|
1 | 1 | 'use strict';
|
2 |
| -const common = require('../common'); |
3 |
| -const tmpdir = require('../common/tmpdir'); |
4 |
| -const { deepStrictEqual, strictEqual } = require('node:assert'); |
| 2 | +require('../common'); |
| 3 | +const fixtures = require('../common/fixtures'); |
| 4 | +const assert = require('node:assert'); |
5 | 5 | const { spawnSync } = require('node:child_process');
|
6 |
| -const { readdirSync, writeFileSync } = require('node:fs'); |
7 |
| -const { join } = require('node:path'); |
8 |
| -const { beforeEach, test } = require('node:test'); |
| 6 | +const { test } = require('node:test'); |
| 7 | +const cwd = fixtures.path('test-runner', 'default-behavior'); |
| 8 | +const env = { ...process.env, 'NODE_DEBUG': 'test_runner' }; |
9 | 9 |
|
10 |
| -function createTestFile(name) { |
11 |
| - writeFileSync(join(tmpdir.path, name), ` |
12 |
| - const fs = require('node:fs'); |
13 |
| -
|
14 |
| - fs.unlinkSync(__filename); |
15 |
| - setTimeout(() => {}, 1_000_000_000); |
16 |
| - `); |
17 |
| -} |
18 |
| - |
19 |
| -beforeEach(() => { |
20 |
| - tmpdir.refresh(); |
21 |
| - createTestFile('test-1.js'); |
22 |
| - createTestFile('test-2.js'); |
| 10 | +test('default concurrency', async () => { |
| 11 | + const args = ['--test']; |
| 12 | + const cp = spawnSync(process.execPath, args, { cwd, env }); |
| 13 | + assert.match(cp.stderr.toString(), /concurrency: true,/); |
23 | 14 | });
|
24 | 15 |
|
25 |
| -test('concurrency of one', () => { |
26 |
| - const cp = spawnSync(process.execPath, ['--test', '--test-concurrency=1'], { |
27 |
| - cwd: tmpdir.path, |
28 |
| - timeout: common.platformTimeout(1000), |
29 |
| - }); |
30 |
| - |
31 |
| - strictEqual(cp.stderr.toString(), ''); |
32 |
| - strictEqual(cp.error.code, 'ETIMEDOUT'); |
33 |
| - deepStrictEqual(readdirSync(tmpdir.path), ['test-2.js']); |
| 16 | +test('concurrency of one', async () => { |
| 17 | + const args = ['--test', '--test-concurrency=1']; |
| 18 | + const cp = spawnSync(process.execPath, args, { cwd, env }); |
| 19 | + assert.match(cp.stderr.toString(), /concurrency: 1,/); |
34 | 20 | });
|
35 | 21 |
|
36 |
| -test('concurrency of two', () => { |
37 |
| - const cp = spawnSync(process.execPath, ['--test', '--test-concurrency=2'], { |
38 |
| - cwd: tmpdir.path, |
39 |
| - timeout: common.platformTimeout(1000), |
40 |
| - }); |
41 |
| - |
42 |
| - strictEqual(cp.stderr.toString(), ''); |
43 |
| - strictEqual(cp.error.code, 'ETIMEDOUT'); |
44 |
| - deepStrictEqual(readdirSync(tmpdir.path), []); |
| 22 | +test('concurrency of two', async () => { |
| 23 | + const args = ['--test', '--test-concurrency=2']; |
| 24 | + const cp = spawnSync(process.execPath, args, { cwd, env }); |
| 25 | + assert.match(cp.stderr.toString(), /concurrency: 2,/); |
45 | 26 | });
|
0 commit comments