Repository: xd009642/tarpaulin
Pull request #956 (2022-02-12 14:46:59)

Apply some tweaks based on cargo-mutants
Firmed up the branch analysis tests and fixed one issue (for when it
hopefully moves forward in the future). Fixed a gap in source_analysis
tests. Minor tweak to CARGO_HOME test to make it a bit cleaner

Fixes https://github.com/xd009642/tarpaulin/issues/954


xd009642: Notes on tests that could be added:

1. Run doc tests project, modify to change line of doc test and the doc test comment and then run again. Ensure results aren't confused.

Things I can't think of a way to add:

1. Some of the "untested" features involve tweaking the args passed to the test binary. I don't have a way of introspecting hose args but I could maybe break out into another function and unit test them :thinking:  

Patch:
diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml
index 2656d28..88d5327 100644
--- a/.github/workflows/rust.yml
+++ b/.github/workflows/rust.yml
@@ -33,11 +33,11 @@ jobs:
         env:
           RUST_BACKTRACE: 1
       - name: test
-        run: cargo test -- --test-threads 1
+        run: cargo test
         env:
           RUST_BACKTRACE: 1
       - name: ignored test
-        run: cargo test -- --test-threads 1 --ignored || true
+        run: cargo test -- --ignored || true
         env:
           RUST_BACKTRACE: 1
         if: matrix.version == 'nightly'
@@ -62,7 +62,7 @@ jobs:
       - name: build
         run: cargo build
       - name: test
-        run: cargo test -- --test-threads 1 || true
+        run: cargo test -- || true
         env:
           RUST_BACKTRACE: 1
   mac:
@@ -83,6 +83,6 @@ jobs:
       - name: build
         run: cargo build
       - name: test
-        run: cargo test -- --test-threads 1 || true
+        run: cargo test -- || true
         env:
           RUST_BACKTRACE: 1
diff --git a/Cargo.lock b/Cargo.lock
index 5d1c8f2..ebeb0c2 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -106,6 +106,7 @@ dependencies = [
  "regex",
  "rustc-demangle",
  "rustc_version",
+ "rusty-fork",
  "serde",
  "serde_json",
  "syn",
@@ -241,6 +242,15 @@ version = "0.2.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7"
 
+[[package]]
+name = "fastrand"
+version = "1.7.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c3fcf0cee53519c866c09b5de1f6c56ff9d647101f81c1964fa632e148896cdf"
+dependencies = [
+ "instant",
+]
+
 [[package]]
 name = "flate2"
 version = "1.0.22"
@@ -253,6 +263,12 @@ dependencies = [
  "miniz_oxide",
 ]
 
+[[package]]
+name = "fnv"
+version = "1.0.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
+
 [[package]]
 name = "form_urlencoded"
 version = "1.0.1"
@@ -357,6 +373,15 @@ dependencies = [
  "serde",
 ]
 
+[[package]]
+name = "instant"
+version = "0.1.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c"
+dependencies = [
+ "cfg-if",
+]
+
 [[package]]
 name = "itoa"
 version = "1.0.1"
@@ -618,6 +643,12 @@ dependencies = [
  "libc",
 ]
 
+[[package]]
+name = "quick-error"
+version = "1.2.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0"
+
 [[package]]
 name = "quick-xml"
 version = "0.22.0"
@@ -636,6 +667,15 @@ dependencies = [
  "proc-macro2",
 ]
 
+[[package]]
+name = "redox_syscall"
+version = "0.2.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff"
+dependencies = [
+ "bitflags",
+]
+
 [[package]]
 name = "regex"
 version = "1.5.4"
@@ -662,6 +702,15 @@ version = "0.6.25"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b"
 
+[[package]]
+name = "remove_dir_all"
+version = "0.5.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7"
+dependencies = [
+ "winapi",
+]
+
 [[package]]
 name = "rustc-demangle"
 version = "0.1.21"
@@ -677,6 +726,18 @@ dependencies = [
  "semver",
 ]
 
+[[package]]
+name = "rusty-fork"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cb3dcc6e454c328bb824492db107ab7c0ae8fcffe4ad210136ef014458c1bc4f"
+dependencies = [
+ "fnv",
+ "quick-error",
+ "tempfile",
+ "wait-timeout",
+]
+
 [[package]]
 name = "ryu"
 version = "1.0.9"
@@ -790,6 +851,20 @@ dependencies = [
  "unicode-xid",
 ]
 
+[[package]]
+name = "tempfile"
+version = "3.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4"
+dependencies = [
+ "cfg-if",
+ "fastrand",
+ "libc",
+ "redox_syscall",
+ "remove_dir_all",
+ "winapi",
+]
+
 [[package]]
 name = "textwrap"
 version = "0.11.0"
@@ -951,6 +1026,15 @@ version = "0.8.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
 
+[[package]]
+name = "wait-timeout"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9f200f5b12eb75f8c1ed65abd4b2db8a6e1b138a20de009dacee265a2498f3f6"
+dependencies = [
+ "libc",
+]
+
 [[package]]
 name = "walkdir"
 version = "2.3.2"
diff --git a/Cargo.toml b/Cargo.toml
index 409a922..6a36796 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -59,6 +59,9 @@ vendored-openssl = ["git2/vendored-openssl"]
 [build-dependencies]
 rustc_version = "0.4"
 
+[dev-dependencies]
+rusty-fork = "0.3.0"
+
 [package.metadata.binstall]
 pkg-url = "{ repo }/releases/download/{ version }/cargo-tarpaulin-{ version }-travis.tar.gz"
 bin-dir = "cargo-tarpaulin"
diff --git a/src/branching/mod.rs b/src/branching/mod.rs
index 50db1c8..233afc9 100644
--- a/src/branching/mod.rs
+++ b/src/branching/mod.rs
@@ -78,7 +78,6 @@ impl From<&ExprIf> for Branches {
             if let Expr::If(ref i) = *el {
                 then = LineRange::from(&i.then_branch);
                 then.end -= 1;
-                ranges.push(then);
                 else_block = i.else_branch.as_ref().map(|x| x.1.clone());
                 implicit_default = else_block.is_none();
                 if let Some(s) = &else_block {
@@ -87,6 +86,8 @@ impl From<&ExprIf> for Branches {
                         lr.end = lr2.start - 1;
                     }
                     ranges.push(lr);
+                } else {
+                    ranges.push(then);
                 }
             } else {
                 else_block = None;
@@ -200,7 +201,9 @@ mod tests {
         let source = "fn foo(x: i32) {
             if x > 0 {
                 println!(\"BOO\");
-            } else {
+            } 
+            else 
+            {
                 todo!()
             }
         }";
@@ -221,7 +224,42 @@ mod tests {
         assert!(!branches.implicit_default);
         assert_eq!(branches.ranges.len(), 2);
         assert_eq!(branches.ranges[0], LineRange::new(2, 4));
+        assert_eq!(branches.ranges[1], LineRange::new(6, 9));
+    }
+
+    #[test]
+    fn if_elif_else() {
+        let source = "fn foo(x: i32) {
+            if x > 0 {
+                println!(\"BOO\");
+            } else if x < 0 {
+                todo!()
+            } 
+            else 
+            {   
+                todo!()
+            }
+        }";
+        let parser = parse_file(source).unwrap();
+        let func = &parser.items[0];
+        let mut branches = None;
+        if let Item::Fn(func) = func {
+            for stmt in &func.block.stmts {
+                match stmt {
+                    Stmt::Semi(Expr::If(i), _) | Stmt::Expr(Expr::If(i)) => {
+                        branches = Some(Branches::from(i));
+                    }
+                    _ => {}
+                }
+            }
+        }
+        let branches = branches.unwrap();
+        println!("Branches: {:?}", branches);
+        assert!(!branches.implicit_default);
+        assert_eq!(branches.ranges.len(), 3);
+        assert_eq!(branches.ranges[0], LineRange::new(2, 4));
         assert_eq!(branches.ranges[1], LineRange::new(4, 7));
+        assert_eq!(branches.ranges[2], LineRange::new(8, 11));
     }
 
     #[test]
@@ -310,4 +348,56 @@ mod tests {
         assert_eq!(branches.ranges.len(), 1);
         assert_eq!(branches.ranges[0], LineRange::new(4, 6));
     }
+
+    #[test]
+    fn branch_analysis_context() {
+        let mut analysis = BranchAnalysis::new();
+        let source = "fn foo(x: i32) {
+            if x > 0 {
+                println!(\"BOO\");
+            } else if x < 0 {
+                todo!()
+            }
+            println!(\"hello\");
+            match x {
+                0..5 => println!(\"less than 6\"),
+                _ => println!(\"greater than 5\"),
+            }
+            for i in 0..5 {
+                let _x = i*2;
+            }
+            while false {
+                unreachable!();
+            }
+        }";
+        let parser = parse_file(source).unwrap();
+        let func = &parser.items[0];
+        if let Item::Fn(func) = func {
+            for stmt in &func.block.stmts {
+                match stmt {
+                    Stmt::Semi(e, _) | Stmt::Expr(e) => {
+                        analysis.register_expr(e);
+                    }
+                    _ => {}
+                }
+            }
+        }
+
+        assert!(!analysis.is_branch(0));
+        assert!(analysis.is_branch(2));
+        assert!(analysis.is_branch(3));
+        assert!(analysis.is_branch(4));
+        assert!(!analysis.is_branch(7));
+        assert!(analysis.is_branch(9));
+        assert!(analysis.is_branch(10));
+        assert!(analysis.is_branch(13));
+        assert!(analysis.is_branch(16));
+
+        // Quick sanity check
+        let mut context = BranchContext::default();
+        context.files.insert(PathBuf::from("foo.rs"), analysis);
+        assert!(!context.is_branch("foo.rs", 1));
+        assert!(context.is_branch("foo.rs", 2));
+        assert!(!context.is_branch("bar.rs", 2));
+    }
 }
diff --git a/src/cargo.rs b/src/cargo.rs
index e5c30d6..35eb662 100644
--- a/src/cargo.rs
+++ b/src/cargo.rs
@@ -48,7 +48,10 @@ pub struct TestBinary {
     pkg_version: Option<String>,
     pkg_authors: Option<Vec<String>>,
     should_panic: bool,
-    linker_paths: Vec<PathBuf>,
+    /// Linker paths used when linking the binary, this should be accessed via
+    /// `Self::has_linker_paths` and `Self::ld_library_path` as there may be interaction with
+    /// current environment. It's only made pub(crate) for the purpose of testing.
+    pub(crate) linker_paths: Vec<PathBuf>,
 }
 
 #[derive(Clone, Debug)]
diff --git a/src/process_handling/mod.rs b/src/process_handling/mod.rs
index d0390e4..3e5ae54 100644
--- a/src/process_handling/mod.rs
+++ b/src/process_handling/mod.rs
@@ -160,6 +160,38 @@ pub(crate) fn collect_coverage(
     Ok((traces, ret_code))
 }
 
+fn get_env_vars(test: &TestBinary, config: &Config) -> Vec<(String, String)> {
+    let mut envars: Vec<(String, String)> = Vec::new();
+
+    for (key, value) in env::vars() {
+        // Avoid adding it twice
+        if key == "LD_LIBRARY_PATH" && test.has_linker_paths() {
+            continue;
+        }
+        envars.push((key.to_string(), value.to_string()));
+    }
+    if config.verbose {
+        envars.push(("RUST_BACKTRACE".to_string(), "1".to_string()));
+    }
+    if let Some(s) = test.pkg_name() {
+        envars.push(("CARGO_PKG_NAME".to_string(), s.to_string()));
+    }
+    if let Some(s) = test.pkg_version() {
+        envars.push(("CARGO_PKG_VERSION".to_string(), s.to_string()));
+    }
+    if let Some(s) = test.pkg_authors() {
+        envars.push(("CARGO_PKG_AUTHORS".to_string(), s.join(":")));
+    }
+    if let Some(s) = test.manifest_dir() {
+        envars.push(("CARGO_MANIFEST_DIR".to_string(), s.display().to_string()));
+    }
+    if test.has_linker_paths() {
+        envars.push(("LD_LIBRARY_PATH".to_string(), test.ld_library_path()));
+    }
+
+    envars
+}
+
 /// Launches the test executable
 fn execute_test(
     test: &TestBinary,
@@ -175,18 +207,12 @@ fn execute_test(
 
     debug!("Current working dir: {:?}", env::current_dir());
 
-    let mut envars: Vec<(String, String)> = Vec::new();
+    let mut envars = get_env_vars(test, config);
 
-    for (key, value) in env::vars() {
-        envars.push((key.to_string(), value.to_string()));
-    }
     let mut argv = vec![];
     if ignored {
         argv.push("--ignored".to_string());
     }
-    if config.verbose {
-        envars.push(("RUST_BACKTRACE".to_string(), "1".to_string()));
-    }
     argv.extend_from_slice(&config.varargs);
     if config.color != Color::Auto {
         argv.push("--color".to_string());
@@ -209,21 +235,6 @@ fn execute_test(
         }
     }
 
-    if let Some(s) = test.pkg_name() {
-        envars.push(("CARGO_PKG_NAME".to_string(), s.to_string()));
-    }
-    if let Some(s) = test.pkg_version() {
-        envars.push(("CARGO_PKG_VERSION".to_string(), s.to_string()));
-    }
-    if let Some(s) = test.pkg_authors() {
-        envars.push(("CARGO_PKG_AUTHORS".to_string(), s.join(":")));
-    }
-    if let Some(s) = test.manifest_dir() {
-        envars.push(("CARGO_MANIFEST_DIR".to_string(), s.display().to_string()));
-    }
-    if test.has_linker_paths() {
-        envars.push(("LD_LIBRARY_PATH".to_string(), test.ld_library_path()));
-    }
     match config.engine() {
         TraceEngine::Llvm => {
             // Used for llvm coverage to avoid report naming clashes TODO could have clashes
@@ -253,3 +264,40 @@ fn execute_test(
         ))),
     }
 }
+
+#[cfg(test)]
+mod tests {
+    use super::*;
+    use std::path::PathBuf;
+
+    #[test]
+    fn check_ld_library_path_correct() {
+        let mut binary = TestBinary::new(PathBuf::from("dummy"), None);
+        let default_config = Config::default();
+
+        let vars = get_env_vars(&binary, &default_config);
+
+        if let Some(ld) = vars
+            .iter()
+            .find(|(key, _)| key == "LD_LIBRARY_PATH")
+            .map(|(_, val)| val)
+        {
+            let sys = env::var("LD_LIBRARY_PATH").unwrap();
+            assert_eq!(ld, &sys);
+        }
+
+        binary
+            .linker_paths
+            .push(PathBuf::from("/usr/local/lib/foo"));
+
+        let vars = get_env_vars(&binary, &default_config);
+        let res = vars
+            .iter()
+            .find(|(key, _)| key == "LD_LIBRARY_PATH")
+            .map(|(_, val)| val);
+
+        assert!(res.is_some());
+        let res = res.unwrap();
+        assert!(res.contains("/usr/local/lib/foo"));
+    }
+}


Test patch:
diff --git a/src/source_analysis/tests.rs b/src/source_analysis/tests.rs
index 8288203..f767651 100644
--- a/src/source_analysis/tests.rs
+++ b/src/source_analysis/tests.rs
@@ -1394,3 +1394,49 @@ fn single_line_callables() {
     assert!(!lines.ignore.contains(&Lines::Line(13)));
     assert!(!lines.ignore.contains(&Lines::Line(14)));
 }
+
+#[test]
+fn visit_generics() {
+    let config = Config::default();
+    let ctx = Context {
+        config: &config,
+        file_contents: "fn blah<T>(t: T)  
+        where
+            T: Clone,
+            T: Eq
+        {
+            println!(\"{:?}\", t.clone());
+        }
+        
+        pub trait Foo<T> // 9
+        where
+            T: Clone
+        {
+            fn cloney(&self) -> Self {
+                self.clone()
+            }
+        }
+
+        impl<T> Foo<T> for T // 18
+        where
+            T: Clone
+        {}
+        ",
+        file: Path::new(""),
+        ignore_mods: RefCell::new(HashSet::new()),
+    };
+    let parser = parse_file(ctx.file_contents).unwrap();
+    let mut analysis = SourceAnalysis::new();
+    analysis.process_items(&parser.items, &ctx);
+    let lines = analysis.get_line_analysis(ctx.file.to_path_buf());
+    assert!(lines.ignore.contains(&Lines::Line(2)));
+    assert!(lines.ignore.contains(&Lines::Line(3)));
+    assert!(lines.ignore.contains(&Lines::Line(4)));
+    assert!(lines.ignore.contains(&Lines::Line(3)));
+
+    assert!(lines.ignore.contains(&Lines::Line(10)));
+    assert!(lines.ignore.contains(&Lines::Line(11)));
+
+    assert!(lines.ignore.contains(&Lines::Line(19)));
+    assert!(lines.ignore.contains(&Lines::Line(20)));
+}
diff --git a/tests/data/torch_test/Cargo.lock b/tests/data/torch_test/Cargo.lock
new file mode 100644
index 0000000..8b0265b
--- /dev/null
+++ b/tests/data/torch_test/Cargo.lock
@@ -0,0 +1,458 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 3
+
+[[package]]
+name = "adler"
+version = "1.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
+
+[[package]]
+name = "anyhow"
+version = "1.0.53"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "94a45b455c14666b85fc40a019e8ab9eb75e3a124e05494f5397122bc9eb06e0"
+
+[[package]]
+name = "autocfg"
+version = "1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
+
+[[package]]
+name = "byteorder"
+version = "1.4.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
+
+[[package]]
+name = "bzip2"
+version = "0.4.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6afcd980b5f3a45017c57e57a2fcccbb351cc43a356ce117ef760ef8052b89b0"
+dependencies = [
+ "bzip2-sys",
+ "libc",
+]
+
+[[package]]
+name = "bzip2-sys"
+version = "0.1.11+1.0.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "736a955f3fa7875102d57c82b8cac37ec45224a07fd32d58f9f7a186b6cd4cdc"
+dependencies = [
+ "cc",
+ "libc",
+ "pkg-config",
+]
+
+[[package]]
+name = "cc"
+version = "1.0.72"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "22a9137b95ea06864e018375b72adfb7db6e6f68cfc8df5a04d00288050485ee"
+
+[[package]]
+name = "cfg-if"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
+
+[[package]]
+name = "crc32fast"
+version = "1.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d"
+dependencies = [
+ "cfg-if",
+]
+
+[[package]]
+name = "curl"
+version = "0.4.42"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7de97b894edd5b5bcceef8b78d7da9b75b1d2f2f9a910569d0bde3dd31d84939"
+dependencies = [
+ "curl-sys",
+ "libc",
+ "openssl-probe",
+ "openssl-sys",
+ "schannel",
+ "socket2",
+ "winapi",
+]
+
+[[package]]
+name = "curl-sys"
+version = "0.4.52+curl-7.81.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "14b8c2d1023ea5fded5b7b892e4b8e95f70038a421126a056761a84246a28971"
+dependencies = [
+ "cc",
+ "libc",
+ "libz-sys",
+ "openssl-sys",
+ "pkg-config",
+ "vcpkg",
+ "winapi",
+]
+
+[[package]]
+name = "flate2"
+version = "1.0.22"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1e6988e897c1c9c485f43b47a529cef42fde0547f9d8d41a7062518f1d8fc53f"
+dependencies = [
+ "cfg-if",
+ "crc32fast",
+ "libc",
+ "miniz_oxide",
+]
+
+[[package]]
+name = "getrandom"
+version = "0.2.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "418d37c8b1d42553c93648be529cb70f920d3baf8ef469b74b9638df426e0b4c"
+dependencies = [
+ "cfg-if",
+ "libc",
+ "wasi",
+]
+
+[[package]]
+name = "half"
+version = "1.8.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7"
+
+[[package]]
+name = "lazy_static"
+version = "1.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
+
+[[package]]
+name = "libc"
+version = "0.2.117"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e74d72e0f9b65b5b4ca49a346af3976df0f9c61d550727f349ecd559f251a26c"
+
+[[package]]
+name = "libz-sys"
+version = "1.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "de5435b8549c16d423ed0c03dbaafe57cf6c3344744f1242520d59c9d8ecec66"
+dependencies = [
+ "cc",
+ "libc",
+ "pkg-config",
+ "vcpkg",
+]
+
+[[package]]
+name = "matrixmultiply"
+version = "0.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "add85d4dd35074e6fedc608f8c8f513a3548619a9024b751949ef0e8e45a4d84"
+dependencies = [
+ "rawpointer",
+]
+
+[[package]]
+name = "miniz_oxide"
+version = "0.4.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b"
+dependencies = [
+ "adler",
+ "autocfg",
+]
+
+[[package]]
+name = "ndarray"
+version = "0.15.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dec23e6762830658d2b3d385a75aa212af2f67a4586d4442907144f3bb6a1ca8"
+dependencies = [
+ "matrixmultiply",
+ "num-complex",
+ "num-integer",
+ "num-traits",
+ "rawpointer",
+]
+
+[[package]]
+name = "num-complex"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "26873667bbbb7c5182d4a37c1add32cdf09f841af72da53318fdb81543c15085"
+dependencies = [
+ "num-traits",
+]
+
+[[package]]
+name = "num-integer"
+version = "0.1.44"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db"
+dependencies = [
+ "autocfg",
+ "num-traits",
+]
+
+[[package]]
+name = "num-traits"
+version = "0.2.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290"
+dependencies = [
+ "autocfg",
+]
+
+[[package]]
+name = "openssl-probe"
+version = "0.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
+
+[[package]]
+name = "openssl-sys"
+version = "0.9.72"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7e46109c383602735fa0a2e48dd2b7c892b048e1bf69e5c3b1d804b7d9c203cb"
+dependencies = [
+ "autocfg",
+ "cc",
+ "libc",
+ "pkg-config",
+ "vcpkg",
+]
+
+[[package]]
+name = "pkg-config"
+version = "0.3.24"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "58893f751c9b0412871a09abd62ecd2a00298c6c83befa223ef98c52aef40cbe"
+
+[[package]]
+name = "ppv-lite86"
+version = "0.2.16"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872"
+
+[[package]]
+name = "proc-macro2"
+version = "1.0.36"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029"
+dependencies = [
+ "unicode-xid",
+]
+
+[[package]]
+name = "quote"
+version = "1.0.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "864d3e96a899863136fc6e99f3d7cae289dafe43bf2c5ac19b70df7210c0a145"
+dependencies = [
+ "proc-macro2",
+]
+
+[[package]]
+name = "rand"
+version = "0.8.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2e7573632e6454cf6b99d7aac4ccca54be06da05aca2ef7423d22d27d4d4bcd8"
+dependencies = [
+ "libc",
+ "rand_chacha",
+ "rand_core",
+ "rand_hc",
+]
+
+[[package]]
+name = "rand_chacha"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
+dependencies = [
+ "ppv-lite86",
+ "rand_core",
+]
+
+[[package]]
+name = "rand_core"
+version = "0.6.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7"
+dependencies = [
+ "getrandom",
+]
+
+[[package]]
+name = "rand_hc"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d51e9f596de227fda2ea6c84607f5558e196eeaf43c986b724ba4fb8fdf497e7"
+dependencies = [
+ "rand_core",
+]
+
+[[package]]
+name = "rawpointer"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3"
+
+[[package]]
+name = "schannel"
+version = "0.1.19"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8f05ba609c234e60bee0d547fe94a4c7e9da733d1c962cf6e59efa4cd9c8bc75"
+dependencies = [
+ "lazy_static",
+ "winapi",
+]
+
+[[package]]
+name = "socket2"
+version = "0.4.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "66d72b759436ae32898a2af0a14218dbf55efde3feeb170eb623637db85ee1e0"
+dependencies = [
+ "libc",
+ "winapi",
+]
+
+[[package]]
+name = "syn"
+version = "1.0.86"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8a65b3f4ffa0092e9887669db0eae07941f023991ab58ea44da8fe8e2d511c6b"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "unicode-xid",
+]
+
+[[package]]
+name = "tch"
+version = "0.6.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2b73f876b186599e22b01fa6ebfeea2dee2f11e8083463ab3572933d8201436b"
+dependencies = [
+ "half",
+ "lazy_static",
+ "libc",
+ "ndarray",
+ "rand",
+ "thiserror",
+ "torch-sys",
+ "zip",
+]
+
+[[package]]
+name = "thiserror"
+version = "1.0.30"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "854babe52e4df1653706b98fcfc05843010039b406875930a70e4d9644e5c417"
+dependencies = [
+ "thiserror-impl",
+]
+
+[[package]]
+name = "thiserror-impl"
+version = "1.0.30"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "time"
+version = "0.1.43"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438"
+dependencies = [
+ "libc",
+ "winapi",
+]
+
+[[package]]
+name = "torch-sys"
+version = "0.6.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "34cc0f21b1aad5d71d529e9fe4dbbbdbf53918d7b4bde946f523839aa32cffae"
+dependencies = [
+ "anyhow",
+ "cc",
+ "curl",
+ "libc",
+ "zip",
+]
+
+[[package]]
+name = "torch_test"
+version = "0.1.0"
+dependencies = [
+ "tch",
+]
+
+[[package]]
+name = "unicode-xid"
+version = "0.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"
+
+[[package]]
+name = "vcpkg"
+version = "0.2.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
+
+[[package]]
+name = "wasi"
+version = "0.10.2+wasi-snapshot-preview1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
+
+[[package]]
+name = "winapi"
+version = "0.3.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
+dependencies = [
+ "winapi-i686-pc-windows-gnu",
+ "winapi-x86_64-pc-windows-gnu",
+]
+
+[[package]]
+name = "winapi-i686-pc-windows-gnu"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
+
+[[package]]
+name = "winapi-x86_64-pc-windows-gnu"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
+
+[[package]]
+name = "zip"
+version = "0.5.13"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "93ab48844d61251bb3835145c521d88aa4031d7139e8485990f60ca911fa0815"
+dependencies = [
+ "byteorder",
+ "bzip2",
+ "crc32fast",
+ "flate2",
+ "thiserror",
+ "time",
+]
diff --git a/tests/doc_coverage.rs b/tests/doc_coverage.rs
index 4c468e6..b5a1aa8 100644
--- a/tests/doc_coverage.rs
+++ b/tests/doc_coverage.rs
@@ -1,9 +1,11 @@
 use crate::utils::get_test_path;
 use cargo_tarpaulin::config::{Config, RunType};
 use cargo_tarpaulin::launch_tarpaulin;
+use rusty_fork::rusty_fork_test;
 use std::env;
 use std::time::Duration;
 
+rusty_fork_test! {
 #[test]
 fn doc_test_env() {
     let mut config = Config::default();
@@ -136,3 +138,4 @@ fn doc_test_no_run() {
     let (_, ret) = launch_tarpaulin(&config, &None).unwrap();
     assert_eq!(ret, 0);
 }
+}
diff --git a/tests/failure_thresholds.rs b/tests/failure_thresholds.rs
index e94e3db..cfbbf80 100644
--- a/tests/failure_thresholds.rs
+++ b/tests/failure_thresholds.rs
@@ -1,8 +1,11 @@
 use crate::utils::get_test_path;
 use cargo_tarpaulin::run;
 use cargo_tarpaulin::{config::Config, errors::RunError};
+use rusty_fork::rusty_fork_test;
 use std::env;
 
+rusty_fork_test! {
+
 #[test]
 fn coverage_below_threshold() {
     let mut config = Config::default();
@@ -65,3 +68,5 @@ fn report_coverage_fail() {
         panic!("Wrong error type {}", result.unwrap_err());
     }
 }
+
+}
diff --git a/tests/failures.rs b/tests/failures.rs
index 0812a4c..ea27cc2 100644
--- a/tests/failures.rs
+++ b/tests/failures.rs
@@ -4,8 +4,11 @@ use cargo_tarpaulin::{
     errors::RunError,
 };
 use cargo_tarpaulin::{launch_tarpaulin, run};
+use rusty_fork::rusty_fork_test;
 use std::env;
 
+rusty_fork_test! {
+
 #[test]
 fn error_if_build_script_fails() {
     let mut config = Config::default();
@@ -81,3 +84,5 @@ fn issue_610() {
     let result = run(&[config]);
     assert!(result.is_err());
 }
+
+}
diff --git a/tests/line_coverage.rs b/tests/line_coverage.rs
index 6e129a4..62fa5fe 100644
--- a/tests/line_coverage.rs
+++ b/tests/line_coverage.rs
@@ -2,9 +2,12 @@ use crate::utils::get_test_path;
 use cargo_tarpaulin::config::Config;
 use cargo_tarpaulin::launch_tarpaulin;
 use cargo_tarpaulin::traces::CoverageStat;
+use rusty_fork::rusty_fork_test;
 use std::env;
 use std::time::Duration;
 
+rusty_fork_test! {
+
 #[test]
 fn simple_project_coverage() {
     let mut config = Config::default();
@@ -94,3 +97,5 @@ fn test_threads_1() {
         }
     }
 }
+
+}
diff --git a/tests/mod.rs b/tests/mod.rs
index ec2fe30..240f4e3 100644
--- a/tests/mod.rs
+++ b/tests/mod.rs
@@ -4,9 +4,10 @@ use cargo_tarpaulin::launch_tarpaulin;
 use cargo_tarpaulin::path_utils::*;
 use cargo_tarpaulin::traces::TraceMap;
 use clap::App;
+use rusty_fork::rusty_fork_test;
 use std::env;
+use std::fs;
 use std::path::Path;
-use std::process::Command;
 use std::time::Duration;
 
 #[cfg(nightly)]
@@ -91,6 +92,8 @@ pub fn check_percentage(project_name: &str, minimum_coverage: f64, has_lines: bo
     check_percentage_with_config(project_name, minimum_coverage, has_lines, config);
 }
 
+rusty_fork_test! {
+
 #[test]
 fn incorrect_manifest_path() {
     let mut config = Config::default();
@@ -291,10 +294,11 @@ fn cargo_home_filtering() {
 
     env::set_var("CARGO_HOME", new_home.display().to_string());
     let run = launch_tarpaulin(&config, &None);
+    let _ = fs::remove_dir_all(&new_home);
     match previous {
         Ok(s) => env::set_var("CARGO_HOME", s),
         Err(_) => {
-            let _ = Command::new("unset").args(&["CARGO_HOME"]).output();
+            let _ = env::remove_var("CARGO_HOME");
         }
     }
     let (res, _) = run.unwrap();
@@ -379,3 +383,5 @@ fn dot_rs_in_dir_name() {
         assert!(dir.path().is_file());
     }
 }
+
+}
diff --git a/tests/test_types.rs b/tests/test_types.rs
index 4559061..44b1ceb 100644
--- a/tests/test_types.rs
+++ b/tests/test_types.rs
@@ -1,9 +1,12 @@
 use crate::utils::get_test_path;
 use cargo_tarpaulin::config::{types::RunType, Config};
 use cargo_tarpaulin::launch_tarpaulin;
+use rusty_fork::rusty_fork_test;
 use std::env;
 use std::time::Duration;
 
+rusty_fork_test! {
+
 #[test]
 fn mix_test_types() {
     // Issue 747 the clean would delete old tests leaving to only one run type effectively being
@@ -137,3 +140,5 @@ fn only_doctest_coverage() {
         }
     }
 }
+
+}
diff --git a/tests/workspaces.rs b/tests/workspaces.rs
index 307e5ac..5ce2fc1 100644
--- a/tests/workspaces.rs
+++ b/tests/workspaces.rs
@@ -1,9 +1,12 @@
 use crate::utils::get_test_path;
 use cargo_tarpaulin::config::Config;
 use cargo_tarpaulin::launch_tarpaulin;
+use rusty_fork::rusty_fork_test;
 use std::env;
 use std::path::PathBuf;
 
+rusty_fork_test! {
+
 #[test]
 fn package_exclude() {
     let mut config = Config::default();
@@ -85,3 +88,5 @@ fn config_relative_pathing() {
     assert_eq!(configs[1].manifest, base_path.join("bin/Cargo.toml"));
     assert_eq!(configs[1].target_dir(), base_path.join("targ"));
 }
+
+}