datafoodconsortium / connector-codegen

An Acceleo project to generate the source code of the DFC connector into all the supported programming languages.
MIT License
3 stars 3 forks source link

Deterministic order of require statetments #4

Closed mkllnk closed 11 months ago

mkllnk commented 1 year ago

I'm trying to make the build reproducible to avoid random code changes of the generated code. But I'm not sure if it's working.

lecoqlibre commented 11 months ago

Hi @mkllnk,

Thanks! I wanted to talk with you about this issue before.

I think we should generate the tests like I did in the PHP version (see this file). This way there is no need to write new tests by hand when new classes are added. And there is no issue regarding the random generation. You will see I use a method to generate random test values (getTestValues query).

If you like the idea, could you replace the hard-coded tests with generated tests? Do you need help?

mkllnk commented 11 months ago

Oh, sorry, this PR used to contain two changes and I reduced it to one now. The random order of require statements is not related to tests. All the lib classes are affected. When running the generator multiple times with the same input, I don't want to see changes in git status. But currently, I get random changes in the require statements.

mkllnk commented 11 months ago

I think we should generate the tests like I did in the PHP version

Those generated tests are a good addition. I agree that we should do that. But I think that we need additional tests that are written manually. There's static code that needs testing. And we need to make sure that a fail in the auto-generation is detected. Using similar code for the generation of the production classes and the tests doesn't necessarily detect bugs in the generation code itself.

If you like the idea, could you replace the hard-coded tests with generated tests? Do you need help?

I can try and let you know.