Test `list_optional_deps_as_feature` fails on Rust 1.60
lilyball opened this issue · 2 comments
Running the test suite with Rust 1.60 fails the list_optional_deps_as_feature
test with the following output:
❯ cargo test
Finished test [unoptimized + debuginfo] target(s) in 0.01s
Running unittests (target/debug/deps/cargo_feature-0552cd56c3a73a3d)
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
Running tests/success.rs (target/debug/deps/success-3a7c3c4de90d35a2)
running 8 tests
test ui_not_exist ... ok
test list_features ... ok
test hypen_underline ... ok
test list_optional_deps_as_feature ... FAILED
test default_add ... ok
test disable_default_features ... ok
test add_target_feature ... ok
test remove_feature ... ok
failures:
---- list_optional_deps_as_feature stdout ----
thread 'list_optional_deps_as_feature' panicked at 'Unexpected stdout, failed diff original var
├── original: test-lib (optional)
├── diff:
| --- orig
| +++ var
| @@ -0,0 +1 @@
| +test-lib = ["dep:test-lib"]
└── var as str: test-lib = ["dep:test-lib"]
test-lib (optional)
command=`"/Users/lily/Dev/Rust/Scratch/cargo-feature/target/debug/cargo-feature" "feature" "-p" "test_lib_dep"`
code=0
stdout="\u{1b}[32mtest-lib\u{1b}[0m = [\"dep:test-lib\"]\n\u{1b}[33mtest-lib\u{1b}[0m (optional)\n"
stderr="\u{1b}[1;36m Avaliable\u{1b}[0m features for `test_lib_dep`\n"
', /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/ops/function.rs:227:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
failures:
list_optional_deps_as_feature
test result: FAILED. 7 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.45s
error: test failed, to rerun pass '--test success'
It looks like this is caused by Rust 1.60's new dep:cratename
syntax. Apparently the implicit feature named after an optional crate now shows up as e.g. test-lib = ["dep:test-lib"]
. This case should probably be detected and suppressed.
It looks like this is an artifact of the current runtime toolchain rather than the build version, e.g. cargo feature --manifest-path tests/test-ws/Cargo.toml -p test-lib-dep
with Rust 1.60 produces the extra output but using cargo +1.56.1 feature …
prints the correct output.
In any case, this issue is preventing me from installing cargo-feature with recent nixpkgs (without overriding it to skip tests).
It looks like this is an artifact of the current runtime toolchain rather than the build version
cargo-feature
uses cargo-metadata
which use local cargo and its output had changed in 1.60.0