Skip to content

Conversation

patonw
Copy link

@patonw patonw commented Jul 30, 2025

This updates the build script to write generated integration tests to the OUT_DIR in accordance to The Cargo Book :

Build scripts may save any output files or intermediate artifacts in the directory specified in the OUT_DIR environment variable. Scripts should not modify any files outside of that directory.

Additionally, the current method of writing tests to the repo working directory during builds causes issues with hermetic build systems that need the source to be hashable and hence immutable. Such systems require that any artifacts created during the build process are written outside the source directory into a designated output location. Projects using this library as a direct dependency can work around by overriding the default feature set (which is a bit awkward). But for transitive dependencies this is fairly problematic.

I've attached a log from running the integration tests to demonstrate that they can and are still being run from the output directory: test-output.log

Another run, but injecting a fault into the snippets to demonstrate that it runs against the snippets from the repo and not empty modules or extraneous code: fault-injection.log


All Submissions:

  • Contributions should target the dev branch. Did you create your branch from dev?
  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

P.S. Might be helpful to include the link to CONTRIBUTING in the PR template in checkbox 2

@patonw patonw marked this pull request as draft July 30, 2025 20:10
@patonw patonw marked this pull request as ready for review July 30, 2025 20:44
@generall
Copy link
Member

I would prefer to keep generated tests in the source. Maybe better alternative would be to move generation of tests out of build.rs (but keep in CI)

@patonw
Copy link
Author

patonw commented Aug 24, 2025

That could be done with a fairly trivial shell script. A separate git hook could also verify that the snippets and tests are in sync by generating to a temp dir and comparing with the source.

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