summaryrefslogtreecommitdiff
path: root/cli/tests/integration/coverage_tests.rs
diff options
context:
space:
mode:
authorColin Ihrig <cjihrig@gmail.com>2022-05-22 10:45:22 -0400
committerGitHub <noreply@github.com>2022-05-22 10:45:22 -0400
commitd55444b41cdee5b3f281896a7e60ff06c5fc01de (patch)
tree4b211d199738310cfed1d6b4c59ccf7ca0d6dacb /cli/tests/integration/coverage_tests.rs
parent75315dfe006b9a5cf6fa92e361b62ca3925c631a (diff)
fix(coverage): do not report transpiled files with no lines (#14699)
This commit omits files from the coverage report that have no lines of code to report coverage for. Fixes: https://github.com/denoland/deno/issues/14683
Diffstat (limited to 'cli/tests/integration/coverage_tests.rs')
-rw-r--r--cli/tests/integration/coverage_tests.rs73
1 files changed, 73 insertions, 0 deletions
diff --git a/cli/tests/integration/coverage_tests.rs b/cli/tests/integration/coverage_tests.rs
index 6e6e2a681..59c1a5092 100644
--- a/cli/tests/integration/coverage_tests.rs
+++ b/cli/tests/integration/coverage_tests.rs
@@ -236,3 +236,76 @@ fn no_snaps_included(test_name: &str, extension: &str) {
assert!(output.status.success());
}
+
+#[test]
+fn no_transpiled_lines() {
+ let deno_dir = TempDir::new();
+ let tempdir = TempDir::new();
+ let tempdir = tempdir.path().join("cov");
+
+ let status = util::deno_cmd_with_deno_dir(&deno_dir)
+ .current_dir(util::testdata_path())
+ .arg("test")
+ .arg("--quiet")
+ .arg(format!("--coverage={}", tempdir.to_str().unwrap()))
+ .arg("coverage/no_transpiled_lines/")
+ .stdout(std::process::Stdio::piped())
+ .stderr(std::process::Stdio::inherit())
+ .status()
+ .unwrap();
+
+ assert!(status.success());
+
+ let output = util::deno_cmd_with_deno_dir(&deno_dir)
+ .current_dir(util::testdata_path())
+ .arg("coverage")
+ .arg(format!("{}/", tempdir.to_str().unwrap()))
+ .stdout(std::process::Stdio::piped())
+ .stderr(std::process::Stdio::piped())
+ .output()
+ .unwrap();
+
+ let actual =
+ util::strip_ansi_codes(std::str::from_utf8(&output.stdout).unwrap())
+ .to_string();
+
+ let expected = fs::read_to_string(
+ util::testdata_path().join("coverage/no_transpiled_lines/expected.out"),
+ )
+ .unwrap();
+
+ if !util::wildcard_match(&expected, &actual) {
+ println!("OUTPUT\n{}\nOUTPUT", actual);
+ println!("EXPECTED\n{}\nEXPECTED", expected);
+ panic!("pattern match failed");
+ }
+
+ assert!(output.status.success());
+
+ let output = util::deno_cmd_with_deno_dir(&deno_dir)
+ .current_dir(util::testdata_path())
+ .arg("coverage")
+ .arg("--lcov")
+ .arg(format!("{}/", tempdir.to_str().unwrap()))
+ .stdout(std::process::Stdio::piped())
+ .stderr(std::process::Stdio::inherit())
+ .output()
+ .unwrap();
+
+ let actual =
+ util::strip_ansi_codes(std::str::from_utf8(&output.stdout).unwrap())
+ .to_string();
+
+ let expected = fs::read_to_string(
+ util::testdata_path().join("coverage/no_transpiled_lines/expected.lcov"),
+ )
+ .unwrap();
+
+ if !util::wildcard_match(&expected, &actual) {
+ println!("OUTPUT\n{}\nOUTPUT", actual);
+ println!("EXPECTED\n{}\nEXPECTED", expected);
+ panic!("pattern match failed");
+ }
+
+ assert!(output.status.success());
+}