The repository contains two main components:
- dev: the development code with a concrete (register) implementation for testing. The folder also contains templates for dynamic code and all the static code that will be bundled together with the generated code.
- -plugins/gorums: second order plugin to
protoc-gen-gorums
binary.
The Makefile itself serves as documentation, inspect it for details. Important targets:
-
make gengolden
: Generate and update what should be the golden output for thegorums
plugin. -
make gendev
: Generate and update_gen.go
files from the dev templates. -
make gengoldenanddev
: Combination of the two targets above.
The following file ending conventions are used in the dev
package:
_gen.go
: File should be generated by the gorums plugin._udef.go
File is user defined._test.go
File is a Go test file.
These endings are important because all other files will be bundled together as static resources during gorums code generation (see the bundle) utility program.
-
Changes should be made to the development code in
dev
. -
Changes in any of the files ending with
_gen.go
must be reflected in the generator. -
If the change is in a "static" file it's enough to update the bundle of static code. This can be done by calling
make genstatic
. -
If any change is done to the static or generated code, the file representing the "golden" output of the generator must be regenerated. This can be done by running
make gengolden
.
See the Makefile for more details.
All tests can be invoked by running make test
and/or make testrace
.
There are three main tests for this project:
-
dev/config_rpc_test.go: The integration test in this package verifies that the concrete client/server register implementation works.
-
End-to-end: This test invokes the generator with the
register.proto
example fromdev
and runs the integration test against the generated code. -
Golden: This test invokes the generator with the
register.proto
example fromdev
and compares the output against a golden output file in thetestdata
folder. This test verifies that the generator output does not change unexpectedly. The golden output file should be updated as described in the previous Workflow section if the output is expected to change.
The benchcmp
program is recommended for comparing benchmarks:
go get -u golang.org/x/tools/cmd/benchcmp
Example :
git checkout devel (or another branch)
cd dev
go test . -run=$$ -bench=Read1KQ2N3Local -benchtime=3s -count=10 > old.txt
*make changes and regenerate _gen.go-files if needed*
go test . -run=$$ -bench=Read1KQ2N3Local -benchtime=3s -count=10 > new.txt
benchcmp old.txt new.txt