| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -184,21 +184,26 @@ function setup(root) { | |||
| 184 | 184 | __proto__: null, | |
| 185 | 185 | allowTestsToRun: false, | |
| 186 | 186 | bootstrapComplete: false, | |
| 187 | + watching: false, | ||
| 187 | 188 | coverage: FunctionPrototypeBind(collectCoverage, null, root, coverage), | |
| 188 | - counters: { | ||
| 189 | - __proto__: null, | ||
| 190 | - all: 0, | ||
| 191 | - failed: 0, | ||
| 192 | - passed: 0, | ||
| 193 | - cancelled: 0, | ||
| 194 | - skipped: 0, | ||
| 195 | - todo: 0, | ||
| 196 | - topLevel: 0, | ||
| 197 | - suites: 0, | ||
| 189 | + resetCounters() { | ||
| 190 | + root.harness.counters = { | ||
| 191 | + __proto__: null, | ||
| 192 | + all: 0, | ||
| 193 | + failed: 0, | ||
| 194 | + passed: 0, | ||
| 195 | + cancelled: 0, | ||
| 196 | + skipped: 0, | ||
| 197 | + todo: 0, | ||
| 198 | + topLevel: 0, | ||
| 199 | + suites: 0, | ||
| 200 | + }; | ||
| 198 | 201 | }, | |
| 202 | + counters: null, | ||
| 199 | 203 | shouldColorizeTestFiles: false, | |
| 200 | 204 | teardown: exitHandler, | |
| 201 | 205 | }; | |
| 206 | + root.harness.resetCounters(); | ||
| 202 | 207 | root.startTime = hrtime(); | |
| 203 | 208 | return root; | |
| 204 | 209 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -36,6 +36,7 @@ const { createInterface } = require('readline'); | |||
| 36 | 36 | const { deserializeError } = require('internal/error_serdes'); | |
| 37 | 37 | const { Buffer } = require('buffer'); | |
| 38 | 38 | const { FilesWatcher } = require('internal/watch_mode/files_watcher'); | |
| 39 | + const { queueMicrotask } = require('internal/process/task_queues'); | ||
| 39 | 40 | const console = require('internal/console/global'); | |
| 40 | 41 | const { | |
| 41 | 42 | codes: { | |
@@ -378,6 +379,7 @@ function runTestFile(path, filesWatcher, opts) { | |||
| 378 | 379 | filesWatcher.runningSubtests.delete(path); | |
| 379 | 380 | if (filesWatcher.runningSubtests.size === 0) { | |
| 380 | 381 | opts.root.reporter[kEmitMessage]('test:watch:drained'); | |
| 382 | + queueMicrotask(() => opts.root.postRun()); | ||
| 381 | 383 | } | |
| 382 | 384 | } | |
| 383 | 385 | ||
@@ -405,6 +407,7 @@ function watchFiles(testFiles, opts) { | |||
| 405 | 407 | const runningSubtests = new SafeMap(); | |
| 406 | 408 | const watcher = new FilesWatcher({ __proto__: null, debounce: 200, mode: 'filter', signal: opts.signal }); | |
| 407 | 409 | const filesWatcher = { __proto__: null, watcher, runningProcesses, runningSubtests }; | |
| 410 | + opts.root.harness.watching = true; | ||
| 408 | 411 | ||
| 409 | 412 | watcher.on('changed', ({ owners }) => { | |
| 410 | 413 | watcher.unfilterFilesOwnedBy(owners); | |
@@ -431,7 +434,10 @@ function watchFiles(testFiles, opts) { | |||
| 431 | 434 | kResistStopPropagation ??= require('internal/event_target').kResistStopPropagation; | |
| 432 | 435 | opts.signal.addEventListener( | |
| 433 | 436 | 'abort', | |
| 434 | - () => opts.root.postRun(), | ||
| 437 | + () => { | ||
| 438 | + opts.root.harness.watching = false; | ||
| 439 | + opts.root.postRun(); | ||
| 440 | + }, | ||
| 435 | 441 | { __proto__: null, once: true, [kResistStopPropagation]: true }, | |
| 436 | 442 | ); | |
| 437 | 443 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -847,7 +847,12 @@ class Test extends AsyncResource { | |||
| 847 | 847 | reporter.coverage(nesting, loc, coverage); | |
| 848 | 848 | } | |
| 849 | 849 | ||
| 850 | - reporter.end(); | ||
| 850 | + if (harness.watching) { | ||
| 851 | + this.reported = false; | ||
| 852 | + harness.resetCounters(); | ||
| 853 | + } else { | ||
| 854 | + reporter.end(); | ||
| 855 | + } | ||
| 851 | 856 | } | |
| 852 | 857 | } | |
| 853 | 858 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -195,9 +195,16 @@ describe('require(\'node:test\').run', { concurrency: true }, () => { | |||
| 195 | 195 | signal: controller.signal, | |
| 196 | 196 | }) | |
| 197 | 197 | .compose(async function* (source) { | |
| 198 | + let waitForCancel = 2; | ||
| 198 | 199 | for await (const chunk of source) { | |
| 199 | - if (chunk.type === 'test:pass') { | ||
| 200 | + if (chunk.type === 'test:watch:drained' || | ||
| 201 | + (chunk.type === 'test:diagnostic' && chunk.data.message.startsWith('duration_ms'))) { | ||
| 202 | + waitForCancel--; | ||
| 203 | + } | ||
| 204 | + if (waitForCancel === 0) { | ||
| 200 | 205 | controller.abort(); | |
| 206 | + } | ||
| 207 | + if (chunk.type === 'test:pass') { | ||
| 201 | 208 | yield chunk.data.name; | |
| 202 | 209 | } | |
| 203 | 210 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments