diff options
author | Casper Beyer <caspervonb@pm.me> | 2021-01-30 03:45:22 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-29 14:45:22 -0500 |
commit | 9965fc8cc35afc0ff4b338b0d893742b84fe102d (patch) | |
tree | dc845b973016e7e5b44e014c49eabe6ce6a2f44b /cli/tests | |
parent | 013b8fe606ba146ad9f7d15a8a3a0e05defb0a12 (diff) |
fix(cli/coverage): display mapped instrumentation line counts (#9310)
Diffstat (limited to 'cli/tests')
-rw-r--r-- | cli/tests/integration_tests.rs | 6 | ||||
-rw-r--r-- | cli/tests/subdir/complex.ts | 35 | ||||
-rw-r--r-- | cli/tests/test_branch_coverage.out | 2 | ||||
-rw-r--r-- | cli/tests/test_comment_coverage.out | 2 | ||||
-rw-r--r-- | cli/tests/test_complex_coverage.out | 18 | ||||
-rw-r--r-- | cli/tests/test_complex_coverage.ts | 5 | ||||
-rw-r--r-- | cli/tests/test_coverage.out | 6 | ||||
-rw-r--r-- | cli/tests/test_run_combined_coverage.out | 10 | ||||
-rw-r--r-- | cli/tests/test_run_run_coverage.out | 8 | ||||
-rw-r--r-- | cli/tests/test_run_test_coverage.out | 8 |
10 files changed, 82 insertions, 18 deletions
diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs index eab49a3c4..7eae47859 100644 --- a/cli/tests/integration_tests.rs +++ b/cli/tests/integration_tests.rs @@ -3478,6 +3478,12 @@ itest!(deno_test_coverage { exit_code: 0, }); +itest!(deno_test_complex_coverage { + args: "test --coverage --unstable test_complex_coverage.ts", + output: "test_complex_coverage.out", + exit_code: 0, +}); + itest!(deno_test_comment_coverage { args: "test --coverage --unstable test_comment_coverage.ts", output: "test_comment_coverage.out", diff --git a/cli/tests/subdir/complex.ts b/cli/tests/subdir/complex.ts new file mode 100644 index 000000000..588e6ce59 --- /dev/null +++ b/cli/tests/subdir/complex.ts @@ -0,0 +1,35 @@ +// This entire interface should be completely ignored by the coverage tool. +export interface Complex { + // These are comments. + foo: string; + + // But this is a stub, so this isn't really documentation. + bar: string; + + // Really all these are doing is padding the line count. + baz: string; +} + +export function complex( + foo: string, + bar: string, + baz: string, +): Complex { + return { + foo, + bar, + baz, + }; +} + +export function unused( + foo: string, + bar: string, + baz: string, +): Complex { + return complex( + foo, + bar, + baz, + ); +} diff --git a/cli/tests/test_branch_coverage.out b/cli/tests/test_branch_coverage.out index e52c4bac0..375073e36 100644 --- a/cli/tests/test_branch_coverage.out +++ b/cli/tests/test_branch_coverage.out @@ -4,7 +4,7 @@ test branch ... ok ([WILDCARD]) test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out ([WILDCARD]) -cover [WILDCARD]/tests/subdir/branch.ts ... 66.667% (6/9) +cover [WILDCARD]/tests/subdir/branch.ts ... 57.143% (4/7) 4 | } else { 5 | return false; 6 | } diff --git a/cli/tests/test_comment_coverage.out b/cli/tests/test_comment_coverage.out index 582152fa1..ce846836c 100644 --- a/cli/tests/test_comment_coverage.out +++ b/cli/tests/test_comment_coverage.out @@ -4,4 +4,4 @@ test comment ... ok ([WILDCARD]) test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out ([WILDCARD]) -[WILDCARD]/tests/subdir/comment.ts ... 100.000% (4/4) +[WILDCARD]/tests/subdir/comment.ts ... 100.000% (3/3) diff --git a/cli/tests/test_complex_coverage.out b/cli/tests/test_complex_coverage.out new file mode 100644 index 000000000..1082d098c --- /dev/null +++ b/cli/tests/test_complex_coverage.out @@ -0,0 +1,18 @@ +Check [WILDCARD]/tests/$deno$test.ts +running 1 tests +test complex ... ok ([WILDCARD]) + +test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out ([WILDCARD]) + +cover [WILDCARD]/tests/subdir/complex.ts ... 50.000% (10/20) + 25 | export function unused( + 26 | foo: string, + 27 | bar: string, + 28 | baz: string, +-----|----- + 30 | return complex( + 31 | foo, + 32 | bar, + 33 | baz, + 34 | ); + 35 | } diff --git a/cli/tests/test_complex_coverage.ts b/cli/tests/test_complex_coverage.ts new file mode 100644 index 000000000..06f17d87d --- /dev/null +++ b/cli/tests/test_complex_coverage.ts @@ -0,0 +1,5 @@ +import { complex } from "./subdir/complex.ts"; + +Deno.test("complex", function () { + complex("foo", "bar", "baz"); +}); diff --git a/cli/tests/test_coverage.out b/cli/tests/test_coverage.out index 709d57d3b..83456bced 100644 --- a/cli/tests/test_coverage.out +++ b/cli/tests/test_coverage.out @@ -4,7 +4,7 @@ test returnsFooSuccess ... ok ([WILDCARD]) test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out ([WILDCARD]) -cover [WILDCARD]/tests/subdir/mod1.ts ... 35.714% (5/14) +cover [WILDCARD]/tests/subdir/mod1.ts ... 30.769% (4/13) 3 | export function returnsHi(): string { 4 | return "Hi"; 5 | } @@ -16,11 +16,11 @@ cover [WILDCARD]/tests/subdir/mod1.ts ... 35.714% (5/14) 15 | export function throwsError(): void { 16 | throw Error("exception from mod1"); 17 | } -cover [WILDCARD]/tests/subdir/print_hello.ts ... 25.000% (1/4) +cover [WILDCARD]/tests/subdir/print_hello.ts ... 0.000% (0/3) 1 | export function printHello(): void { 2 | console.log("Hello"); 3 | } -cover [WILDCARD]/tests/subdir/subdir2/mod2.ts ... 62.500% (5/8) +cover [WILDCARD]/tests/subdir/subdir2/mod2.ts ... 57.143% (4/7) 7 | export function printHello2(): void { 8 | printHello(); 9 | } diff --git a/cli/tests/test_run_combined_coverage.out b/cli/tests/test_run_combined_coverage.out index 24ceb9955..9a638214e 100644 --- a/cli/tests/test_run_combined_coverage.out +++ b/cli/tests/test_run_combined_coverage.out @@ -12,8 +12,8 @@ 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) +cover [WILDCARD]/tests/run_coverage.ts ... 100.000% (2/2) +cover [WILDCARD]/tests/subdir/mod1.ts ... 53.846% (7/13) 11 | export function printHello3(): void { 12 | printHello2(); 13 | } @@ -21,12 +21,12 @@ cover [WILDCARD]/tests/subdir/mod1.ts ... 57.143% (8/14) 15 | export function throwsError(): void { 16 | throw Error("exception from mod1"); 17 | } -cover [WILDCARD]/tests/subdir/print_hello.ts ... 25.000% (1/4) +cover [WILDCARD]/tests/subdir/print_hello.ts ... 0.000% (0/3) 1 | export function printHello(): void { 2 | console.log("Hello"); 3 | } -cover [WILDCARD]/tests/subdir/subdir2/mod2.ts ... 62.500% (5/8) +cover [WILDCARD]/tests/subdir/subdir2/mod2.ts ... 57.143% (4/7) 7 | export function printHello2(): void { 8 | printHello(); 9 | } -cover [WILDCARD]/tests/test_coverage.ts ... 100.000% (5/5) +cover [WILDCARD]/tests/test_coverage.ts ... 100.000% (4/4) diff --git a/cli/tests/test_run_run_coverage.out b/cli/tests/test_run_run_coverage.out index 97eb29264..81f86c9be 100644 --- a/cli/tests/test_run_run_coverage.out +++ b/cli/tests/test_run_run_coverage.out @@ -5,8 +5,8 @@ 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) +cover [WILDCARD]/tests/run_coverage.ts ... 100.000% (2/2) +cover [WILDCARD]/tests/subdir/mod1.ts ... 30.769% (4/13) 7 | export function returnsFoo2(): string { 8 | return returnsFoo(); 9 | } @@ -18,11 +18,11 @@ cover [WILDCARD]/tests/subdir/mod1.ts ... 35.714% (5/14) 15 | export function throwsError(): void { 16 | throw Error("exception from mod1"); 17 | } -cover [WILDCARD]/tests/subdir/print_hello.ts ... 25.000% (1/4) +cover [WILDCARD]/tests/subdir/print_hello.ts ... 0.000% (0/3) 1 | export function printHello(): void { 2 | console.log("Hello"); 3 | } -cover [WILDCARD]/tests/subdir/subdir2/mod2.ts ... 25.000% (2/8) +cover [WILDCARD]/tests/subdir/subdir2/mod2.ts ... 14.286% (1/7) 3 | export function returnsFoo(): string { 4 | return "Foo"; 5 | } diff --git a/cli/tests/test_run_test_coverage.out b/cli/tests/test_run_test_coverage.out index 186ecba13..aa524966e 100644 --- a/cli/tests/test_run_test_coverage.out +++ b/cli/tests/test_run_test_coverage.out @@ -10,7 +10,7 @@ ok ([WILDCARD]) test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out ([WILDCARD]) -cover [WILDCARD]/tests/subdir/mod1.ts ... 35.714% (5/14) +cover [WILDCARD]/tests/subdir/mod1.ts ... 30.769% (4/13) 3 | export function returnsHi(): string { 4 | return "Hi"; 5 | } @@ -22,12 +22,12 @@ cover [WILDCARD]/tests/subdir/mod1.ts ... 35.714% (5/14) 15 | export function throwsError(): void { 16 | throw Error("exception from mod1"); 17 | } -cover [WILDCARD]/tests/subdir/print_hello.ts ... 25.000% (1/4) +cover [WILDCARD]/tests/subdir/print_hello.ts ... 0.000% (0/3) 1 | export function printHello(): void { 2 | console.log("Hello"); 3 | } -cover [WILDCARD]/tests/subdir/subdir2/mod2.ts ... 62.500% (5/8) +cover [WILDCARD]/tests/subdir/subdir2/mod2.ts ... 57.143% (4/7) 7 | export function printHello2(): void { 8 | printHello(); 9 | } -cover [WILDCARD]/tests/test_coverage.ts ... 100.000% (5/5) +cover [WILDCARD]/tests/test_coverage.ts ... 100.000% (4/4) |