Skip to content
Prev Previous commit
Next Next commit
try fully sequential
  • Loading branch information
MoLow committed Sep 8, 2022
commit 1da1d5ed1e0d5db12893946351246c4964fc61c9
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
'use strict';
const common = require('../common');
const tmpdir = require('../common/tmpdir.js');
const { NodeInstance } = require('../common/inspector-helper.js');
const assert = require('assert');
const { spawnSync } = require('child_process');
const { join } = require('path');
const fixtures = require('../common/fixtures');
const testFixtures = fixtures.path('test-runner');
import * as common from '../common/index.mjs';
import * as tmpdir from '../common/tmpdir.js';
import * as fixtures from '../common/fixtures.mjs';
import assert from 'node:assert';
import { NodeInstance } from '../common/inspector-helper.js';


common.skipIfInspectorDisabled();
tmpdir.refresh();

async function debugTest() {
const child = new NodeInstance(['--test', '--inspect-brk=0'], undefined, join(testFixtures, 'index.test.js'));
{
const child = new NodeInstance(['--test', '--inspect-brk=0'], undefined, fixtures.path('test-runner/index.test.js'));

let stdout = '';
let stderr = '';
Expand All @@ -23,46 +21,35 @@ async function debugTest() {

await session.send([
{ method: 'Runtime.enable' },
{ method: 'NodeRuntime.notifyWhenWaitingForDisconnect',
params: { enabled: true } },
{ method: 'Runtime.runIfWaitingForDebugger' }]);


await session.waitForNotification((notification) => {
return notification.method === 'NodeRuntime.waitingForDisconnect';
});

session.disconnect();
assert.match(stderr,
/Warning: Using the inspector with --test forces running at a concurrency of 1\. Use the inspectPort option to run with concurrency/);
}

debugTest().then(common.mustCall());


{
const args = ['--test', '--inspect=0', join(testFixtures, 'index.js')];
const child = spawnSync(process.execPath, args);
const args = ['--test', '--inspect=0', fixtures.path('test-runner/index.js')];
const { stderr, stdout, code, signal } = await common.spawnPromisified(process.execPath, args);

assert.match(child.stderr.toString(),
assert.match(stderr,
/Warning: Using the inspector with --test forces running at a concurrency of 1\. Use the inspectPort option to run with concurrency/);
const stdout = child.stdout.toString();
assert.match(stdout, /not ok 1 - .+index\.js/);
assert.match(stdout, /stderr: \|-\r?\n\s+Debugger listening on/);
assert.strictEqual(child.status, 1);
assert.strictEqual(child.signal, null);
assert.strictEqual(code, 1);
assert.strictEqual(signal, null);
}


{
// File not found.
const args = ['--test', '--inspect=0', 'a-random-file-that-does-not-exist.js'];
const child = spawnSync(process.execPath, args);
const { stderr, stdout, code, signal } = await common.spawnPromisified(process.execPath, args);

const stderr = child.stderr.toString();
assert.strictEqual(child.stdout.toString(), '');
assert.strictEqual(stdout, '');
assert.match(stderr, /^Could not find/);
assert.doesNotMatch(stderr, /Warning: Using the inspector with --test forces running at a concurrency of 1\. Use the inspectPort option to run with concurrency/);
assert.strictEqual(child.status, 1);
assert.strictEqual(child.signal, null);
assert.strictEqual(code, 1);
assert.strictEqual(signal, null);
}