xd009642 / tarpaulin

A code coverage tool for Rust projects
https://crates.io/crates/cargo-tarpaulin
Apache License 2.0
2.5k stars 180 forks source link

rustflags and rustdocflags in config.toml can be string or list #797

Closed xd009642 closed 3 years ago

xd009642 commented 3 years ago

The current code assumes rustflags can only be a list of strings not a single string. This apparently causes some projects to fail to build correctly.

whirm commented 3 years ago

I think this needs to be reopened.

Having this in config.toml works:

rustflags = ["-Ctarget-cpu=native"]

But this fails:

rustflags = "-Ctarget-cpu=native"

# RUST_BACKTRACE=1 cargo tarpaulin -v Aug 20 14:17:35.660 DEBUG cargo_tarpaulin: set up logging Aug 20 14:17:35.758 INFO cargo_tarpaulin: Running Tarpaulin Aug 20 14:17:35.758 INFO cargo_tarpaulin: Building project Aug 20 14:17:35.758 INFO cargo_tarpaulin::cargo: Cleaning project thread 'main' panicked at 'called Option::unwrap() on a None value', /home/whirm/.cargo/registry/src/github.com-1ecc6299db9ec823/cargo-tarpaulin-0.18.0/src/cargo.rs:582:14 stack backtrace: 0: rust_begin_unwind at /rustc/3d0774d0dc98084d25d95cc1909a8051ebbd9cb1/library/std/src/panicking.rs:517:5 1: core::panicking::panic_fmt at /rustc/3d0774d0dc98084d25d95cc1909a8051ebbd9cb1/library/core/src/panicking.rs:93:14 2: core::panicking::panic at /rustc/3d0774d0dc98084d25d95cc1909a8051ebbd9cb1/library/core/src/panicking.rs:50:5 3: core::ops::function::impls::<impl core::ops::function::FnOnce for &mut F>::call_once 4: <alloc::vec::Vec as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter 5: cargo_tarpaulin::cargo::look_for_rustflags_in_file 6: cargo_tarpaulin::cargo::look_for_rustflags_in 7: cargo_tarpaulin::cargo::rust_flags 8: cargo_tarpaulin::cargo::run_cargo 9: cargo_tarpaulin::cargo::get_tests 10: cargo_tarpaulin::launch_tarpaulin 11: cargo_tarpaulin::trace 12: cargo_tarpaulin::run 13: cargo_tarpaulin::main note: Some details are omitted, run with RUST_BACKTRACE=full for a verbose backtrace.

Thanks!

xd009642 commented 3 years ago

@whirm since I merged that PR there hasn't been a new release. Try installing the version on the develop branch and see if the issue persists (it shouldn't, but if it does we can reopen)

whirm commented 3 years ago

Oh, my bad. I didn't think about checking for that. Thanks!