rust-client
rust-client copied to clipboard
Write generated tests to OUT_DIR instead of repo working dir
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:
- [x] Contributions should target the
devbranch. Did you create your branch fromdev? - [x] Have you followed the guidelines in our Contributing document?
- [x] 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
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)
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.