I'm Mathis Joffre, I'm 22 years old and I'm an apprentice engineer currently interested in Network, system administration, and software engineering.
🔭 I’m currently working on 5GCoreNetSDK, it is an open source student project that provides a set of APIs to access or provide services in 5G Core Network.
👯 I’m looking to collaborate on open source project
The main idea is to be able to test the generated code against an expected output. Moreover, we should be able to test the behavior of templates against common scenarios, in order to prevent regression.
What is the solution?
Let's define it together!
Why is this important?
This could be a huge blocker for company-grade solutions wanting to use GenZ as they are not able to test templates to avoid regression.
Actual output when running genz tests (via make test-examples) doesn't give information about the context on failure.
▶ genz(refacto-generator-to-parse-1-type-only) $ make test-examples
genz test -directory ./examples/ -v
genz: genz test ./examples/
running test in examples/1_validator/test
genz: generating template for type Human
genz: generated buffer (716 bytes)
genz: gofmt-ing buffer
genz: wrote human_validator.gen.go (580 bytes)
running test in examples/2_getters/test
genz: generating template for type Car
genz: generated buffer (142 bytes)
genz: gofmt-ing buffer
genz: wrote car.gen.go (122 bytes)
? github.com/Joffref/genz/examples/2_getters/test [no test files]
running test in examples/3_tests/tests/0_no_getter
genz: generating template for type Car
genz: generated buffer (19 bytes)
genz: gofmt-ing buffer
genz: wrote car.gen.go (13 bytes)
? github.com/Joffref/genz/examples/3_tests/tests/0_no_getter [no test files]
running test in examples/3_tests/tests/1_1_getter
genz: generating template for type Car
genz: generated buffer (75 bytes)
genz: gofmt-ing buffer
genz: wrote car.gen.go (66 bytes)
=== RUN TestCarGetModel
--- PASS: TestCarGetModel (0.00s)
PASS
ok github.com/Joffref/genz/examples/3_tests/tests/1_1_getter (cached)
genz: Difference between expected.go and generated file:
[]uint8(
"""
... // 22 identical lines
// WORK IN PROGRESS
- // map[_0:+>18 _1:<99]
+ // map[_0:+>18 _1:<99]
return nil
... // 2 identical lines
"""
)
make: *** [Makefile:23: test-examples] Error 1
What is the solution?
I guess we can have a best output to read the results
Getting PASS at the end of unit tests execution even with a failure is a bit tricky because we could understand everything went well, (or is that me ?)
I see that somewhere I got a diff genz: Difference between expected.go and generated file: but there is no information about the concerned directory or test name (I suggest to print the directory and the test name)
(bonus) Maybe we can have a summary at the end ?
Why is this important?
Because currently it's hard to determine where a test did not match