Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cli/coverage): display mapped instrumentation line counts #9310

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions cli/tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
35 changes: 35 additions & 0 deletions cli/tests/subdir/complex.ts
Original file line number Diff line number Diff line change
@@ -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,
);
}
2 changes: 1 addition & 1 deletion cli/tests/test_branch_coverage.out
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
caspervonb marked this conversation as resolved.
Show resolved Hide resolved
5 | return false;
6 | }
2 changes: 1 addition & 1 deletion cli/tests/test_comment_coverage.out
Original file line number Diff line number Diff line change
Expand Up @@ -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)
18 changes: 18 additions & 0 deletions cli/tests/test_complex_coverage.out
Original file line number Diff line number Diff line change
@@ -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 | }
5 changes: 5 additions & 0 deletions cli/tests/test_complex_coverage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { complex } from "./subdir/complex.ts";

Deno.test("complex", function () {
complex("foo", "bar", "baz");
});
6 changes: 3 additions & 3 deletions cli/tests/test_coverage.out
Original file line number Diff line number Diff line change
Expand Up @@ -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 | }
Expand All @@ -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 | }
10 changes: 5 additions & 5 deletions cli/tests/test_run_combined_coverage.out
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ 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 | }
-----|-----
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)
8 changes: 4 additions & 4 deletions cli/tests/test_run_run_coverage.out
Original file line number Diff line number Diff line change
Expand Up @@ -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 | }
Expand All @@ -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 | }
Expand Down
8 changes: 4 additions & 4 deletions cli/tests/test_run_test_coverage.out
Original file line number Diff line number Diff line change
Expand Up @@ -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 | }
Expand All @@ -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)
Loading