mirror of
https://github.com/nodejs/node.git
synced 2025-05-10 11:50:36 +00:00

PR-URL: https://github.com/nodejs/node/pull/43549 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Nitzan Uziely <linkgoron@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
46 lines
1.5 KiB
JavaScript
46 lines
1.5 KiB
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const { spawnSync } = require('child_process');
|
|
const { setTimeout } = require('timers/promises');
|
|
|
|
if (process.argv[2] === 'child') {
|
|
const test = require('node:test');
|
|
|
|
if (process.argv[3] === 'pass') {
|
|
test('passing test', () => {
|
|
assert.strictEqual(true, true);
|
|
});
|
|
} else if (process.argv[3] === 'fail') {
|
|
assert.strictEqual(process.argv[3], 'fail');
|
|
test('failing test', () => {
|
|
assert.strictEqual(true, false);
|
|
});
|
|
} else if (process.argv[3] === 'never_ends') {
|
|
assert.strictEqual(process.argv[3], 'never_ends');
|
|
test('never ending test', () => {
|
|
return setTimeout(100_000_000);
|
|
});
|
|
process.kill(process.pid, 'SIGINT');
|
|
} else assert.fail('unreachable');
|
|
} else {
|
|
let child = spawnSync(process.execPath, [__filename, 'child', 'pass']);
|
|
assert.strictEqual(child.status, 0);
|
|
assert.strictEqual(child.signal, null);
|
|
|
|
child = spawnSync(process.execPath, [__filename, 'child', 'fail']);
|
|
assert.strictEqual(child.status, 1);
|
|
assert.strictEqual(child.signal, null);
|
|
|
|
child = spawnSync(process.execPath, [__filename, 'child', 'never_ends']);
|
|
assert.strictEqual(child.status, 1);
|
|
assert.strictEqual(child.signal, null);
|
|
if (common.isWindows) {
|
|
common.printSkipMessage('signals are not supported in windows');
|
|
} else {
|
|
const stdout = child.stdout.toString();
|
|
assert.match(stdout, /not ok 1 - never ending test/);
|
|
assert.match(stdout, /# cancelled 1/);
|
|
}
|
|
}
|