GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test: use common spawnSync helpers in more tests by greenheadHQ · Pull Request #65552 · nodejs/node

test: use common spawnSync helpers in more tests #65552

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
nodejs-github-bot merged 3 commits into nodejs:main from greenheadHQ:use-spawnsync-helpers
Aug 28, 2026

Uh oh!

There was an error while loading. Please reload this page.

Merged

test: use common spawnSync helpers in more tests #65552

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
3 commits
Select commit Hold shift + click to select a range
1c0a3ea
test: use common spawnSync helpers in more tests
greenheadHQ Aug 25, 2026
98ce165
fixup! test: use common spawnSync helpers in more tests
greenheadHQ Aug 26, 2026
d43187e
fixup! test: use common spawnSync helpers in more tests
greenheadHQ Aug 26, 2026
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

7 changes: 3 additions & 4 deletions 7 test/message/node_run_list.js
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
'use strict';

require('../common');
const assert = require('node:assert/strict');
const childProcess = require('node:child_process');
const { spawnSyncAndExit } = require('../common/child_process');
const fixtures = require('../common/fixtures');

const child = childProcess.spawnSync(
const { child } = spawnSyncAndExit(
process.execPath,
[ '--no-warnings', '--run'],
{ cwd: fixtures.path('run-script'), encoding: 'utf8' },
{ status: 9, signal: null },
);
assert.strictEqual(child.status, 9);
console.log(child.stderr);
Comment thread
aduh95 marked this conversation as resolved.
Resolved

Uh oh!

There was an error while loading. Please reload this page.

4 changes: 2 additions & 2 deletions 4 test/parallel/test-common-wpt-backends.js
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const assert = require('assert');
const fs = require('fs');
const path = require('path');
const { spawnSync } = require('child_process');
const { spawnSyncAndExitWithoutError } = require('../common/child_process');
const { backends, WPTRunner } = require('../common/wpt');

const queueProbe = process.env.NODE_TEST_WPT_QUEUE_PROBE === '1';
Expand Down Expand Up @@ -106,12 +107,11 @@ async function compare(throws) {
// End to end: the runner's own reporting has to match too. The webidl spec
// reports an uncaught error whose name the status file matches on.
function runDriver(driver, spec, backend) {
const { status, stdout, stderr } = spawnSync(
const { child: { stdout } } = spawnSyncAndExitWithoutError(
process.execPath,
[path.join(__dirname, '../wpt', driver), spec],
{ env: { ...process.env, WPT_BACKEND: backend }, encoding: 'utf8' },
);
assert.strictEqual(status, 0, `${spec} failed on the ${backend} backend:\n${stdout}${stderr}`);
// Specs run concurrently, so the lines arrive in an arbitrary order.
return stdout.split('\n').filter((line) => line.startsWith('[')).sort();
}
Expand Down
8 changes: 3 additions & 5 deletions 8 test/parallel/test-fs-glob.mjs
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as common from '../common/index.mjs';
import tmpdir from '../common/tmpdir.js';
import { spawnSync } from 'node:child_process';
import { spawnSyncAndExitWithoutError } from '../common/child_process.js';
import { resolve, dirname, sep, relative, join, isAbsolute } from 'node:path';
import { mkdir, writeFile, symlink, glob as asyncGlob } from 'node:fs/promises';
import {
Expand Down Expand Up @@ -707,12 +707,11 @@ test('glob forwards maxDepth', async () => {
});

function runNodeScript(script) {
const child = spawnSync(
const { child } = spawnSyncAndExitWithoutError(
process.execPath,
['--expose-internals', '-e', script],
{ encoding: 'utf8' },
);
assert.strictEqual(child.status, 0, child.stderr || child.stdout);
return child.stdout;
}

Expand Down Expand Up @@ -992,11 +991,10 @@ describe('glob - seen cache', function() {
`;

const seenDir = tmpdir.resolve('glob-seen');
const child = spawnSync(
spawnSyncAndExitWithoutError(
process.execPath,
['--expose-internals', '-e', script, seenDir],
{ encoding: 'utf8' },
);
assert.strictEqual(child.status, 0, child.stderr || child.stdout);
});
});
10 changes: 5 additions & 5 deletions 10 test/parallel/test-module-unreadable-package-json.js
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const assert = require('assert');
const fs = require('fs');
const path = require('path');
const { spawnSync } = require('child_process');
const { spawnSyncAndAssert } = require('../common/child_process');
const tmpdir = require('../common/tmpdir');

tmpdir.refresh();
Expand All @@ -38,11 +39,10 @@ const entry = tmpdir.resolve('main.mjs');
fs.writeFileSync(entry, 'import { which } from "dep"; console.log(which);');

// Sanity check: the export resolves while the package config is readable.
{
const child = spawnSync(process.execPath, [entry], { encoding: 'utf8' });
assert.strictEqual(child.stdout.trim(), 'real');
assert.strictEqual(child.status, 0, child.stderr);
}
spawnSyncAndAssert(process.execPath, [entry], { encoding: 'utf8' }, {
stdout: 'real',
trim: true,
});

fs.chmodSync(depPackageJson, 0o000);

Expand Down
19 changes: 9 additions & 10 deletions 19 test/parallel/test-runner-cli.js
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require('../common');
const assert = require('assert');
const { spawnSync } = require('child_process');
const { spawnSyncAndAssert } = require('../common/child_process');
const { join } = require('path');
const fixtures = require('../common/fixtures');
const testFixtures = fixtures.path('test-runner');
Expand Down Expand Up @@ -70,16 +71,14 @@ for (const isolation of ['none', 'process']) {
const args = ['--test', '--test-reporter=tap',
'--no-experimental-strip-types',
`--test-isolation=${isolation}`, dir];
const child = spawnSync(process.execPath, args, { cwd: testFixtures });

assert.strictEqual(child.status, 0);
assert.strictEqual(child.signal, null);
assert.strictEqual(child.stderr.toString(), '');
const stdout = child.stdout.toString();

assert.match(stdout, /ok 1 - this should pass/);
assert.match(stdout, /ok 2 - this should pass/);
assert.match(stdout, /ok 3 - this should pass/);
spawnSyncAndAssert(process.execPath, args, { cwd: testFixtures }, {
stderr: '',
stdout(output) {
assert.match(output, /ok 1 - this should pass/);
assert.match(output, /ok 2 - this should pass/);
assert.match(output, /ok 3 - this should pass/);
},
});
}
}

Expand Down
42 changes: 20 additions & 22 deletions 42 test/parallel/test-runner-coverage-default-exclusion.mjs
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import '../common/index.mjs';
import { before, describe, it } from 'node:test';
import assert from 'node:assert';
import { spawnSync } from 'node:child_process';
import { cp } from 'node:fs/promises';
import tmpdir from '../common/tmpdir.js';
import fixtures from '../common/fixtures.js';
import { spawnSyncAndAssert } from '../common/child_process.js';
const skipIfNoInspector = {
skip: !process.features.inspector ? 'inspector disabled' : false
};
Expand Down Expand Up @@ -57,14 +57,13 @@ describe('test runner coverage default exclusion', skipIfNoInspector, () => {
'--test-reporter=tap',
'--no-experimental-strip-types',
];
const result = spawnSync(process.execPath, args, {
spawnSyncAndAssert(process.execPath, args, {
env: { ...process.env, NODE_TEST_TMPDIR: tmpdir.path },
cwd: tmpdir.path
}, {
stderr: '',
stdout: new RegExp(RegExp.escape(report)),
});

assert.strictEqual(result.stderr.toString(), '');
assert(result.stdout.toString().includes(report));
assert.strictEqual(result.status, 0);
});

it('should exclude test files from coverage by default', async () => {
Expand All @@ -74,14 +73,13 @@ describe('test runner coverage default exclusion', skipIfNoInspector, () => {
'--experimental-test-coverage',
'--test-reporter=tap',
];
const result = spawnSync(process.execPath, args, {
spawnSyncAndAssert(process.execPath, args, {
env: { ...process.env, NODE_TEST_TMPDIR: tmpdir.path },
cwd: tmpdir.path
}, {
stderr: '',
stdout: assertDefaultExclusions,
});

assert.strictEqual(result.stderr.toString(), '');
assertDefaultExclusions(result.stdout.toString());
assert.strictEqual(result.status, 0);
});

it('should exclude ts test files', async () => {
Expand All @@ -91,14 +89,13 @@ describe('test runner coverage default exclusion', skipIfNoInspector, () => {
'--disable-warning=ExperimentalWarning',
'--test-reporter=tap',
];
const result = spawnSync(process.execPath, args, {
spawnSyncAndAssert(process.execPath, args, {
env: { ...process.env, NODE_TEST_TMPDIR: tmpdir.path },
cwd: tmpdir.path
}, {
stderr: '',
stdout: assertDefaultExclusions,
});

assert.strictEqual(result.stderr.toString(), '');
assertDefaultExclusions(result.stdout.toString());
assert.strictEqual(result.status, 0);
});

it('should exclude dotfile test files from coverage by default', async () => {
Expand All @@ -109,14 +106,15 @@ describe('test runner coverage default exclusion', skipIfNoInspector, () => {
'--test-reporter=tap',
'test/.dotfile.cjs',
];
const result = spawnSync(process.execPath, args, {
spawnSyncAndAssert(process.execPath, args, {
env: { ...process.env, NODE_TEST_TMPDIR: tmpdir.path },
cwd: tmpdir.path
}, {
stderr: '',
stdout(output) {
assertDefaultExclusions(output);
assert.doesNotMatch(output, /#\s+\.dotfile\.cjs\s+\|/);
},
});

assert.strictEqual(result.stderr.toString(), '');
assertDefaultExclusions(result.stdout.toString());
assert.doesNotMatch(result.stdout.toString(), /#\s+\.dotfile\.cjs\s+\|/);
assert.strictEqual(result.status, 0);
});
});
26 changes: 14 additions & 12 deletions 26 test/parallel/test-runner-coverage-thresholds.js
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
const common = require('../common');
const assert = require('node:assert');
const { spawnSync } = require('node:child_process');
const { spawnSyncAndExit } = require('../common/child_process');
const { readdirSync } = require('node:fs');
const { test } = require('node:test');
const fixtures = require('../common/fixtures');
Expand Down Expand Up @@ -172,23 +173,24 @@ for (const coverage of coverages) {
});

test(`test failing ${coverage.flag} with dot reporter`, () => {
const result = spawnSync(process.execPath, [
const { child } = spawnSyncAndExit(process.execPath, [
'--test',
'--experimental-test-coverage',
'--test-coverage-exclude=!test/**',
`${coverage.flag}=99`,
'--test-reporter', 'dot',
fixture,
]);

const stdout = result.stdout.toString();
assert.match(
stdout,
RegExp(`Error: ${coverage.actual.toFixed(2)}% ${coverage.name} coverage does not meet threshold of 99%`)
);
assert.match(stdout, /start of coverage report/);
assert.match(stdout, /end of coverage report/);
assert.strictEqual(result.status, 1);
assert(!findCoverageFileForPid(result.pid));
], {
status: 1,
stdout(output) {
assert.match(
output,
RegExp(`Error: ${coverage.actual.toFixed(2)}% ${coverage.name} coverage does not meet threshold of 99%`)
);
assert.match(output, /start of coverage report/);
assert.match(output, /end of coverage report/);
},
});
assert(!findCoverageFileForPid(child.pid));
});
}
5 changes: 2 additions & 3 deletions 5 test/pseudo-tty/test-set-raw-mode-modes.js
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
'use strict';
require('../common');
const assert = require('assert');
const { spawnSync } = require('child_process');
const { spawnSyncAndExitWithoutError } = require('../common/child_process');

function isOnlcrEnabled() {
const { stdout, stderr, status } = spawnSync('stty', ['-a'], {
const { child: { stdout } } = spawnSyncAndExitWithoutError('stty', ['-a'], {
encoding: 'utf8',
stdio: ['inherit', 'pipe', 'pipe'],
});

assert.strictEqual(status, 0, stderr);
return /(?:^|[\s;])onlcr(?:[\s;]|$)/.test(stdout);
}

Expand Down
Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.