Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fortran serialization codegen tests #198

Merged

Conversation

ChristopherBignamini
Copy link
Contributor

No description provided.

source='\n!$ser savepoint no_deps_run_out\n\n!$ser data c=c\n\n!$ser data b=b')]
return serialization_directives

def test_deserialiser_no_deps_codegen(no_deps_source_file, diffusion_granule_deps,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you declared the no_deps_source_file fixture anywhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I forgot to push the conftest.py file

@@ -24,3 +26,26 @@ def test_deserialiser_diffusion_codegen(diffusion_granule, diffusion_granule_dep
generator = SerialisationGenerator(interface)
generated = generator()
assert len(generated) == 3

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also add one test case for a fortran file which does have dependencies and where the dependencies include derived types so we can test they are being generated correctly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a test_deserialiser_directives_diffusion_codegen test where I check if the serialization directives are correctly generated for the diffusion case, so the derived types serialization are included. I'm not sure this is what you expected, maybe I can create a smaller more specific test...

I have a question concerning the reference code fixtures: in the shorter case of the test_deserialiser_directives_no_deps_codegen test, where I check the generation of the serialization directives for a no-deps small source code, I create the GeneratedCode items and save them in a list, exactly as we do in the serialization code. In the diffusion case, instead, I saved the reference code in a file and then compare the file content to the generated code, after a conversion into a string of the GeneratedCode list (because creating the GeneratedCode instances is a bit complex giving the source code size). Should I unify the two approaches?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the small reference case it makes sense to define the generated code fixture like you did it. I agree that for more complex cases such as when defining the expected code for the diffusion granule, a better approach would be to define the expected code in an external file. Here a compromise would be to for example only check the first savepoint since otherwise the file would be quite large. I've modified the test to check for only the first savepoint, since anyhow that includes all the parts we want to test.

@samkellerhals samkellerhals marked this pull request as ready for review May 9, 2023 14:44
@samkellerhals samkellerhals merged commit c21a8ae into fortran-serialisation May 9, 2023
@samkellerhals samkellerhals deleted the fortran-serialization-codegen-tests branch May 9, 2023 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants