Tests Are Broken

#14 · closed · 4 comments

View on GitHub ↗

sunjay

This crate seems to no longer work. It's likely because of changes in Cargo. I believe the OUT_DIR environment variable is not being set in the way you expected anymore. You can reproduce this with your own example tests. Just go into `examples/01-simple` and run `cargo +nightly test`. ``` $ cargo +nightly test Compiling stainless v0.1.11 Compiling sum v0.1.0 (file:///home/sunjay/Documents/projects/second_law/examples/01-simple) Compiling libc v0.2.21 Compiling rand v0.3.15 Compiling tempdir v0.3.5 Compiling second_law v0.2.2 Finished dev [unoptimized + debuginfo] target(s) in 21.7 secs Running target/debug/deps/sum-447e9923084d79b9 running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured Running target/debug/deps/test_basic-32c809a13096e1cb running 4 tests test sum_adds_numbers ... FAILED test sum_no_args_returns_zero ... FAILED test sum_error_non_numeric ... FAILED test sum_works_with_zero ... FAILED failures: ---- sum_adds_numbers stdout ---- thread 'sum_adds_numbers' panicked at 'expected a cargo out dir environment variable: NotPresent', /checkout/src/libcore/result.rs:859 note: Run with `RUST_BACKTRACE=1` for a backtrace. ---- sum_no_args_returns_zero stdout ---- thread 'sum_no_args_returns_zero' panicked at 'expected a cargo out dir environment variable: NotPresent', /checkout/src/libcore/result.rs:859 ---- sum_error_non_numeric stdout ---- thread 'sum_error_non_numeric' panicked at 'expected a cargo out dir environment variable: NotPresent', /checkout/src/libcore/result.rs:859 ---- sum_works_with_zero stdout ---- thread 'sum_works_with_zero' panicked at 'expected a cargo out dir environment variable: NotPresent', /checkout/src/libcore/result.rs:859 failures: sum_adds_numbers sum_error_non_numeric sum_no_args_returns_zero sum_works_with_zero test result: FAILED. 0 passed; 4 failed; 0 ignored; 0 measured error: test failed, to rerun pass '--test test_basic' ```

Comments

sunjay

I did a bit of binary search and found that the breakage happened somewhere between nightly-2016-11-29 and nightly-2016-12-16. There were no nightlies published between those dates. The tests work on 2016-11-29 and begin to fail on 2016-12-16.

gnzlbg

This means second law is basically unusable today without setting the OUT_DIR environment variable, any alternatives?

nathanross

This slipped past my radar, sorry, I'll resolve this within 24 hours @sunjay @gnzlbg

nathanross

Created new version and published to cargo. Thank you @gnzlbg @sunjay and let me know if you use it and run into issues again! @gnzlbg an alternative if you're looking for one is assert_cli, assert_cli is more of the "do one thing and do it well" vs this more opinionated out-of-the-box repo that assumes by default an environment wipe, a temporary directory, and that you might have a fixtures dir, and other minor testing conveniences. Because of fixes needed due to unrelated bitrot, it is a breaking change, specifically it makes SceneSettings.repo_fixture_path an Option<PathBuf> and makes AtPath.root_dir_resolved return an Option<String>. If your Cargo.toml uses "0.2" update it to "0.3"