nix-community / crate2nix

rebuild only changed crates in CI with crate2nix and nix
https://nix-community.github.io/crate2nix/
Apache License 2.0
374 stars 89 forks source link

Allow arbitrary commands before and after tests #193

Closed Fuuzetsu closed 3 years ago

Fuuzetsu commented 3 years ago

An immediate use-case is to inject any environment variables that the test may be relying on, such as location of some external files or overriding some behaviour.

Another, perhaps more cliche use-case is for unsetting the -e bash flag: this will allow us to capture output of failing tests without giving up on expression itself. In this way, it fixes #191.

Fuuzetsu commented 3 years ago

I verified that I can deal with #191 just by doing

testPreRun = "set +e";
testPostRun = "set -e";

I also verified that when neither of these flags is set, I don't have any rebuild of the tests so any existing users should not be affected by the change.

Fuuzetsu commented 3 years ago

@kolloch Any updates? It'd be cool if we could use the repo directly rather than our fork. We've been using this change for a while with success.

Fuuzetsu commented 3 years ago

Could you document this in the README.md please and regenarate generated sources by executing run_tests.sh? (sorry, this will download the internet)

Done. All tests passed apparently. I committed the changes. I fixed small typo/grammar issue in the comment, nothing major.

Feel free to change the README.md sections as you see fit if you imagined something a bit different.