summaryrefslogtreecommitdiff
path: root/cli/tests
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tests')
-rw-r--r--cli/tests/integration/coverage_tests.rs95
-rw-r--r--cli/tests/testdata/coverage/branch_expected.lcov (renamed from cli/tests/testdata/coverage/expected_branch.lcov)10
-rw-r--r--cli/tests/testdata/coverage/branch_expected.out (renamed from cli/tests/testdata/coverage/expected_branch.out)3
-rw-r--r--cli/tests/testdata/coverage/complex_expected.lcov (renamed from cli/tests/testdata/coverage/expected_complex.lcov)12
-rw-r--r--cli/tests/testdata/coverage/complex_expected.out (renamed from cli/tests/testdata/coverage/expected_complex.out)0
-rw-r--r--cli/tests/testdata/coverage/final_blankline.js5
-rw-r--r--cli/tests/testdata/coverage/final_blankline_expected.lcov16
-rw-r--r--cli/tests/testdata/coverage/final_blankline_expected.out1
-rw-r--r--cli/tests/testdata/coverage/final_blankline_test.js5
9 files changed, 56 insertions, 91 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();
diff --git a/cli/tests/testdata/coverage/expected_branch.lcov b/cli/tests/testdata/coverage/branch_expected.lcov
index 07e29cca5..31da70224 100644
--- a/cli/tests/testdata/coverage/expected_branch.lcov
+++ b/cli/tests/testdata/coverage/branch_expected.lcov
@@ -1,6 +1,6 @@
SF:[WILDCARD]branch.ts
-FN:2,branch
-FN:10,unused
+FN:1,branch
+FN:9,unused
FNDA:1,branch
FNDA:0,unused
FNF:2
@@ -11,10 +11,10 @@ BRH:0
DA:1,1
DA:2,2
DA:3,2
-DA:4,0
+DA:4,2
DA:5,0
DA:6,0
-DA:7,1
+DA:7,2
DA:9,0
DA:10,0
DA:11,0
@@ -22,6 +22,6 @@ DA:12,0
DA:13,0
DA:14,0
DA:15,0
-LH:4
+LH:5
LF:14
end_of_record
diff --git a/cli/tests/testdata/coverage/expected_branch.out b/cli/tests/testdata/coverage/branch_expected.out
index 630ea93b2..2ff5e911e 100644
--- a/cli/tests/testdata/coverage/expected_branch.out
+++ b/cli/tests/testdata/coverage/branch_expected.out
@@ -1,5 +1,4 @@
-cover [WILDCARD]/coverage/branch.ts ... 28.571% (4/14)
- 4 | } else {
+cover [WILDCARD]/coverage/branch.ts ... 35.714% (5/14)
5 | return false;
6 | }
-----|-----
diff --git a/cli/tests/testdata/coverage/expected_complex.lcov b/cli/tests/testdata/coverage/complex_expected.lcov
index 962ebee96..a0af4cff3 100644
--- a/cli/tests/testdata/coverage/expected_complex.lcov
+++ b/cli/tests/testdata/coverage/complex_expected.lcov
@@ -1,8 +1,8 @@
SF:[WILDCARD]complex.ts
-FN:22,dependency
-FN:37,complex
-FN:51,unused
-FN:65,ƒ
+FN:17,dependency
+FN:32,complex
+FN:46,unused
+FN:64,ƒ
FNDA:1,dependency
FNDA:1,complex
FNDA:0,unused
@@ -20,7 +20,7 @@ DA:23,2
DA:24,2
DA:25,2
DA:26,2
-DA:27,1
+DA:27,2
DA:32,1
DA:33,1
DA:34,1
@@ -30,7 +30,7 @@ DA:38,2
DA:39,2
DA:40,2
DA:41,2
-DA:42,1
+DA:42,2
DA:46,0
DA:47,0
DA:48,0
diff --git a/cli/tests/testdata/coverage/expected_complex.out b/cli/tests/testdata/coverage/complex_expected.out
index e9f9a453f..e9f9a453f 100644
--- a/cli/tests/testdata/coverage/expected_complex.out
+++ b/cli/tests/testdata/coverage/complex_expected.out
diff --git a/cli/tests/testdata/coverage/final_blankline.js b/cli/tests/testdata/coverage/final_blankline.js
new file mode 100644
index 000000000..bb5ab0378
--- /dev/null
+++ b/cli/tests/testdata/coverage/final_blankline.js
@@ -0,0 +1,5 @@
+// deno-fmt-ignore-file - has blankline at end
+export default function example() {
+ return true;
+}
+
diff --git a/cli/tests/testdata/coverage/final_blankline_expected.lcov b/cli/tests/testdata/coverage/final_blankline_expected.lcov
new file mode 100644
index 000000000..48af66180
--- /dev/null
+++ b/cli/tests/testdata/coverage/final_blankline_expected.lcov
@@ -0,0 +1,16 @@
+SF:[WILDCARD]final_blankline.js
+FN:2,example
+FNDA:1,example
+FNF:1
+FNH:1
+BRF:0
+BRH:0
+DA:1,1
+DA:2,1
+DA:3,2
+DA:4,2
+DA:5,1
+DA:6,1
+LH:6
+LF:6
+end_of_record
diff --git a/cli/tests/testdata/coverage/final_blankline_expected.out b/cli/tests/testdata/coverage/final_blankline_expected.out
new file mode 100644
index 000000000..8dc5ce30d
--- /dev/null
+++ b/cli/tests/testdata/coverage/final_blankline_expected.out
@@ -0,0 +1 @@
+cover file:///[WILDCARD]final_blankline.js ... 100.000% (6/6)
diff --git a/cli/tests/testdata/coverage/final_blankline_test.js b/cli/tests/testdata/coverage/final_blankline_test.js
new file mode 100644
index 000000000..e7331c537
--- /dev/null
+++ b/cli/tests/testdata/coverage/final_blankline_test.js
@@ -0,0 +1,5 @@
+import example from "./final_blankline.js";
+
+Deno.test("Example.", () => {
+ example();
+});