-
Notifications
You must be signed in to change notification settings - Fork 21
Main binary assertions fail with SIGSEGV when attempting to collect coverage with kcov #101
Comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Okay, I fixed the SIGSEGV by using the following: extern crate assert_cli;
use std::env;
fn get_cwd() -> String {
env::current_dir().unwrap().to_str().unwrap().to_string()
}
#[test]
fn test_app_config_works() {
let cfg_file: &str = &format!("{}/tests/data/libtestwppr.toml", get_cwd());
let bin: &str = &format!("{}/target/debug/wppr", get_cwd());
assert_cli::Assert::command(&[bin, "help"])
.succeeds()
.stdout()
.contains("list")
.unwrap();
assert_cli::Assert::command(&[bin, "--configuration", cfg_file, "list"])
.succeeds()
.stdout()
.contains("plugin.php")
.stdout()
.contains("0.1.2")
.unwrap();
} So instead of using the But now kcov says the lib code is not being covered at all so I need to tackle that next. |
This comment has been minimized.
This comment has been minimized.
Thanks for the update and workaround here - I appreciate it. I'm now seeing the same problem as you @rask where kcov isn't seeing coverage for the binaries that |
RE coverage reporting, see #104 (forgot to transfer it over from https://github.com/rust-lang-nursery/cli-wg/issues/9) |
The responsibility for this is moving to assert_cmd and tis will be addressed in assert-rs/assert_cmd#5 assert_cli is going to morph into a wider-focused tool, including things like assert_fs. See #41 |
assert_cli
version:0.5.4
1.25.0
I have a CLI application in the works and wanted to see if
assert_cli
was of any use for me. The crate works fine when runningcargo test
. Neat stuff. :)After running
cargo test
I use kcov to generate code coverage reports for my code. Whenassert_cli
is in use kcov makes the tests fail with asignal: 11, SIGSEGV: invalid memory reference
.I'm not sure if this is related to my newbie Rust code or if kcov and
assert_cli
just don't like each other for some reason.My code for the test:
And the error I get with
RUST_BACKTRACE=full
:As I stated: the tests pass just fine when I run a plain
cargo test
instead of using kcov. kcov operates by taking the built test binaries and running them through again, while looking at what is being run. Would this pose a problem for kcov or assert_cli which is used to run "external" bins that are not directly built from the test case?When I remove the
lib_test.rs
file from kcov runs the tests pass for kcov again, but nothing relating to assert_cli is reported as covered.The application I'm working on is over at https://github.com/rask/wppr which contains the logic right now, the above tests are the only thing I've added which are not in the repo. You can see the
coverage.sh
for a script which I use to run coverage tests on my code. (The in-repocoverage.sh
is missing the kcov definition for running the above lib_test.rs file, but it is the same as thewordpress_test-
pattern inclusion in there.)Please let me know if this issue should be moved somewhere else. :)
The text was updated successfully, but these errors were encountered: