summaryrefslogtreecommitdiff
path: root/cli/tests
diff options
context:
space:
mode:
authorCasper Beyer <caspervonb@pm.me>2021-01-05 00:01:21 +0800
committerGitHub <noreply@github.com>2021-01-04 17:01:21 +0100
commit4ca77ad84c46ba4afef95f0b6775377d350b7339 (patch)
tree0b1331508fb0774fccb88e7c527a2ffd48b43848 /cli/tests
parent3e5a3daf5983d9c6fd6b9cbf9a5b46abb9602346 (diff)
fix(coverage): merge duplicate reports (#8942)
Merging multiple runs isn't quite right because we rely on a 0 count to signal that a block hasn't been called. Other tools like c8 expect this to be true as-well so we need to do our best to merge coverage files rather than duplicating them.
Diffstat (limited to 'cli/tests')
-rw-r--r--cli/tests/integration_tests.rs6
-rw-r--r--cli/tests/run_coverage.ts4
-rw-r--r--cli/tests/test_run_combined_coverage.out31
-rw-r--r--cli/tests/test_run_run_coverage.out16
4 files changed, 48 insertions, 9 deletions
diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs
index 9dc4df7cb..199172e2c 100644
--- a/cli/tests/integration_tests.rs
+++ b/cli/tests/integration_tests.rs
@@ -3330,6 +3330,12 @@ itest!(deno_test_run_run_coverage {
exit_code: 0,
});
+itest!(deno_test_run_combined_coverage {
+ args: "test --allow-all --coverage --unstable test_run_run_coverage.ts test_run_test_coverage.ts",
+ output: "test_run_combined_coverage.out",
+ exit_code: 0,
+});
+
itest!(deno_lint {
args: "lint --unstable lint/file1.js lint/file2.ts lint/ignored_file.ts",
output: "lint/expected.out",
diff --git a/cli/tests/run_coverage.ts b/cli/tests/run_coverage.ts
index 098d463e8..d1443dfad 100644
--- a/cli/tests/run_coverage.ts
+++ b/cli/tests/run_coverage.ts
@@ -1,3 +1,3 @@
-import { returnsFoo2 } from "./subdir/mod1.ts";
+import { returnsHi } from "./subdir/mod1.ts";
-returnsFoo2();
+returnsHi();
diff --git a/cli/tests/test_run_combined_coverage.out b/cli/tests/test_run_combined_coverage.out
new file mode 100644
index 000000000..476e9adcc
--- /dev/null
+++ b/cli/tests/test_run_combined_coverage.out
@@ -0,0 +1,31 @@
+Check [WILDCARD]/tests/$deno$test.ts
+running 2 tests
+test spawn test ... Check [WILDCARD]/tests/run_coverage.ts
+ok ([WILDCARD])
+test spawn test ... Check [WILDCARD]/tests/$deno$test.ts
+running 1 tests
+test returnsFooSuccess ... ok ([WILDCARD])
+
+test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out ([WILDCARD])
+
+ok ([WILDCARD])
+
+test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out ([WILDCARD])
+
+cover [WILDCARD]/tests/run_coverage.ts ... 100.000% (3/3)
+cover [WILDCARD]/tests/subdir/mod1.ts ... 57.143% (8/14)
+ 8 | export function printHello3() {
+ 9 | printHello2();
+ 10 | }
+ 11 | export function throwsError() {
+ 12 | throw Error("exception from mod1");
+ 13 | }
+cover [WILDCARD]/tests/subdir/print_hello.ts ... 25.000% (1/4)
+ 1 | export function printHello() {
+ 2 | console.log("Hello");
+ 3 | }
+cover [WILDCARD]/tests/subdir/subdir2/mod2.ts ... 62.500% (5/8)
+ 5 | export function printHello2() {
+ 6 | printHello();
+ 7 | }
+cover [WILDCARD]/tests/test_coverage.ts ... 100.000% (5/5)
diff --git a/cli/tests/test_run_run_coverage.out b/cli/tests/test_run_run_coverage.out
index 15ea230ef..2f18020d3 100644
--- a/cli/tests/test_run_run_coverage.out
+++ b/cli/tests/test_run_run_coverage.out
@@ -1,16 +1,15 @@
-Check [WILDCARD]/$deno$test.ts
+Check [WILDCARD]/tests/$deno$test.ts
running 1 tests
-test spawn test ... Check [WILDCARD]/run_coverage.ts
+test spawn test ... Check [WILDCARD]/tests/run_coverage.ts
ok ([WILDCARD])
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out ([WILDCARD])
cover [WILDCARD]/tests/run_coverage.ts ... 100.000% (3/3)
cover [WILDCARD]/tests/subdir/mod1.ts ... 35.714% (5/14)
- 2 | export function returnsHi() {
- 3 | return "Hi";
- 4 | }
------|-----
+ 5 | export function returnsFoo2() {
+ 6 | return returnsFoo();
+ 7 | }
8 | export function printHello3() {
9 | printHello2();
10 | }
@@ -21,7 +20,10 @@ cover [WILDCARD]/tests/subdir/print_hello.ts ... 25.000% (1/4)
1 | export function printHello() {
2 | console.log("Hello");
3 | }
-cover [WILDCARD]/tests/subdir/subdir2/mod2.ts ... 62.500% (5/8)
+cover [WILDCARD]/tests/subdir/subdir2/mod2.ts ... 25.000% (2/8)
+ 2 | export function returnsFoo() {
+ 3 | return "Foo";
+ 4 | }
5 | export function printHello2() {
6 | printHello();
7 | }