Skip to content

Commit

Permalink
Add test for issue #966
Browse files Browse the repository at this point in the history
  • Loading branch information
xd009642 committed Mar 6, 2022
1 parent 7101a16 commit 55b9788
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/data/follow_exec_issue966/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/target
Cargo.lock
7 changes: 7 additions & 0 deletions tests/data/follow_exec_issue966/.tarpaulin.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[examples]
command = "Build"
run-types = ["Examples"]
follow-exec = true

#[tests]
#run-types = ["Tests"]
8 changes: 8 additions & 0 deletions tests/data/follow_exec_issue966/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "follow_exec_issue966"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
17 changes: 17 additions & 0 deletions tests/data/follow_exec_issue966/examples/test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use follow_exec_issue966::*;

fn main() {
let args: Vec<_> = std::env::args().into_iter().collect();
println!("args: {:?}", args);
if args.contains(&"do_the_thing".into()) {
do_the_thing();
return;
}

let exe_path = std::env::current_exe().unwrap();

std::process::Command::new(exe_path)
.args(&["call_main", "--", "do_the_thing"])
.spawn()
.unwrap();
}
6 changes: 6 additions & 0 deletions tests/data/follow_exec_issue966/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
use std::io::Write;

pub fn do_the_thing() {
let mut f = std::fs::File::create("/tmp/whatever").unwrap();
f.write("hello\n".as_bytes()).unwrap();
}
11 changes: 11 additions & 0 deletions tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,17 @@ fn config_file_coverage() {
check_percentage_with_cli_args(0.0f64, true, &args);
}

#[test]
fn issue_966_follow_exec() {
let test_dir = get_test_path("follow_exec_issue966");
let args = vec![
"tarpaulin".to_string(),
"--root".to_string(),
test_dir.display().to_string(),
];
check_percentage_with_cli_args(1.0f64, true, &args);
}

#[test]
fn rustflags_config_coverage() {
let test_dir = get_test_path("multiple_rustflags");
Expand Down

0 comments on commit 55b9788

Please sign in to comment.