winksaville / rust-binance-cli

Automatically sell all assets owned by the user on binance.us except USD, USDT plus a minimum of BNB is kept.
Apache License 2.0
2 stars 6 forks source link

Problem with using `cargo tarpaulin` #1

Open winksaville opened 3 years ago

winksaville commented 3 years ago

There is a problem somewhere, if you've previously done a cargo build|test|run you must do a cargo clean before a cargo tarpaulin will succeed. And then you may get a link error if you subsequently do a cargo build. This too can be resolved by doing a cargo clean before the first subsequent cargo build :(

Here is the error I'm seeing:

wink@3900x:~/prgs/rust/projects/binance-auto-sell (main)
$ cargo tarpaulin --follow-exec
Apr 13 17:48:22.451  INFO cargo_tarpaulin: Running Tarpaulin
Apr 13 17:48:22.451  INFO cargo_tarpaulin: Building project
   Compiling autocfg v1.0.1
   Compiling proc-macro2 v1.0.26
...
   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 13 17:48:30.124 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"

After a cargo clean I see:

wink@3900x:~/prgs/rust/projects/binance-auto-sell (main)
$ cargo clean ; cargo tarpaulin --follow-exec
Apr 13 17:50:45.333  INFO cargo_tarpaulin: Running Tarpaulin
Apr 13 17:50:45.333  INFO cargo_tarpaulin: Building project
   Compiling autocfg v1.0.1
   Compiling proc-macro2 v1.0.26
   Compiling version_check v0.9.3
...
   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 8.25s
Apr 13 17:50:53.842  INFO cargo_tarpaulin::process_handling::linux: Launching test
Apr 13 17:50:53.842  INFO cargo_tarpaulin::process_handling: running /home/wink/prgs/rust/projects/binance-auto-sell/target/debug/deps/binance_auto_sell-8b2f8d3614c3ece0

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

Apr 13 17:50:54.416  INFO cargo_tarpaulin::process_handling::linux: Launching test
Apr 13 17:50:54.416  INFO cargo_tarpaulin::process_handling: running /home/wink/prgs/rust/projects/binance-auto-sell/target/debug/deps/cli-595a799ae4fee77f

running 4 tests
test test_no_params ... ok
test test_help ... ok
test test_req_params_as_env_vars ... ok
test test_req_params ... ok

test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 2.30s

Apr 13 17:50:57.732  INFO cargo_tarpaulin::report: Coverage Results:
|| Tested/Total Lines:
|| src/main.rs: 6/6
|| 
100.00% coverage, 6/6 lines covered
winksaville commented 3 years ago

Added issue #736 to trapaulin repo.

winksaville commented 3 years ago

Added issue #736 to trapaulin repo.

Semi fixed as tarpaulin now automatically cleans so just do a cargo tarpaulin. BUT you must do a cargo clean before doing any subsequent cargo build|run|test. What I do now is use a trivial shell script cargo-precommit:

echo clippy ; cargo clippywink@3900x:~/prgs/rust/projects/binance-auto-sell (main)
$ cat ./cargo-pre-commit 
#!/usr/bin/env bash
set -e
echo check ; cargo check
echo fmt ; cargo fmt
echo test ; cargo test
echo tarpaulin ; cargo tarpaulin
echo clean ; cargo clean
echo clippy ; cargo clippy

Which does a cargo clean before cargo clippy as the last operation, so I don't need to worry about it. If you copy it to ~/.cargo/bin/:

wink@3900x:~/prgs/rust/projects/binance-auto-sell (main)
$ cp ./cargo-precommit ~/.cargo/bin/

And then just do a cargo pre-commit before commiting:

wink@3900x:~/prgs/rust/projects/binance-auto-sell (main)
$ cp ./cargo-precommit ~/.cargo/bin/
...