Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 23f22bc

Browse filesBrowse files
Trotttargos
authored andcommitted
test: check that benchmark tests are minimal
Check that benchmark tests are not running longer than necessary by confirming that they only produce one set of configs to report on per benchmark file. PR-URL: #21046 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
1 parent 9030e93 commit 23f22bc
Copy full SHA for 23f22bc

File tree

Expand file treeCollapse file tree

1 file changed

+18
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+18
-1
lines changed
Open diff view settings
Collapse file

‎test/common/benchmark.js‎

Copy file name to clipboardExpand all lines: test/common/benchmark.js
+18-1Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,27 @@ function runBenchmark(name, args, env) {
2020

2121
const mergedEnv = Object.assign({}, process.env, env);
2222

23-
const child = fork(runjs, argv, { env: mergedEnv });
23+
const child = fork(runjs, argv, { env: mergedEnv, stdio: 'pipe' });
24+
child.stdout.setEncoding('utf8');
25+
26+
let stdout = '';
27+
child.stdout.on('data', (line) => {
28+
stdout += line;
29+
});
30+
2431
child.on('exit', (code, signal) => {
2532
assert.strictEqual(code, 0);
2633
assert.strictEqual(signal, null);
34+
// This bit makes sure that each benchmark file is being sent settings such
35+
// that the benchmark file runs just one set of options. This helps keep the
36+
// benchmark tests from taking a long time to run. Therefore, each benchmark
37+
// file should result in three lines of output: a blank line, a line with
38+
// the name of the benchmark file, and a line with the only results that we
39+
// get from testing the benchmark file.
40+
assert.ok(
41+
/^(?:\n.+?\n.+?\n)+$/.test(stdout),
42+
`benchmark file not running exactly one configuration in test: ${stdout}`
43+
);
2744
});
2845
}
2946

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.