| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent d2994e5 commit 2d7cac0
8 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -176,7 +176,7 @@ function setup(root) { | |||
| 176 | 176 | cancelled: 0, | |
| 177 | 177 | skipped: 0, | |
| 178 | 178 | todo: 0, | |
| 179 | - planned: 0, | ||
| 179 | + topLevel: 0, | ||
| 180 | 180 | suites: 0, | |
| 181 | 181 | }, | |
| 182 | 182 | }; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,14 +5,11 @@ const { | |||
| 5 | 5 | ArrayPrototypeFilter, | |
| 6 | 6 | ArrayPrototypeForEach, | |
| 7 | 7 | ArrayPrototypeIncludes, | |
| 8 | - ArrayPrototypeIndexOf, | ||
| 9 | 8 | ArrayPrototypeMap, | |
| 10 | 9 | ArrayPrototypePush, | |
| 11 | 10 | ArrayPrototypeSlice, | |
| 12 | 11 | ArrayPrototypeSome, | |
| 13 | 12 | ArrayPrototypeSort, | |
| 14 | - ArrayPrototypeSplice, | ||
| 15 | - Number, | ||
| 16 | 13 | ObjectAssign, | |
| 17 | 14 | PromisePrototypeThen, | |
| 18 | 15 | SafePromiseAll, | |
@@ -207,7 +204,7 @@ class FileTest extends Test { | |||
| 207 | 204 | ||
| 208 | 205 | const diagnostics = YAMLToJs(node.diagnostics); | |
| 209 | 206 | const cancelled = kCanceledTests.has(diagnostics.error?.failureType); | |
| 210 | - const testNumber = nesting === 0 ? (Number(node.id) + this.testNumber - 1) : node.id; | ||
| 207 | + const testNumber = nesting === 0 ? (this.root.harness.counters.topLevel + 1) : node.id; | ||
| 211 | 208 | const method = pass ? 'ok' : 'fail'; | |
| 212 | 209 | this.reporter[method](nesting, this.name, testNumber, node.description, diagnostics, directive); | |
| 213 | 210 | if (nesting === 0) { | |
@@ -335,17 +332,7 @@ function runTestFile(path, root, inspectPort, filesWatcher, testNamePatterns) { | |||
| 335 | 332 | throw err; | |
| 336 | 333 | } | |
| 337 | 334 | }); | |
| 338 | - const promise = subtest.start(); | ||
| 339 | - if (filesWatcher) { | ||
| 340 | - return PromisePrototypeThen(promise, () => { | ||
| 341 | - const index = ArrayPrototypeIndexOf(root.subtests, subtest); | ||
| 342 | - if (index !== -1) { | ||
| 343 | - ArrayPrototypeSplice(root.subtests, index, 1); | ||
| 344 | - root.waitingOn--; | ||
| 345 | - } | ||
| 346 | - }); | ||
| 347 | - } | ||
| 348 | - return promise; | ||
| 335 | + return subtest.start(); | ||
| 349 | 336 | } | |
| 350 | 337 | ||
| 351 | 338 | function watchFiles(testFiles, root, inspectPort, testNamePatterns) { | |
@@ -361,6 +348,10 @@ function watchFiles(testFiles, root, inspectPort, testNamePatterns) { | |||
| 361 | 348 | runningProcess.kill(); | |
| 362 | 349 | await once(runningProcess, 'exit'); | |
| 363 | 350 | } | |
| 351 | + if (!runningSubtests.size) { | ||
| 352 | + // Reset the topLevel counter | ||
| 353 | + root.harness.counters.topLevel = 0; | ||
| 354 | + } | ||
| 364 | 355 | await runningSubtests.get(file); | |
| 365 | 356 | runningSubtests.set(file, runTestFile(file, root, inspectPort, filesWatcher, testNamePatterns)); | |
| 366 | 357 | }, undefined, (error) => { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -637,7 +637,7 @@ class Test extends AsyncResource { | |||
| 637 | 637 | this.parent.processPendingSubtests(); | |
| 638 | 638 | } else if (!this.reported) { | |
| 639 | 639 | this.reported = true; | |
| 640 | - this.reporter.plan(this.nesting, kFilename, this.root.harness.counters.planned); | ||
| 640 | + this.reporter.plan(this.nesting, kFilename, this.root.harness.counters.topLevel); | ||
| 641 | 641 | ||
| 642 | 642 | for (let i = 0; i < this.diagnostics.length; i++) { | |
| 643 | 643 | this.reporter.diagnostic(this.nesting, kFilename, this.diagnostics[i]); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -227,7 +227,7 @@ function parseCommandLine() { | |||
| 227 | 227 | ||
| 228 | 228 | function countCompletedTest(test, harness = test.root.harness) { | |
| 229 | 229 | if (test.nesting === 0) { | |
| 230 | - harness.counters.planned++; | ||
| 230 | + harness.counters.topLevel++; | ||
| 231 | 231 | } | |
| 232 | 232 | if (test.reportedType === 'suite') { | |
| 233 | 233 | harness.counters.suites++; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,5 +5,5 @@ const fixtures = require('../../../common/fixtures'); | |||
| 5 | 5 | const spawn = require('node:child_process').spawn; | |
| 6 | 6 | ||
| 7 | 7 | spawn(process.execPath, | |
| 8 | - ['--no-warnings', '--test', '--test-reporter', 'tap', fixtures.path('test-runner/output/output.js')], | ||
| 8 | + ['--no-warnings', '--test', '--test-reporter', 'tap', fixtures.path('test-runner/output/output.js'), fixtures.path('test-runner/output/single.js')], | ||
| 9 | 9 | { stdio: 'inherit' }); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -672,10 +672,15 @@ not ok 66 - invalid subtest fail | |||
| 672 | 672 | # Warning: Test "immediate reject - passes but warns" generated asynchronous activity after the test ended. This activity created the error "Error: rejected from immediate reject fail" and would have caused the test to fail, but instead triggered an unhandledRejection event. | |
| 673 | 673 | # Warning: Test "callback called twice in different ticks" generated asynchronous activity after the test ended. This activity created the error "Error [ERR_TEST_FAILURE]: callback invoked multiple times" and would have caused the test to fail, but instead triggered an uncaughtException event. | |
| 674 | 674 | # Warning: Test "callback async throw after done" generated asynchronous activity after the test ended. This activity created the error "Error: thrown from callback async throw after done" and would have caused the test to fail, but instead triggered an uncaughtException event. | |
| 675 | - 1..66 | ||
| 676 | - # tests 80 | ||
| 675 | + # Subtest: last test | ||
| 676 | + ok 67 - last test | ||
| 677 | + --- | ||
| 678 | + duration_ms: * | ||
| 679 | + ... | ||
| 680 | + 1..67 | ||
| 681 | + # tests 81 | ||
| 677 | 682 | # suites 0 | |
| 678 | - # pass 37 | ||
| 683 | + # pass 38 | ||
| 679 | 684 | # fail 25 | |
| 680 | 685 | # cancelled 3 | |
| 681 | 686 | # skipped 10 | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,4 @@ | |||
| 1 | + // Flags: --no-warnings | ||
| 2 | + 'use strict'; | ||
| 3 | + const test = require('node:test'); | ||
| 4 | + test('last test', () => {}); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,13 +14,14 @@ async function testWatch({ files, fileToUpdate }) { | |||
| 14 | 14 | ||
| 15 | 15 | child.stdout.on('data', (data) => { | |
| 16 | 16 | stdout += data.toString(); | |
| 17 | - const matches = stdout.match(/test has ran/g); | ||
| 18 | - if (matches?.length >= 1) ran1.resolve(); | ||
| 19 | - if (matches?.length >= 2) ran2.resolve(); | ||
| 17 | + const testRuns = stdout.match(/ - test has ran/g); | ||
| 18 | + if (testRuns?.length >= 1) ran1.resolve(); | ||
| 19 | + if (testRuns?.length >= 2) ran2.resolve(); | ||
| 20 | 20 | }); | |
| 21 | 21 | ||
| 22 | 22 | await ran1.promise; | |
| 23 | - const interval = setInterval(() => writeFileSync(fileToUpdate, readFileSync(fileToUpdate, 'utf8')), 50); | ||
| 23 | + const content = readFileSync(fileToUpdate, 'utf8'); | ||
| 24 | + const interval = setInterval(() => writeFileSync(fileToUpdate, content), 10); | ||
| 24 | 25 | await ran2.promise; | |
| 25 | 26 | clearInterval(interval); | |
| 26 | 27 | child.kill(); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments