est31 / cargo-udeps

Find unused dependencies in Cargo.toml
Other
1.76k stars 46 forks source link

Tests are failing in a clean chroot #86

Closed orhun closed 3 years ago

orhun commented 3 years ago

Hey, I'm trying to build cargo-udeps in a clean chroot. I will package it for the Arch Linux community repository afterwards.

Unfortunately I'm getting the following error(s) while running the tests:

[root@orhun cargo-udeps-0.1.17]# cargo test --no-fail-fast
    Finished test [unoptimized] target(s) in 0.29s
     Running target/debug/deps/cargo_udeps-0e5cb73693edb719

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

     Running target/debug/deps/cargo_udeps-55a0336dd6431257

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

     Running target/debug/deps/ignore-6df070b5d2e170ba

running 2 tests
test ignore_all ... FAILED
test ignore_if_chain ... FAILED

failures:

---- ignore_all stdout ----
Error: No such file or directory (os error 2)
thread 'ignore_all' panicked at 'assertion failed: `(left == right)`
  left: `1`,
 right: `0`: the test returned a termination value with a non-zero status code (1) which indicates a failure', /build/rust/src/rustc-1.49.0-src/library/test/src/lib.rs:193:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

---- ignore_if_chain stdout ----
Error: build failed
thread 'ignore_if_chain' panicked at 'assertion failed: `(left == right)`
  left: `1`,
 right: `0`: the test returned a termination value with a non-zero status code (1) which indicates a failure', /build/rust/src/rustc-1.49.0-src/library/test/src/lib.rs:193:5

failures:
    ignore_all
    ignore_if_chain

test result: FAILED. 0 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out

     Running target/debug/deps/non_lib_build_dep-137239edea01881b

running 2 tests
test with_all_targets ... FAILED
test without_all_targets ... FAILED

failures:

---- with_all_targets stdout ----
Error: No such file or directory (os error 2)
thread 'with_all_targets' panicked at 'assertion failed: `(left == right)`
  left: `1`,
 right: `0`: the test returned a termination value with a non-zero status code (1) which indicates a failure', /build/rust/src/rustc-1.49.0-src/library/test/src/lib.rs:193:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

---- without_all_targets stdout ----
Error: could not compile `non_lib_build_dep`

Caused by:
    process didn't exit successfully: `rustc --crate-name non_lib_build_dep src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata -C embed-bitcode=no -C debuginfo=2 -C metadata=3af69da90063ed9c -C extra-filename=-3af69da90063ed9c --out-dir /tmp/cargo_udeps_test_non_lib_build_dep_without_all_targetsQ7Dlqf/target/debug/deps -C incremental=/tmp/cargo_udeps_test_non_lib_build_dep_without_all_targetsQ7Dlqf/target/debug/incremental -L dependency=/tmp/cargo_udeps_test_non_lib_build_dep_without_all_targetsQ7Dlqf/target/debug/deps -Z binary-dep-depinfo -Z save-analysis` (exit code: 1)
thread 'without_all_targets' panicked at 'assertion failed: `(left == right)`
  left: `1`,
 right: `0`: the test returned a termination value with a non-zero status code (1) which indicates a failure', /build/rust/src/rustc-1.49.0-src/library/test/src/lib.rs:193:5

failures:
    with_all_targets
    without_all_targets

test result: FAILED. 0 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out

     Running target/debug/deps/normal_dev_build-04fcb6cd2731c255

running 2 tests
test with_all_targets ... FAILED
test without_all_targets ... FAILED

failures:

---- with_all_targets stdout ----
Error: No such file or directory (os error 2)
thread 'with_all_targets' panicked at 'assertion failed: `(left == right)`
  left: `1`,
 right: `0`: the test returned a termination value with a non-zero status code (1) which indicates a failure', /build/rust/src/rustc-1.49.0-src/library/test/src/lib.rs:193:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

---- without_all_targets stdout ----
Error: build failed
thread 'without_all_targets' panicked at 'assertion failed: `(left == right)`
  left: `1`,
 right: `0`: the test returned a termination value with a non-zero status code (1) which indicates a failure', /build/rust/src/rustc-1.49.0-src/library/test/src/lib.rs:193:5

failures:
    with_all_targets
    without_all_targets

test result: FAILED. 0 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out

     Running target/debug/deps/unused_byteorder-889aecdede1cfe24

running 2 tests
test with_all_targets ... FAILED
test without_all_targets ... FAILED

failures:

---- with_all_targets stdout ----
Error: No such file or directory (os error 2)
thread 'with_all_targets' panicked at 'assertion failed: `(left == right)`
  left: `1`,
 right: `0`: the test returned a termination value with a non-zero status code (1) which indicates a failure', /build/rust/src/rustc-1.49.0-src/library/test/src/lib.rs:193:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

---- without_all_targets stdout ----
Error: could not compile `byteorder`

Caused by:
    process didn't exit successfully: `rustc --crate-name byteorder --edition=2018 /root/.cargo/registry/src/github.com-1ecc6299db9ec823/byteorder-1.4.2/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata -C embed-bitcode=no -C debuginfo=2 --cfg 'feature="default"' --cfg 'feature="std"' -C metadata=e6cb78bee3e3a9e7 -C extra-filename=-e6cb78bee3e3a9e7 --out-dir /tmp/cargo_udeps_test_unused_byteorder_without_all_targetseDd9Kl/target/debug/deps -L dependency=/tmp/cargo_udeps_test_unused_byteorder_without_all_targetseDd9Kl/target/debug/deps --cap-lints allow -Z binary-dep-depinfo` (exit code: 1)
thread 'without_all_targets' panicked at 'assertion failed: `(left == right)`
  left: `1`,
 right: `0`: the test returned a termination value with a non-zero status code (1) which indicates a failure', /build/rust/src/rustc-1.49.0-src/library/test/src/lib.rs:193:5

failures:
    with_all_targets
    without_all_targets

test result: FAILED. 0 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out

   Doc-tests cargo-udeps

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

error: test failed.

Error: No such file or directory (os error 2)

I suspect that it might be about the temp file being dropped early. (tempfile#115)

Any ideas about what might cause this?

est31 commented 3 years ago

Thanks for the report!

  1. Is this with an issue with an attempt to update cargo-udeps to a new version, or do you suspect older versions have it too? (no need to verify, just maybe it helps with finding the cause for the bug)

  2. the tests work if you don't run it from a chroot, right?

orhun commented 3 years ago
1. Is this with an issue with an attempt to update cargo-udeps to a new version, or do you suspect older versions have it too? (no need to verify, just maybe it helps with finding the cause for the bug)

No, I only tried to build 0.1.17 since it's the latest release.

2. the tests work if you don't run it from a chroot, right?

Yup, they run without any fails.

qryxip commented 3 years ago

I've run the tests in a chroot with base-devel, git, and rustup, and the tests passed.

❯ yay -S devtools
⋮
⋮
❯ mkdir ~/chroot
❯ mkarchroot ~/chroot/root base-devel
⋮
⋮
❯ arch-nspawn ~/chroot/root bash
[root@root /]# pacman -S git rustup
⋮
⋮
[root@root ~]# cd
[root@root ~]# rustup install stable nightly
⋮
⋮
[root@root ~]# git clone https://github.com/cargo-udeps
⋮
⋮
[root@root ~]# cd ./cargo-udeps
[root@root cargo-udeps]# cargo --version
cargo 1.49.0 (d00d64df9 2020-12-05)
[root@root cargo-udeps]# cargo +nightly --version
cargo 1.51.0-nightly (c3abcfe8a 2021-01-25)
[root@root cargo-udeps]# cargo test
   Compiling cargo-udeps v0.1.17 (/root/cargo-udeps)
    Finished test [unoptimized] target(s) in 2m 11s
     Running target/debug/deps/cargo_udeps-94f9dbcc781cffce
⋮
⋮
[root@root cargo-udeps]# echo $?
0

I think the std::io::Error comes from this.

https://github.com/est31/cargo-udeps/blob/dca356df2c831556f5bf34ca3fc481d31df922d9/tests/runner/mod.rs#L27-L30

orhun commented 3 years ago

@qryxip good catch! rustup was missing since the package was built using rust. I used rustup for the PKGBUILD and everything works like a charm now.