| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 2d7cac0 commit 40b3879
8 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -565,13 +565,7 @@ primordials.SafePromiseAllSettled = (promises, mapFn) => | |||
| 565 | 565 | * @returns {Promise<void>} | |
| 566 | 566 | */ | |
| 567 | 567 | primordials.SafePromiseAllSettledReturnVoid = async (promises, mapFn) => { | |
| 568 | - for (let i = 0; i < promises.length; i++) { | ||
| 569 | - try { | ||
| 570 | - await (mapFn != null ? mapFn(promises[i], i) : promises[i]); | ||
| 571 | - } catch { | ||
| 572 | - // In all settled, we can ignore errors. | ||
| 573 | - } | ||
| 574 | - } | ||
| 568 | + await primordials.SafePromiseAllSettled(promises, mapFn); | ||
| 575 | 569 | }; | |
| 576 | 570 | ||
| 577 | 571 | /** | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -207,10 +207,6 @@ class FileTest extends Test { | |||
| 207 | 207 | const testNumber = nesting === 0 ? (this.root.harness.counters.topLevel + 1) : node.id; | |
| 208 | 208 | const method = pass ? 'ok' : 'fail'; | |
| 209 | 209 | this.reporter[method](nesting, this.name, testNumber, node.description, diagnostics, directive); | |
| 210 | - if (nesting === 0) { | ||
| 211 | - this.failedSubtests ||= !pass; | ||
| 212 | - } | ||
| 213 | - this.#reportedChildren++; | ||
| 214 | 210 | countCompletedTest({ | |
| 215 | 211 | name: node.description, | |
| 216 | 212 | finished: true, | |
@@ -237,22 +233,36 @@ class FileTest extends Test { | |||
| 237 | 233 | break; | |
| 238 | 234 | } | |
| 239 | 235 | } | |
| 236 | + #accumulateReportItem({ kind, node, comments, nesting = 0 }) { | ||
| 237 | + if (kind !== TokenKind.TAP_TEST_POINT) { | ||
| 238 | + return; | ||
| 239 | + } | ||
| 240 | + this.#reportedChildren++; | ||
| 241 | + if (nesting === 0 && !node.status.pass) { | ||
| 242 | + this.failedSubtests = true; | ||
| 243 | + } | ||
| 244 | + } | ||
| 245 | + #drainBuffer() { | ||
| 246 | + if (this.#buffer.length > 0) { | ||
| 247 | + ArrayPrototypeForEach(this.#buffer, (ast) => this.#handleReportItem(ast)); | ||
| 248 | + this.#buffer = []; | ||
| 249 | + } | ||
| 250 | + } | ||
| 240 | 251 | addToReport(ast) { | |
| 252 | + this.#accumulateReportItem(ast); | ||
| 241 | 253 | if (!this.isClearToSend()) { | |
| 242 | 254 | ArrayPrototypePush(this.#buffer, ast); | |
| 243 | 255 | return; | |
| 244 | 256 | } | |
| 245 | - this.reportStarted(); | ||
| 257 | + this.#drainBuffer(); | ||
| 246 | 258 | this.#handleReportItem(ast); | |
| 247 | 259 | } | |
| 248 | 260 | reportStarted() {} | |
| 249 | 261 | report() { | |
| 262 | + this.#drainBuffer(); | ||
| 250 | 263 | const skipReporting = this.#skipReporting(); | |
| 251 | 264 | if (!skipReporting) { | |
| 252 | 265 | super.reportStarted(); | |
| 253 | - } | ||
| 254 | - ArrayPrototypeForEach(this.#buffer, (ast) => this.#handleReportItem(ast)); | ||
| 255 | - if (!skipReporting) { | ||
| 256 | 266 | super.report(); | |
| 257 | 267 | } | |
| 258 | 268 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -658,7 +658,7 @@ class Test extends AsyncResource { | |||
| 658 | 658 | this.reporter.coverage(this.nesting, kFilename, coverage); | |
| 659 | 659 | } | |
| 660 | 660 | ||
| 661 | - this.reporter.push(null); | ||
| 661 | + this.reporter.end(); | ||
| 662 | 662 | } | |
| 663 | 663 | } | |
| 664 | 664 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -59,6 +59,10 @@ class TestsStream extends Readable { | |||
| 59 | 59 | this.#emit('test:coverage', { __proto__: null, nesting, file, summary }); | |
| 60 | 60 | } | |
| 61 | 61 | ||
| 62 | + end() { | ||
| 63 | + this.#tryPush(null); | ||
| 64 | + } | ||
| 65 | + | ||
| 62 | 66 | #emit(type, data) { | |
| 63 | 67 | this.emit(type, data); | |
| 64 | 68 | this.#tryPush({ type, data }); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,13 @@ | |||
| 1 | + import tmpdir from '../../../common/tmpdir.js'; | ||
| 2 | + import { setTimeout } from 'node:timers/promises'; | ||
| 3 | + import fs from 'node:fs/promises'; | ||
| 4 | + import path from 'node:path'; | ||
| 5 | + | ||
| 6 | + await fs.writeFile(path.resolve(tmpdir.path, 'test-runner-concurrency'), 'a.mjs'); | ||
| 7 | + while (true) { | ||
| 8 | + const file = await fs.readFile(path.resolve(tmpdir.path, 'test-runner-concurrency'), 'utf8'); | ||
| 9 | + if (file === 'b.mjs') { | ||
| 10 | + break; | ||
| 11 | + } | ||
| 12 | + await setTimeout(10); | ||
| 13 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,13 @@ | |||
| 1 | + import tmpdir from '../../../common/tmpdir.js'; | ||
| 2 | + import { setTimeout } from 'node:timers/promises'; | ||
| 3 | + import fs from 'node:fs/promises'; | ||
| 4 | + import path from 'node:path'; | ||
| 5 | + | ||
| 6 | + while (true) { | ||
| 7 | + const file = await fs.readFile(path.resolve(tmpdir.path, 'test-runner-concurrency'), 'utf8'); | ||
| 8 | + if (file === 'a.mjs') { | ||
| 9 | + await fs.writeFile(path.resolve(tmpdir.path, 'test-runner-concurrency'), 'b.mjs'); | ||
| 10 | + break; | ||
| 11 | + } | ||
| 12 | + await setTimeout(10); | ||
| 13 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -55,13 +55,11 @@ assertIsPromise(SafePromisePrototypeFinally(test(), common.mustCall())); | |||
| 55 | 55 | ||
| 56 | 56 | assertIsPromise(SafePromiseAllReturnArrayLike([test()])); | |
| 57 | 57 | assertIsPromise(SafePromiseAllReturnVoid([test()])); | |
| 58 | - assertIsPromise(SafePromiseAllSettledReturnVoid([test()])); | ||
| 59 | 58 | assertIsPromise(SafePromiseAny([test()])); | |
| 60 | 59 | assertIsPromise(SafePromiseRace([test()])); | |
| 61 | 60 | ||
| 62 | 61 | assertIsPromise(SafePromiseAllReturnArrayLike([])); | |
| 63 | 62 | assertIsPromise(SafePromiseAllReturnVoid([])); | |
| 64 | - assertIsPromise(SafePromiseAllSettledReturnVoid([])); | ||
| 65 | 63 | ||
| 66 | 64 | { | |
| 67 | 65 | const val1 = Symbol(); | |
@@ -108,9 +106,11 @@ Object.defineProperties(Array.prototype, { | |||
| 108 | 106 | ||
| 109 | 107 | assertIsPromise(SafePromiseAll([test()])); | |
| 110 | 108 | assertIsPromise(SafePromiseAllSettled([test()])); | |
| 109 | + assertIsPromise(SafePromiseAllSettledReturnVoid([test()])); | ||
| 111 | 110 | ||
| 112 | 111 | assertIsPromise(SafePromiseAll([])); | |
| 113 | 112 | assertIsPromise(SafePromiseAllSettled([])); | |
| 113 | + assertIsPromise(SafePromiseAllSettledReturnVoid([])); | ||
| 114 | 114 | ||
| 115 | 115 | async function test() { | |
| 116 | 116 | const catchFn = common.mustCall(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,7 +1,14 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | const common = require('../common'); | |
| 3 | + const tmpdir = require('../common/tmpdir'); | ||
| 4 | + const fixtures = require('../common/fixtures'); | ||
| 3 | 5 | const { describe, it, test } = require('node:test'); | |
| 4 | - const assert = require('assert'); | ||
| 6 | + const assert = require('node:assert'); | ||
| 7 | + const path = require('node:path'); | ||
| 8 | + const fs = require('node:fs/promises'); | ||
| 9 | + const os = require('node:os'); | ||
| 10 | + | ||
| 11 | + tmpdir.refresh(); | ||
| 5 | 12 | ||
| 6 | 13 | describe('Concurrency option (boolean) = true ', { concurrency: true }, () => { | |
| 7 | 14 | let isFirstTestOver = false; | |
@@ -62,3 +69,14 @@ describe( | |||
| 62 | 69 | it('should run after other suites', expectedTestTree); | |
| 63 | 70 | }); | |
| 64 | 71 | } | |
| 72 | + | ||
| 73 | + test('--test multiple files', { skip: os.availableParallelism() < 3 }, async () => { | ||
| 74 | + await fs.writeFile(path.resolve(tmpdir.path, 'test-runner-concurrency'), ''); | ||
| 75 | + const { code, stderr } = await common.spawnPromisified(process.execPath, [ | ||
| 76 | + '--test', | ||
| 77 | + fixtures.path('test-runner', 'concurrency', 'a.mjs'), | ||
| 78 | + fixtures.path('test-runner', 'concurrency', 'b.mjs'), | ||
| 79 | + ]); | ||
| 80 | + assert.strictEqual(stderr, ''); | ||
| 81 | + assert.strictEqual(code, 0); | ||
| 82 | + }); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments