File tree Expand file tree Collapse file tree
tests/specs/test/only_failed Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1710,17 +1710,20 @@ pub async fn report_tests(
17101710 ) ;
17111711 }
17121712
1713+ // A genuine test failure takes precedence over the `only` notice: if a test
1714+ // failed on its own, reporting that it failed "because the \"only\" option
1715+ // was used" is misleading.
1716+ if failed {
1717+ return ( Err ( anyhow ! ( "Test failed" ) ) , receiver) ;
1718+ }
1719+
17131720 if used_only {
17141721 return (
17151722 Err ( anyhow ! ( "Test failed because the \" only\" option was used" , ) ) ,
17161723 receiver,
17171724 ) ;
17181725 }
17191726
1720- if failed {
1721- return ( Err ( anyhow ! ( "Test failed" ) ) , receiver) ;
1722- }
1723-
17241727 ( Ok ( ( ) ) , receiver)
17251728}
17261729
Original file line number Diff line number Diff line change 1+ {
2+ "tests" : {
3+ "only_test_fails_on_its_own" : {
4+ "args" : " test --no-check main.ts" ,
5+ "exitCode" : 1 ,
6+ "output" : " main.out"
7+ },
8+ "only_test_passes" : {
9+ "args" : " test --no-check pass.ts" ,
10+ "exitCode" : 1 ,
11+ "output" : " pass.out"
12+ }
13+ }
14+ }
Original file line number Diff line number Diff line change 1+ running 1 test from ./main.ts
2+ fails on its own ... FAILED ([WILDCARD])
3+
4+ ERRORS
5+
6+ fails on its own => ./main.ts:3:11
7+ error: Error: boom
8+ throw new Error("boom");
9+ ^
10+ at [WILDCARD]main.ts:4:9
11+
12+ FAILURES
13+
14+ fails on its own => ./main.ts:3:11
15+
16+ FAILED | 0 passed | 1 failed ([WILDCARD])
17+
18+ error: Test failed
Original file line number Diff line number Diff line change 1+ // When a test marked with `only` fails on its own, the run should report the
2+ // actual failure rather than the misleading "only" notice.
3+ Deno . test . only ( "fails on its own" , ( ) => {
4+ throw new Error ( "boom" ) ;
5+ } ) ;
Original file line number Diff line number Diff line change 1+ running 1 test from ./pass.ts
2+ passes ... ok ([WILDCARD])
3+
4+ ok | 1 passed | 0 failed ([WILDCARD])
5+
6+ error: Test failed because the "only" option was used
Original file line number Diff line number Diff line change 1+ // A `only` test that passes should still report the "only" notice, since the
2+ // run only "failed" because the `only` filter was applied.
3+ Deno . test . only ( "passes" , ( ) => { } ) ;
You can’t perform that action at this time.
0 commit comments