Closed pinkforest closed 3 years ago
Tested fix from: #764
And it works now! great @xd009642 fixing it.
Tested on: https://github.com/pinkforest/test_tarpaulin_env
Doctests;
env RUN_MODE=development cargo-tarpaulin tarpaulin --run-types Doctests -v
May 19 13:52:40.343 DEBUG cargo_tarpaulin: set up logging
May 19 13:52:40.540 INFO cargo_tarpaulin: Running Tarpaulin
May 19 13:52:40.540 INFO cargo_tarpaulin: Building project
May 19 13:52:40.540 INFO cargo_tarpaulin::cargo: Cleaning project
Finished test [unoptimized + debuginfo] target(s) in 0.19s
Doc-tests test_tarpaulin_env
May 19 13:52:41.009 INFO cargo_tarpaulin::process_handling::linux: Launching test
May 19 13:52:41.009 INFO cargo_tarpaulin::process_handling: xx running /home/foobar/testing-rust/test_tarpaulin_env/target/doctests/src_cargo_manifest_path_rs_8_0/rust_out
test_dir evaluated to = lossy?:/home/foobar/testing-rust/test_tarpaulin_env/tests/data/test_data
May 19 13:52:41.061 INFO cargo_tarpaulin::report: Coverage Results:
|| Uncovered Lines:
|| Tested/Total Lines:
|| src/cargo_manifest_path.rs: 6/6 +0%
||
100.00% coverage, 6/6 lines covered, +0% change in coverage
Tests:
env RUN_MODE=development cargo-tarpaulin tarpaulin --run-types Tests -v
May 19 13:52:54.191 DEBUG cargo_tarpaulin: set up logging
May 19 13:52:54.387 INFO cargo_tarpaulin: Running Tarpaulin
May 19 13:52:54.387 INFO cargo_tarpaulin: Building project
May 19 13:52:54.387 INFO cargo_tarpaulin::cargo: Cleaning project
Compiling test_tarpaulin_env v0.1.0 (/home/foobar/testing-rust/test_tarpaulin_env)
Finished test [unoptimized + debuginfo] target(s) in 0.29s
May 19 13:52:54.795 INFO cargo_tarpaulin::process_handling::linux: Launching test
May 19 13:52:54.795 INFO cargo_tarpaulin::process_handling: xx running /home/foobar/testing-rust/test_tarpaulin_env/target/debug/deps/test_tarpaulin_env-5a8f46bc4bedec67
running 1 test
test cargo_manifest_path::tests::cargo_manifest_path ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.02s
May 19 13:52:54.902 INFO cargo_tarpaulin::report: Coverage Results:
|| Uncovered Lines:
|| Tested/Total Lines:
|| src/cargo_manifest_path.rs: 9/9 +0%
||
100.00% coverage, 9/9 lines covered, +0% change in coverage
And works with my repo gis_puller now. good stuff - there is one unit that is funky but it's unrelated to this.
Description
When running --run-types Doctests the CARGO_MANIFEST_PATH is missing
Trying to mitigate it with --manifest-path also evaluates to env CARGO_MANIFEST_PATH missing.
On run type Test env CARGO_MANIFEST_PATH is visible just like running the cargo test
I initially ran to this issue here: https://github.com/alexliesenfeld/httpmock/issues/45
cargo version 1.52.0 and 1.54.0-nightly (070e459c2 2021-05-11) same result
Reproduce
I created an environment to reproduce here which has both run type Tests and Doctests: https://github.com/pinkforest/test_tarpaulin_env
Code under test: src/lib.rs has both Doctest and Tests Run types
Run type: Doctests
Doctests will fail with missing CARGO_MANIFEST_PATH due to panic!() from get_my_path I stole from your tests/util.rs
Even if I try --manifest-path=. it fails with relative ./Cargo.toml:
Or even absolute --manifest-path fails:
Tarpaulin did think itself previously the manifest was correctly set as tarpaulin does some checking:
Expectation
On both Doctests and Tests expectation is env CARGO_MANIFEST_PATH evaluates correctly.
Considering:
Doc README.md was initially suggested via PR to make expectation clear not to rely on env CARGO_MANIFEST_PATH:
Which in turn with both code and resp clarifies CARGO_MANIFEST_PATH env should be set despite:
Regular Cargo test:
Cargo test evaluates both correctly using CARGO_MANIFEST_PATH and test succeeds:
Run type: Tests
Tests finds that one unit in cfg test and we see 100% coverage with tarpaulin run mode Tests