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
Output logs for tests that remain pending when AVA exits #3125
Changes from 3 commits
ce2b12e
1937048
98bbc25
29ed720
82231fc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -370,8 +370,11 @@ export default class Reporter { | |||||
} | ||||||
|
||||||
this.lineWriter.writeLine(`${testsInFile.size} tests were pending in ${this.relativeFile(file)}\n`); | ||||||
const testTitleToLogs = evt.pendingTestsLogReference.get(file) ?? new Map(); | ||||||
for (const title of testsInFile) { | ||||||
const logs = testTitleToLogs.get(title) ?? []; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
this.lineWriter.writeLine(`${figures.circleDotted} ${this.prefixTitle(file, title)}`); | ||||||
this.writeLogs({logs}); | ||||||
} | ||||||
|
||||||
this.lineWriter.writeLine(''); | ||||||
|
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -9,6 +9,7 @@ export default class RunStatus extends Emittery { | |||||||||
super(); | ||||||||||
|
||||||||||
this.pendingTests = new Map(); | ||||||||||
this.pendingTestsLogReference = new Map(); | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. separate map from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oops, I think |
||||||||||
|
||||||||||
this.emptyParallelRun = parallelRuns | ||||||||||
&& parallelRuns.currentFileCount === 0 | ||||||||||
|
@@ -60,6 +61,7 @@ export default class RunStatus extends Emittery { | |||||||||
}); | ||||||||||
|
||||||||||
this.pendingTests.set(testFile, new Set()); | ||||||||||
this.pendingTestsLogReference.set(testFile, new Map()); | ||||||||||
worker.onStateChange(data => this.emitStateChange(data)); | ||||||||||
} | ||||||||||
|
||||||||||
|
@@ -124,22 +126,31 @@ export default class RunStatus extends Emittery { | |||||||||
fileStats.remainingTests--; | ||||||||||
this.removePendingTest(event); | ||||||||||
break; | ||||||||||
case 'test-register-log-reference': | ||||||||||
this.addLogReference(event); | ||||||||||
break; | ||||||||||
case 'timeout': | ||||||||||
stats.timeouts++; | ||||||||||
event.pendingTests = this.pendingTests; | ||||||||||
event.pendingTestsLogReference = this.pendingTestsLogReference; | ||||||||||
this.pendingTests = new Map(); | ||||||||||
this.pendingTestsLogReference = new Map(); | ||||||||||
for (const testsInFile of event.pendingTests.values()) { | ||||||||||
stats.timedOutTests += testsInFile.size; | ||||||||||
} | ||||||||||
|
||||||||||
break; | ||||||||||
case 'interrupt': | ||||||||||
event.pendingTests = this.pendingTests; | ||||||||||
event.pendingTestsLogReference = this.pendingTestsLogReference; | ||||||||||
this.pendingTests = new Map(); | ||||||||||
this.pendingTestsLogReference = new Map(); | ||||||||||
break; | ||||||||||
case 'process-exit': | ||||||||||
event.pendingTests = this.pendingTests; | ||||||||||
event.pendingTestsLogReference = this.pendingTestsLogReference; | ||||||||||
this.pendingTests = new Map(); | ||||||||||
this.pendingTestsLogReference = new Map(); | ||||||||||
break; | ||||||||||
case 'uncaught-exception': | ||||||||||
stats.uncaughtExceptions++; | ||||||||||
|
@@ -198,6 +209,12 @@ export default class RunStatus extends Emittery { | |||||||||
return 0; | ||||||||||
} | ||||||||||
|
||||||||||
addLogReference(event) { | ||||||||||
if (this.pendingTestsLogReference.has(event.testFile)) { | ||||||||||
this.pendingTestsLogReference.get(event.testFile).set(event.title, event.logs); | ||||||||||
} | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
} | ||||||||||
|
||||||||||
addPendingTest(event) { | ||||||||||
if (this.pendingTests.has(event.testFile)) { | ||||||||||
this.pendingTests.get(event.testFile).add(event.title); | ||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
const delay = require('delay'); | ||
|
||
const test = require('../../../../entrypoints/main.cjs'); | ||
|
||
test('a passes', t => t.pass()); | ||
|
||
test('a slow', async t => { | ||
t.log('this slow test prints useful debug message just text'); | ||
await delay(15_000); | ||
t.log('this never logs because test times out'); | ||
t.pass(); | ||
}); | ||
test('a slow two', async t => { | ||
t.log('another useful debug message', {x: 5}); | ||
await delay(15_000); | ||
t.log('this never logs because test times out'); | ||
t.pass(); | ||
}); | ||
|
||
test('a passes two', t => t.pass()); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const delay = require('delay'); | ||
|
||
const test = require('../../../../entrypoints/main.cjs'); | ||
|
||
test('a passes', t => t.pass()); | ||
|
||
test('a slow', async t => { | ||
t.log('hello world'); | ||
await delay(15_000); | ||
t.log('this never prints due to test time out'); | ||
t.pass(); | ||
}); | ||
test('a slow two', async t => { | ||
await delay(15_000); | ||
t.log('this never prints due to test time out'); | ||
t.pass(); | ||
}); | ||
|
||
test('a passes two', t => t.pass()); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
|
||
---tty-stream-chunk-separator | ||
[32m✔[39m a [90m[2m›[22m[39m a passes | ||
---tty-stream-chunk-separator | ||
[32m✔[39m a [90m[2m›[22m[39m a passes two | ||
---tty-stream-chunk-separator | ||
[31m[39m | ||
[31m✘ Timed out while running tests[39m | ||
|
||
2 tests were pending in a.cjs | ||
|
||
◌ a [90m[2m›[22m[39m a slow | ||
[35mℹ[39m [90mthis slow test prints useful debug message just text[39m | ||
◌ a [90m[2m›[22m[39m a slow two | ||
[35mℹ[39m [90manother useful debug message [90m{[39m[90m[39m | ||
[90m x: [33m5[39m[90m[90m,[39m[90m[39m | ||
[90m[90m}[39m[90m[39m | ||
|
||
---tty-stream-chunk-separator | ||
[32m✔[39m b [90m[2m›[22m[39m a passes | ||
---tty-stream-chunk-separator | ||
[32m✔[39m b [90m[2m›[22m[39m a passes two | ||
---tty-stream-chunk-separator | ||
[31m[39m | ||
[31m✘ Timed out while running tests[39m | ||
|
||
2 tests were pending in b.cjs | ||
|
||
◌ b [90m[2m›[22m[39m a slow | ||
[35mℹ[39m [90mhello world[39m | ||
◌ b [90m[2m›[22m[39m a slow two | ||
|
||
---tty-stream-chunk-separator | ||
[90m─[39m | ||
|
||
[32m4 tests passed[39m | ||
[31m4 tests remained pending after a timeout[39m | ||
---tty-stream-chunk-separator |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
|
||
---tty-stream-chunk-separator | ||
[32m✔[39m a [90m[2m›[22m[39m a passes | ||
---tty-stream-chunk-separator | ||
[32m✔[39m a [90m[2m›[22m[39m a passes two | ||
---tty-stream-chunk-separator | ||
[31m[39m | ||
[31m✘ Timed out while running tests[39m | ||
|
||
2 tests were pending in a.cjs | ||
|
||
◌ a [90m[2m›[22m[39m a slow | ||
[35mℹ[39m [90mthis slow test prints useful debug message just text[39m | ||
◌ a [90m[2m›[22m[39m a slow two | ||
[35mℹ[39m [90manother useful debug message [90m{[39m[90m[39m | ||
[90m x: [33m5[39m[90m[90m,[39m[90m[39m | ||
[90m[90m}[39m[90m[39m | ||
|
||
---tty-stream-chunk-separator | ||
[32m✔[39m b [90m[2m›[22m[39m a passes | ||
---tty-stream-chunk-separator | ||
[32m✔[39m b [90m[2m›[22m[39m a passes two | ||
---tty-stream-chunk-separator | ||
[31m[39m | ||
[31m✘ Timed out while running tests[39m | ||
|
||
2 tests were pending in b.cjs | ||
|
||
◌ b [90m[2m›[22m[39m a slow | ||
[35mℹ[39m [90mhello world[39m | ||
◌ b [90m[2m›[22m[39m a slow two | ||
|
||
---tty-stream-chunk-separator | ||
[90m─[39m | ||
|
||
[32m4 tests passed[39m | ||
[31m4 tests remained pending after a timeout[39m | ||
---tty-stream-chunk-separator |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
|
||
---tty-stream-chunk-separator | ||
[32m✔[39m a [90m[2m›[22m[39m a passes | ||
---tty-stream-chunk-separator | ||
[32m✔[39m a [90m[2m›[22m[39m a passes two | ||
---tty-stream-chunk-separator | ||
[31m[39m | ||
[31m✘ Timed out while running tests[39m | ||
|
||
2 tests were pending in a.cjs | ||
|
||
◌ a [90m[2m›[22m[39m a slow | ||
[35mℹ[39m [90mthis slow test prints useful debug message just text[39m | ||
◌ a [90m[2m›[22m[39m a slow two | ||
[35mℹ[39m [90manother useful debug message [90m{[39m[90m[39m | ||
[90m x: [33m5[39m[90m[90m,[39m[90m[39m | ||
[90m[90m}[39m[90m[39m | ||
|
||
---tty-stream-chunk-separator | ||
[32m✔[39m b [90m[2m›[22m[39m a passes | ||
---tty-stream-chunk-separator | ||
[32m✔[39m b [90m[2m›[22m[39m a passes two | ||
---tty-stream-chunk-separator | ||
[31m[39m | ||
[31m✘ Timed out while running tests[39m | ||
|
||
2 tests were pending in b.cjs | ||
|
||
◌ b [90m[2m›[22m[39m a slow | ||
[35mℹ[39m [90mhello world[39m | ||
◌ b [90m[2m›[22m[39m a slow two | ||
|
||
---tty-stream-chunk-separator | ||
[90m─[39m | ||
|
||
[32m4 tests passed[39m | ||
[31m4 tests remained pending after a timeout[39m | ||
---tty-stream-chunk-separator |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.