summaryrefslogtreecommitdiff
path: root/cli/tests/integration/coverage_tests.rs
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2021-12-23 20:02:54 -0500
committerGitHub <noreply@github.com>2021-12-23 20:02:54 -0500
commit7ebbda7fd71495b6f4e9bf87d385d19c44102c62 (patch)
treee3279b7456e47511f41c95a1972391f0607b6450 /cli/tests/integration/coverage_tests.rs
parent37dbe5249c9b5c447da5577b5c787d7006a4c80f (diff)
fix(coverage): use only string byte indexes and 0-indexed line numbers (#13190)
Diffstat (limited to 'cli/tests/integration/coverage_tests.rs')
-rw-r--r--cli/tests/integration/coverage_tests.rs95
1 files changed, 17 insertions, 78 deletions
diff --git a/cli/tests/integration/coverage_tests.rs b/cli/tests/integration/coverage_tests.rs
index 4580b5cec..2f7250817 100644
--- a/cli/tests/integration/coverage_tests.rs
+++ b/cli/tests/integration/coverage_tests.rs
@@ -6,90 +6,29 @@ use test_util as util;
#[test]
fn branch() {
- let tempdir = TempDir::new().expect("tempdir fail");
- let tempdir = tempdir.path().join("cov");
- let status = util::deno_cmd()
- .current_dir(util::testdata_path())
- .arg("test")
- .arg("--quiet")
- .arg("--unstable")
- .arg(format!("--coverage={}", tempdir.to_str().unwrap()))
- .arg("coverage/branch_test.ts")
- .stdout(std::process::Stdio::piped())
- .stderr(std::process::Stdio::inherit())
- .status()
- .expect("failed to spawn test runner");
-
- assert!(status.success());
-
- let output = util::deno_cmd()
- .current_dir(util::testdata_path())
- .arg("coverage")
- .arg("--quiet")
- .arg("--unstable")
- .arg(format!("{}/", tempdir.to_str().unwrap()))
- .stdout(std::process::Stdio::piped())
- .stderr(std::process::Stdio::inherit())
- .output()
- .expect("failed to spawn coverage reporter");
-
- 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/expected_branch.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()
- .current_dir(util::testdata_path())
- .arg("coverage")
- .arg("--quiet")
- .arg("--unstable")
- .arg("--lcov")
- .arg(format!("{}/", tempdir.to_str().unwrap()))
- .stdout(std::process::Stdio::piped())
- .stderr(std::process::Stdio::inherit())
- .output()
- .expect("failed to spawn coverage reporter");
-
- 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/expected_branch.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());
+ run_coverage_text("branch", "ts");
}
#[test]
fn complex() {
+ run_coverage_text("complex", "ts");
+}
+
+#[test]
+fn final_blankline() {
+ run_coverage_text("final_blankline", "js");
+}
+
+fn run_coverage_text(test_name: &str, extension: &str) {
let tempdir = TempDir::new().expect("tempdir fail");
+ let tempdir = tempdir.path().join("cov");
let status = util::deno_cmd()
.current_dir(util::testdata_path())
.arg("test")
.arg("--quiet")
.arg("--unstable")
- .arg(format!("--coverage={}", tempdir.path().to_str().unwrap()))
- .arg("coverage/complex_test.ts")
+ .arg(format!("--coverage={}", tempdir.to_str().unwrap()))
+ .arg(format!("coverage/{}_test.{}", test_name, extension))
.stdout(std::process::Stdio::piped())
.stderr(std::process::Stdio::inherit())
.status()
@@ -102,7 +41,7 @@ fn complex() {
.arg("coverage")
.arg("--quiet")
.arg("--unstable")
- .arg(format!("{}/", tempdir.path().to_str().unwrap()))
+ .arg(format!("{}/", tempdir.to_str().unwrap()))
.stdout(std::process::Stdio::piped())
.stderr(std::process::Stdio::inherit())
.output()
@@ -113,7 +52,7 @@ fn complex() {
.to_string();
let expected = fs::read_to_string(
- util::testdata_path().join("coverage/expected_complex.out"),
+ util::testdata_path().join(format!("coverage/{}_expected.out", test_name)),
)
.unwrap();
@@ -131,7 +70,7 @@ fn complex() {
.arg("--quiet")
.arg("--unstable")
.arg("--lcov")
- .arg(format!("{}/", tempdir.path().to_str().unwrap()))
+ .arg(format!("{}/", tempdir.to_str().unwrap()))
.stdout(std::process::Stdio::piped())
.stderr(std::process::Stdio::inherit())
.output()
@@ -142,7 +81,7 @@ fn complex() {
.to_string();
let expected = fs::read_to_string(
- util::testdata_path().join("coverage/expected_complex.lcov"),
+ util::testdata_path().join(format!("coverage/{}_expected.lcov", test_name)),
)
.unwrap();