-
Notifications
You must be signed in to change notification settings - Fork 29.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/main' into sdghjfsjghafjhkfs
- Loading branch information
Showing
595 changed files
with
49,612 additions
and
24,087 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
const { test } = require('node:test'); | ||
|
||
test('should pass', () => {}); | ||
test('should fail', () => { throw new Error('fail'); }); | ||
test('should skip', { skip: true }, () => {}); | ||
test('parent', (t) => { | ||
t.test('should fail', () => { throw new Error('fail'); }); | ||
t.test('should pass but parent fail', (t, done) => { | ||
setImmediate(done); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const assert = require('node:assert'); | ||
const { test } = require('node:test'); | ||
|
||
const bench = common.createBenchmark(main, { | ||
n: [1e6], | ||
mode: ['define', 'execute'], | ||
}, { | ||
// We don't want to test the reporter here | ||
flags: ['--test-reporter=./benchmark/fixtures/empty-test-reporter.js'], | ||
}); | ||
|
||
const noop = () => {}; | ||
|
||
function benchmarkDefine(n) { | ||
let noDead; | ||
test((t) => { | ||
bench.start(); | ||
for (let i = 0; i < n; i++) { | ||
noDead = t.mock.fn(noop); | ||
} | ||
bench.end(n); | ||
assert.ok(noDead); | ||
}); | ||
} | ||
|
||
function benchmarkExecute(n) { | ||
let noDead; | ||
test((t) => { | ||
const mocked = t.mock.fn(noop); | ||
bench.start(); | ||
for (let i = 0; i < n; i++) { | ||
noDead = mocked(); | ||
} | ||
bench.end(n); | ||
assert.strictEqual(noDead, noop()); | ||
}); | ||
} | ||
|
||
function main({ n, mode }) { | ||
if (mode === 'define') { | ||
benchmarkDefine(n); | ||
} else if (mode === 'execute') { | ||
benchmarkExecute(n); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const { run } = require('node:test'); | ||
const reporters = require('node:test/reporters'); | ||
const { Readable } = require('node:stream'); | ||
const assert = require('node:assert'); | ||
|
||
const bench = common.createBenchmark(main, { | ||
n: [1e4], | ||
reporter: Object.keys(reporters), | ||
}); | ||
|
||
// No need to run this for every benchmark, | ||
// it should always be the same data. | ||
const stream = run({ | ||
files: ['../fixtures/basic-test-runner.js'], | ||
}); | ||
let testResults; | ||
|
||
async function main({ n, reporter: r }) { | ||
testResults ??= await stream.toArray(); | ||
|
||
// Create readable streams for each iteration | ||
const readables = Array.from({ length: n }, () => Readable.from(testResults)); | ||
|
||
// Get the selected reporter | ||
const reporter = reporters[r]; | ||
|
||
bench.start(); | ||
|
||
let noDead; | ||
for (const readable of readables) { | ||
// Process each readable stream through the reporter | ||
noDead = await readable.compose(reporter).toArray(); | ||
} | ||
|
||
bench.end(n); | ||
|
||
assert.ok(noDead); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.