Closed winksaville closed 3 years ago
So there was a cargo PR about this that was meant to fix it. I tried to use the latest nightly for your project with the latest nightly compiler just to make sure I was using a version of cargo with the fix in and instead I encountered ICE https://github.com/rust-lang/rust/issues/84225 .
Tomorrow is the start of my weekend so I'll set aside some time to more thoroughly diff 0.16.0 and 0.18.0-alpha1 to try and see what changed and also try it out on some other projects to get to the bottom of it.
@xd009642, txs for looking into this.
This evening, I'll try to simplify the code.
I've simplified the code its on my tarpaulin-requires-cargo-clean branch.
main.rs is as simple as I could get:
wink@3900x:~/prgs/rust/projects/binance-auto-sell (tarpaulin-requires-cargo-clean)
$ cat src/main.rs
use clap::Clap;
#[derive(Clap)]
struct Cli {}
fn main() {
Cli::parse(); // Fails
//Cli {}; // Works
}
tests/cli.rs is empty
wink@3900x:~/prgs/rust/projects/binance-auto-sell (tarpaulin-requires-cargo-clean)
$ ls -al tests
total 8
drwxr-xr-x 2 wink users 4096 Apr 15 21:54 .
drwxr-xr-x 6 wink users 4096 Apr 15 22:11 ..
-rw-r--r-- 1 wink users 0 Apr 15 21:48 cli.rs
In Cargo.toml I've removed the [dev-dependencies]
wink@3900x:~/prgs/rust/projects/binance-auto-sell (tarpaulin-requires-cargo-clean)
$ cat Cargo.toml
[package]
name = "binance-auto-sell"
version = "0.1.0"
authors = ["Wink Saville <wink@saville.com>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
clap = "3.0.0-beta.2"
rust-toolchain is still stable
wink@3900x:~/prgs/rust/projects/binance-auto-sell (tarpaulin-requires-cargo-clean)
$ cat rust-toolchain
[toolchain]
channel = "stable"
components = [ "rustfmt", "rustc-dev" ]
profile = "minimal"
And tarpaulin is still 0.18.0-alpha1
wink@3900x:~/prgs/rust/projects/binance-auto-sell (tarpaulin-requires-cargo-clean)
$ cargo tarpaulin --version
cargo-tarpaulin version: 0.18.0-alpha1
And running cargo clean ; cargo build ; cargo tarpaulin
still fails:
wink@3900x:~/prgs/rust/projects/binance-auto-sell (tarpaulin-requires-cargo-clean)
$ cargo clean ; cargo build ; cargo tarpaulin
Compiling proc-macro2 v1.0.26
Compiling version_check v0.9.3
Compiling unicode-xid v0.2.1
Compiling syn v1.0.69
Compiling libc v0.2.93
Compiling autocfg v1.0.1
Compiling bitflags v1.2.1
Compiling unicode-segmentation v1.7.1
Compiling unicode-width v0.1.8
Compiling hashbrown v0.9.1
Compiling vec_map v0.8.2
Compiling strsim v0.10.0
Compiling termcolor v1.1.2
Compiling lazy_static v1.4.0
Compiling os_str_bytes v2.4.0
Compiling textwrap v0.12.1
Compiling proc-macro-error-attr v1.0.4
Compiling proc-macro-error v1.0.4
Compiling indexmap v1.6.2
Compiling heck v0.3.2
Compiling quote v1.0.9
Compiling atty v0.2.14
Compiling clap_derive v3.0.0-beta.2
Compiling clap v3.0.0-beta.2
Compiling binance-auto-sell v0.1.0 (/home/wink/prgs/rust/projects/binance-auto-sell)
Finished dev [unoptimized + debuginfo] target(s) in 7.38s
Apr 15 22:18:10.142 INFO cargo_tarpaulin: Running Tarpaulin
Apr 15 22:18:10.142 INFO cargo_tarpaulin: Building project
Compiling proc-macro2 v1.0.26
Compiling version_check v0.9.3
Compiling unicode-xid v0.2.1
Compiling syn v1.0.69
Compiling libc v0.2.93
Compiling autocfg v1.0.1
Compiling unicode-segmentation v1.7.1
Compiling bitflags v1.2.1
Compiling unicode-width v0.1.8
Compiling hashbrown v0.9.1
Compiling termcolor v1.1.2
Compiling strsim v0.10.0
Compiling os_str_bytes v2.4.0
Compiling lazy_static v1.4.0
Compiling vec_map v0.8.2
Compiling textwrap v0.12.1
Compiling proc-macro-error-attr v1.0.4
Compiling proc-macro-error v1.0.4
Compiling indexmap v1.6.2
Compiling heck v0.3.2
Compiling quote v1.0.9
Compiling atty v0.2.14
Compiling clap_derive v3.0.0-beta.2
Compiling clap v3.0.0-beta.2
Compiling binance-auto-sell v0.1.0 (/home/wink/prgs/rust/projects/binance-auto-sell)
error: could not compile `binance-auto-sell`
To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
thread 'main' panicked at 'already borrowed: BorrowMutError', src/tools/cargo/src/cargo/util/config/mod.rs:307:20
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Apr 15 22:18:17.719 ERROR cargo_tarpaulin: Failed to compile tests! Error: binance-auto-sell: linking with `cc` failed: exit code: 1
Error: "Failed to compile tests! Error: binance-auto-sell: linking with `cc` failed: exit code: 1"
But if I comment out Cli::parse();
and uncomment Cli::{};
wink@3900x:~/prgs/rust/projects/binance-auto-sell (tarpaulin-requires-cargo-clean)
$ cat src/main.rs
use clap::Clap;
#[derive(Clap)]
struct Cli {}
fn main() {
//Cli::parse(); // Fails
Cli {}; // Works
}
It "works":
wink@3900x:~/prgs/rust/projects/binance-auto-sell (tarpaulin-requires-cargo-clean)
$ cargo clean ; cargo build ; cargo tarpaulin
Compiling version_check v0.9.3
Compiling proc-macro2 v1.0.26
Compiling unicode-xid v0.2.1
Compiling syn v1.0.69
Compiling libc v0.2.93
Compiling autocfg v1.0.1
Compiling bitflags v1.2.1
Compiling unicode-segmentation v1.7.1
Compiling unicode-width v0.1.8
Compiling hashbrown v0.9.1
Compiling os_str_bytes v2.4.0
Compiling strsim v0.10.0
Compiling lazy_static v1.4.0
Compiling termcolor v1.1.2
Compiling vec_map v0.8.2
Compiling textwrap v0.12.1
Compiling proc-macro-error-attr v1.0.4
Compiling proc-macro-error v1.0.4
Compiling indexmap v1.6.2
Compiling heck v0.3.2
Compiling quote v1.0.9
Compiling atty v0.2.14
Compiling clap_derive v3.0.0-beta.2
Compiling clap v3.0.0-beta.2
Compiling binance-auto-sell v0.1.0 (/home/wink/prgs/rust/projects/binance-auto-sell)
Finished dev [unoptimized + debuginfo] target(s) in 7.19s
Apr 15 22:20:52.004 INFO cargo_tarpaulin: Running Tarpaulin
Apr 15 22:20:52.004 INFO cargo_tarpaulin: Building project
Compiling proc-macro2 v1.0.26
Compiling version_check v0.9.3
Compiling unicode-xid v0.2.1
Compiling syn v1.0.69
Compiling autocfg v1.0.1
Compiling libc v0.2.93
Compiling bitflags v1.2.1
Compiling unicode-segmentation v1.7.1
Compiling hashbrown v0.9.1
Compiling unicode-width v0.1.8
Compiling os_str_bytes v2.4.0
Compiling vec_map v0.8.2
Compiling lazy_static v1.4.0
Compiling strsim v0.10.0
Compiling termcolor v1.1.2
Compiling textwrap v0.12.1
Compiling proc-macro-error-attr v1.0.4
Compiling proc-macro-error v1.0.4
Compiling indexmap v1.6.2
Compiling heck v0.3.2
Compiling quote v1.0.9
Compiling atty v0.2.14
Compiling clap_derive v3.0.0-beta.2
Compiling clap v3.0.0-beta.2
Compiling binance-auto-sell v0.1.0 (/home/wink/prgs/rust/projects/binance-auto-sell)
Finished test [unoptimized + debuginfo] target(s) in 7.33s
Apr 15 22:20:59.385 INFO cargo_tarpaulin::process_handling::linux: Launching test
Apr 15 22:20:59.385 INFO cargo_tarpaulin::process_handling: running /home/wink/prgs/rust/projects/binance-auto-sell/target/debug/deps/cli-780735ec9073a7ff
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
Apr 15 22:20:59.458 INFO cargo_tarpaulin::process_handling::linux: Launching test
Apr 15 22:20:59.458 INFO cargo_tarpaulin::process_handling: running /home/wink/prgs/rust/projects/binance-auto-sell/target/debug/deps/binance_auto_sell-cc700bcd52a31b50
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
Apr 15 22:21:00.030 INFO cargo_tarpaulin::report: Coverage Results:
|| Tested/Total Lines:
|| src/main.rs: 0/1
||
0.00% coverage, 0/1 lines covered
I hope this makes identifing the problem easier. Let me know if there is anything you'd like me to do!
So it looks like this may have been indirectly caused by the same issue being fixed by https://github.com/rust-lang/rust/pull/84226 . I'll change tarpaulin to clean by default to solve it and then remove that option once this makes it into stable
So 0.18.0-alpha2 is now released that fixes the issue until that rust PR makes it into the 1.53.0 stable, checked it and it works as expected :+1:
Txs for adding --skip-clean!
Describe the bug When using Tarpaulin 0.18.0-alpha1 installed from a clone of this project:
I get the following error when I compile winksaville/binance-auto-sell:
If instead I use the release version, 0.16.0:
It completes successfully:
To Reproduce
Here is the command line and full output. Notice that this happens after a
cargo build
:Work-around If I do a
cargo clean
before thecargo tarpaulin
it works:And if I add the
--follow-exec
parameter I see the expected 100.00% coverage:Expected behavior The version 0.18.0-alpha1 should behave the same as 0.16.0.
System information Arch Linux:
output of
rustup show
:My rust-toolchain file: