From 8c3dd7e9a84973055375ded18a5b5d6aed688697 Mon Sep 17 00:00:00 2001 From: Raz Luvaton <16746759+rluvaton@users.noreply.github.com> Date: Sat, 15 Jul 2023 23:55:51 +0300 Subject: [PATCH 1/8] test: reorder test files fixtures for better understanding --- .../index.test.js | 0 .../combined-stream-output/invalid-tap.js | 1 + .../{ => combined-stream-output}/nested.js | 0 .../index.test.js} | 0 .../default-behavior/node_modules/test-nm.js | 2 ++ .../default-behavior/random.test.mjs | 5 ++++ .../default-behavior/subdir/subdir_test.js | 0 .../default-behavior/test/random.cjs | 4 +++ .../test/skip_by_name.cjs | 0 test/fixtures/test-runner/index.js | 2 -- .../specific-test-files/failure.test.mjs | 5 ++++ .../specific-test-files/skip_by_name.cjs | 5 ++++ .../specific-test-files/success.cjs | 4 +++ .../specific-test-files/success.test.cjs | 4 +++ .../specific-test-files/throwing.js | 2 ++ test/parallel/test-runner-cli.js | 28 +++++++++--------- test/parallel/test-runner-inspect.mjs | 10 +++++-- test/parallel/test-runner-run.mjs | 29 ++++++++++++------- 18 files changed, 71 insertions(+), 30 deletions(-) rename test/fixtures/test-runner/{ => combined-stream-output}/index.test.js (100%) create mode 100644 test/fixtures/test-runner/combined-stream-output/invalid-tap.js rename test/fixtures/test-runner/{ => combined-stream-output}/nested.js (100%) rename test/fixtures/test-runner/{test/random.cjs => default-behavior/index.test.js} (100%) create mode 100644 test/fixtures/test-runner/default-behavior/node_modules/test-nm.js create mode 100644 test/fixtures/test-runner/default-behavior/random.test.mjs create mode 100644 test/fixtures/test-runner/default-behavior/subdir/subdir_test.js create mode 100644 test/fixtures/test-runner/default-behavior/test/random.cjs rename test/fixtures/test-runner/{ => default-behavior}/test/skip_by_name.cjs (100%) delete mode 100644 test/fixtures/test-runner/index.js create mode 100644 test/fixtures/test-runner/specific-test-files/failure.test.mjs create mode 100644 test/fixtures/test-runner/specific-test-files/skip_by_name.cjs create mode 100644 test/fixtures/test-runner/specific-test-files/success.cjs create mode 100644 test/fixtures/test-runner/specific-test-files/success.test.cjs create mode 100644 test/fixtures/test-runner/specific-test-files/throwing.js diff --git a/test/fixtures/test-runner/index.test.js b/test/fixtures/test-runner/combined-stream-output/index.test.js similarity index 100% rename from test/fixtures/test-runner/index.test.js rename to test/fixtures/test-runner/combined-stream-output/index.test.js diff --git a/test/fixtures/test-runner/combined-stream-output/invalid-tap.js b/test/fixtures/test-runner/combined-stream-output/invalid-tap.js new file mode 100644 index 00000000000000..d43fb8ad5cb374 --- /dev/null +++ b/test/fixtures/test-runner/combined-stream-output/invalid-tap.js @@ -0,0 +1 @@ +console.log('invalid tap output'); diff --git a/test/fixtures/test-runner/nested.js b/test/fixtures/test-runner/combined-stream-output/nested.js similarity index 100% rename from test/fixtures/test-runner/nested.js rename to test/fixtures/test-runner/combined-stream-output/nested.js diff --git a/test/fixtures/test-runner/test/random.cjs b/test/fixtures/test-runner/default-behavior/index.test.js similarity index 100% rename from test/fixtures/test-runner/test/random.cjs rename to test/fixtures/test-runner/default-behavior/index.test.js diff --git a/test/fixtures/test-runner/default-behavior/node_modules/test-nm.js b/test/fixtures/test-runner/default-behavior/node_modules/test-nm.js new file mode 100644 index 00000000000000..30024eab1f17e4 --- /dev/null +++ b/test/fixtures/test-runner/default-behavior/node_modules/test-nm.js @@ -0,0 +1,2 @@ +'use strict'; +throw new Error('thrown from node_modules'); diff --git a/test/fixtures/test-runner/default-behavior/random.test.mjs b/test/fixtures/test-runner/default-behavior/random.test.mjs new file mode 100644 index 00000000000000..a87a671d006ab6 --- /dev/null +++ b/test/fixtures/test-runner/default-behavior/random.test.mjs @@ -0,0 +1,5 @@ +import test from 'node:test'; + +test('this should fail', () => { + throw new Error('this is a failing test'); +}); diff --git a/test/fixtures/test-runner/default-behavior/subdir/subdir_test.js b/test/fixtures/test-runner/default-behavior/subdir/subdir_test.js new file mode 100644 index 00000000000000..e69de29bb2d1d6 diff --git a/test/fixtures/test-runner/default-behavior/test/random.cjs b/test/fixtures/test-runner/default-behavior/test/random.cjs new file mode 100644 index 00000000000000..2a722c504b9fa5 --- /dev/null +++ b/test/fixtures/test-runner/default-behavior/test/random.cjs @@ -0,0 +1,4 @@ +'use strict'; +const test = require('node:test'); + +test('this should pass'); diff --git a/test/fixtures/test-runner/test/skip_by_name.cjs b/test/fixtures/test-runner/default-behavior/test/skip_by_name.cjs similarity index 100% rename from test/fixtures/test-runner/test/skip_by_name.cjs rename to test/fixtures/test-runner/default-behavior/test/skip_by_name.cjs diff --git a/test/fixtures/test-runner/index.js b/test/fixtures/test-runner/index.js deleted file mode 100644 index fcf4b4d8eaa0ad..00000000000000 --- a/test/fixtures/test-runner/index.js +++ /dev/null @@ -1,2 +0,0 @@ -'use strict'; -throw new Error('thrown from index.js'); diff --git a/test/fixtures/test-runner/specific-test-files/failure.test.mjs b/test/fixtures/test-runner/specific-test-files/failure.test.mjs new file mode 100644 index 00000000000000..a87a671d006ab6 --- /dev/null +++ b/test/fixtures/test-runner/specific-test-files/failure.test.mjs @@ -0,0 +1,5 @@ +import test from 'node:test'; + +test('this should fail', () => { + throw new Error('this is a failing test'); +}); diff --git a/test/fixtures/test-runner/specific-test-files/skip_by_name.cjs b/test/fixtures/test-runner/specific-test-files/skip_by_name.cjs new file mode 100644 index 00000000000000..14856df43e50f5 --- /dev/null +++ b/test/fixtures/test-runner/specific-test-files/skip_by_name.cjs @@ -0,0 +1,5 @@ +'use strict'; +const test = require('node:test'); + +test('this should be skipped'); +test('this should be executed'); diff --git a/test/fixtures/test-runner/specific-test-files/success.cjs b/test/fixtures/test-runner/specific-test-files/success.cjs new file mode 100644 index 00000000000000..2a722c504b9fa5 --- /dev/null +++ b/test/fixtures/test-runner/specific-test-files/success.cjs @@ -0,0 +1,4 @@ +'use strict'; +const test = require('node:test'); + +test('this should pass'); diff --git a/test/fixtures/test-runner/specific-test-files/success.test.cjs b/test/fixtures/test-runner/specific-test-files/success.test.cjs new file mode 100644 index 00000000000000..2a722c504b9fa5 --- /dev/null +++ b/test/fixtures/test-runner/specific-test-files/success.test.cjs @@ -0,0 +1,4 @@ +'use strict'; +const test = require('node:test'); + +test('this should pass'); diff --git a/test/fixtures/test-runner/specific-test-files/throwing.js b/test/fixtures/test-runner/specific-test-files/throwing.js new file mode 100644 index 00000000000000..313259039afa34 --- /dev/null +++ b/test/fixtures/test-runner/specific-test-files/throwing.js @@ -0,0 +1,2 @@ +'use strict'; +throw new Error('thrown from throwing.js'); diff --git a/test/parallel/test-runner-cli.js b/test/parallel/test-runner-cli.js index c7fb6a0276aeb8..bb483f7d0b9698 100644 --- a/test/parallel/test-runner-cli.js +++ b/test/parallel/test-runner-cli.js @@ -22,7 +22,7 @@ const testFixtures = fixtures.path('test-runner'); // Default behavior. node_modules is ignored. Files that don't match the // pattern are ignored except in test/ directories. const args = ['--test']; - const child = spawnSync(process.execPath, args, { cwd: testFixtures }); + const child = spawnSync(process.execPath, args, { cwd: join(testFixtures, 'default-behavior') }); assert.strictEqual(child.status, 1); assert.strictEqual(child.signal, null); @@ -39,7 +39,7 @@ const testFixtures = fixtures.path('test-runner'); { // Same but with a prototype mutation in require scripts. const args = ['--require', join(testFixtures, 'protoMutation.js'), '--test']; - const child = spawnSync(process.execPath, args, { cwd: testFixtures }); + const child = spawnSync(process.execPath, args, { cwd: join(testFixtures, 'default-behavior') }); const stdout = child.stdout.toString(); assert.match(stdout, /ok 1 - this should pass/); @@ -55,14 +55,14 @@ const testFixtures = fixtures.path('test-runner'); { // User specified files that don't match the pattern are still run. - const args = ['--test', join(testFixtures, 'index.js')]; + const args = ['--test', join(testFixtures, 'specific-test-files/throwing.js')]; const child = spawnSync(process.execPath, args, { cwd: testFixtures }); assert.strictEqual(child.status, 1); assert.strictEqual(child.signal, null); assert.strictEqual(child.stderr.toString(), ''); const stdout = child.stdout.toString(); - assert.match(stdout, /not ok 1 - .+index\.js/); + assert.match(stdout, /not ok 1 - .+throwing\.js/); } { @@ -80,7 +80,7 @@ const testFixtures = fixtures.path('test-runner'); { // The current directory is used by default. const args = ['--test']; - const options = { cwd: testFixtures }; + const options = { cwd: join(testFixtures, 'default-behavior') }; const child = spawnSync(process.execPath, args, options); assert.strictEqual(child.status, 1); @@ -119,9 +119,9 @@ const testFixtures = fixtures.path('test-runner'); // Test combined stream outputs const args = [ '--test', - 'test/fixtures/test-runner/index.test.js', - 'test/fixtures/test-runner/nested.js', - 'test/fixtures/test-runner/invalid-tap.js', + 'test/fixtures/test-runner/combined-stream-output/index.test.js', + 'test/fixtures/test-runner/combined-stream-output/nested.js', + 'test/fixtures/test-runner/combined-stream-output/invalid-tap.js', ]; const child = spawnSync(process.execPath, args); @@ -197,7 +197,7 @@ const testFixtures = fixtures.path('test-runner'); const args = ['--no-warnings', '--experimental-loader', 'data:text/javascript,', '--require', fixtures.path('empty.js'), - '--test', join(testFixtures, 'index.test.js')]; + '--test', join(testFixtures, 'specific-test-files/success.cjs')]; const child = spawnSync(process.execPath, args); assert.strictEqual(child.stderr.toString(), ''); @@ -209,7 +209,7 @@ const testFixtures = fixtures.path('test-runner'); { // --test-shard option validation - const args = ['--test', '--test-shard=1', join(testFixtures, 'index.js')]; + const args = ['--test', '--test-shard=1', join(testFixtures, 'specific-test-files/success.cjs')]; const child = spawnSync(process.execPath, args, { cwd: testFixtures }); assert.strictEqual(child.status, 1); @@ -221,7 +221,7 @@ const testFixtures = fixtures.path('test-runner'); { // --test-shard option validation - const args = ['--test', '--test-shard=1/2/3', join(testFixtures, 'index.js')]; + const args = ['--test', '--test-shard=1/2/3', join(testFixtures, 'specific-test-files/success.cjs')]; const child = spawnSync(process.execPath, args, { cwd: testFixtures }); assert.strictEqual(child.status, 1); @@ -233,7 +233,7 @@ const testFixtures = fixtures.path('test-runner'); { // --test-shard option validation - const args = ['--test', '--test-shard=0/3', join(testFixtures, 'index.js')]; + const args = ['--test', '--test-shard=0/3', join(testFixtures, 'specific-test-files/success.cjs')]; const child = spawnSync(process.execPath, args, { cwd: testFixtures }); assert.strictEqual(child.status, 1); @@ -245,7 +245,7 @@ const testFixtures = fixtures.path('test-runner'); { // --test-shard option validation - const args = ['--test', '--test-shard=0xf/20abcd', join(testFixtures, 'index.js')]; + const args = ['--test', '--test-shard=0xf/20abcd', join(testFixtures, 'specific-test-files/success.cjs')]; const child = spawnSync(process.execPath, args, { cwd: testFixtures }); assert.strictEqual(child.status, 1); @@ -257,7 +257,7 @@ const testFixtures = fixtures.path('test-runner'); { // --test-shard option validation - const args = ['--test', '--test-shard=hello', join(testFixtures, 'index.js')]; + const args = ['--test', '--test-shard=hello', join(testFixtures, 'specific-test-files/success.cjs')]; const child = spawnSync(process.execPath, args, { cwd: testFixtures }); assert.strictEqual(child.status, 1); diff --git a/test/parallel/test-runner-inspect.mjs b/test/parallel/test-runner-inspect.mjs index bdff1ce7ceb84f..f8c915d1f42699 100644 --- a/test/parallel/test-runner-inspect.mjs +++ b/test/parallel/test-runner-inspect.mjs @@ -11,7 +11,11 @@ common.skipIfInspectorDisabled(); tmpdir.refresh(); { - const child = new NodeInstance(['--test', '--inspect-brk=0'], undefined, fixtures.path('test-runner/index.test.js')); + const child = new NodeInstance( + ['--test', '--inspect-brk=0'], + undefined, + fixtures.path('test-runner/specific-test-files/success.test.cjs') + ); let stdout = ''; let stderr = ''; @@ -31,12 +35,12 @@ tmpdir.refresh(); { - const args = ['--test', '--inspect=0', fixtures.path('test-runner/index.js')]; + const args = ['--test', '--inspect=0', fixtures.path('test-runner/specific-test-files/throwing.js')]; const { stderr, stdout, code, signal } = await common.spawnPromisified(process.execPath, args); assert.match(stderr, /Warning: Using the inspector with --test forces running at a concurrency of 1\. Use the inspectPort option to run with concurrency/); - assert.match(stdout, /not ok 1 - .+index\.js/); + assert.match(stdout, /not ok 1 - .+throwing\.js/); assert.strictEqual(code, 1); assert.strictEqual(signal, null); } diff --git a/test/parallel/test-runner-run.mjs b/test/parallel/test-runner-run.mjs index 7e4a8fbe76753a..e4b035636f43fd 100644 --- a/test/parallel/test-runner-run.mjs +++ b/test/parallel/test-runner-run.mjs @@ -26,7 +26,7 @@ describe('require(\'node:test\').run', { concurrency: true }, () => { }); it('should succeed with a file', async () => { - const stream = run({ files: [join(testFixtures, 'test/random.cjs')] }); + const stream = run({ files: [join(testFixtures, 'specific-test-files', 'success.cjs')] }); stream.on('test:fail', common.mustNotCall()); stream.on('test:pass', common.mustCall(1)); // eslint-disable-next-line no-unused-vars @@ -34,7 +34,8 @@ describe('require(\'node:test\').run', { concurrency: true }, () => { }); it('should run same file twice', async () => { - const stream = run({ files: [join(testFixtures, 'test/random.cjs'), join(testFixtures, 'test/random.cjs')] }); + const testFile = join(testFixtures, 'specific-test-files', 'success.cjs'); + const stream = run({ files: [testFile, testFile] }); stream.on('test:fail', common.mustNotCall()); stream.on('test:pass', common.mustCall(2)); // eslint-disable-next-line no-unused-vars @@ -68,7 +69,7 @@ describe('require(\'node:test\').run', { concurrency: true }, () => { }); it('should be piped with dot', async () => { - const result = await run({ files: [join(testFixtures, 'test/random.cjs')] }).compose(dot).toArray(); + const result = await run({ files: [join(testFixtures, 'specific-test-files/success.cjs')] }).compose(dot).toArray(); assert.deepStrictEqual(result, [ '.', '\n', @@ -77,7 +78,9 @@ describe('require(\'node:test\').run', { concurrency: true }, () => { it('should be piped with spec', async () => { const specReporter = new spec(); - const result = await run({ files: [join(testFixtures, 'test/random.cjs')] }).compose(specReporter).toArray(); + const result = await run({ + files: [join(testFixtures, 'specific-test-files/success.cjs')] + }).compose(specReporter).toArray(); const stringResults = result.map((bfr) => bfr.toString()); assert.match(stringResults[0], /this should pass/); assert.match(stringResults[1], /tests 1/); @@ -85,7 +88,7 @@ describe('require(\'node:test\').run', { concurrency: true }, () => { }); it('should be piped with tap', async () => { - const result = await run({ files: [join(testFixtures, 'test/random.cjs')] }).compose(tap).toArray(); + const result = await run({ files: [join(testFixtures, 'specific-test-files/success.cjs')] }).compose(tap).toArray(); assert.strictEqual(result.length, 13); assert.strictEqual(result[0], 'TAP version 13\n'); assert.strictEqual(result[1], '# Subtest: this should pass\n'); @@ -103,7 +106,7 @@ describe('require(\'node:test\').run', { concurrency: true }, () => { }); it('should skip tests not matching testNamePatterns - RegExp', async () => { - const result = await run({ files: [join(testFixtures, 'test/skip_by_name.cjs')], testNamePatterns: [/executed/] }) + const result = await run({ files: [join(testFixtures, 'specific-test-files/skip_by_name.cjs')], testNamePatterns: [/executed/] }) .compose(tap) .toArray(); assert.strictEqual(result[2], 'ok 1 - this should be skipped # SKIP test name does not match pattern\n'); @@ -111,7 +114,10 @@ describe('require(\'node:test\').run', { concurrency: true }, () => { }); it('should skip tests not matching testNamePatterns - string', async () => { - const result = await run({ files: [join(testFixtures, 'test/skip_by_name.cjs')], testNamePatterns: ['executed'] }) + const result = await run({ + files: [join(testFixtures, 'specific-test-files/skip_by_name.cjs')], + testNamePatterns: ['executed'] + }) .compose(tap) .toArray(); assert.strictEqual(result[2], 'ok 1 - this should be skipped # SKIP test name does not match pattern\n'); @@ -134,10 +140,11 @@ describe('require(\'node:test\').run', { concurrency: true }, () => { describe('AbortSignal', () => { it('should stop watch mode when abortSignal aborts', async () => { const controller = new AbortController(); - const result = await run({ - files: [join(testFixtures, 'test/random.cjs')], - watch: true, - signal: controller.signal, + const result = await run({ + files: [join(testFixtures, 'specific-test-files/success.cjs')], + watch: true, + signal: controller.signal + , }) .compose(async function* (source) { for await (const chunk of source) { From 55934189a6628e39811a05a72ef523072012acd4 Mon Sep 17 00:00:00 2001 From: Raz Luvaton <16746759+rluvaton@users.noreply.github.com> Date: Wed, 26 Jul 2023 01:31:57 +0300 Subject: [PATCH 2/8] format --- test/parallel/test-runner-run.mjs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/parallel/test-runner-run.mjs b/test/parallel/test-runner-run.mjs index e4b035636f43fd..75308f94500652 100644 --- a/test/parallel/test-runner-run.mjs +++ b/test/parallel/test-runner-run.mjs @@ -140,11 +140,11 @@ describe('require(\'node:test\').run', { concurrency: true }, () => { describe('AbortSignal', () => { it('should stop watch mode when abortSignal aborts', async () => { const controller = new AbortController(); - const result = await run({ - files: [join(testFixtures, 'specific-test-files/success.cjs')], - watch: true, - signal: controller.signal - , + const result = await run({ + files: [join(testFixtures, 'specific-test-files/success.cjs')], + watch: true, + signal: controller.signal + , }) .compose(async function* (source) { for await (const chunk of source) { From abfc4d88c48c96208025ef82a0504db1b6460343 Mon Sep 17 00:00:00 2001 From: Raz Luvaton <16746759+rluvaton@users.noreply.github.com> Date: Wed, 26 Jul 2023 11:24:00 +0300 Subject: [PATCH 3/8] revert --- .../combined-stream-output/invalid-tap.js | 1 - .../default-behavior/index.test.js | 4 --- .../default-behavior/node_modules/test-nm.js | 2 -- .../default-behavior/random.test.mjs | 5 ---- .../default-behavior/subdir/subdir_test.js | 0 test/fixtures/test-runner/index.js | 2 ++ .../index.test.js | 0 .../{combined-stream-output => }/nested.js | 0 .../specific-test-files/failure.test.mjs | 5 ---- .../specific-test-files/skip_by_name.cjs | 5 ---- .../specific-test-files/success.cjs | 4 --- .../specific-test-files/success.test.cjs | 4 --- .../specific-test-files/throwing.js | 2 -- .../{default-behavior => }/test/random.cjs | 0 .../test/skip_by_name.cjs | 0 test/parallel/test-runner-cli.js | 22 ++++++++-------- test/parallel/test-runner-inspect.mjs | 10 +++----- test/parallel/test-runner-run.mjs | 25 +++++++------------ 18 files changed, 25 insertions(+), 66 deletions(-) delete mode 100644 test/fixtures/test-runner/combined-stream-output/invalid-tap.js delete mode 100644 test/fixtures/test-runner/default-behavior/index.test.js delete mode 100644 test/fixtures/test-runner/default-behavior/node_modules/test-nm.js delete mode 100644 test/fixtures/test-runner/default-behavior/random.test.mjs delete mode 100644 test/fixtures/test-runner/default-behavior/subdir/subdir_test.js create mode 100644 test/fixtures/test-runner/index.js rename test/fixtures/test-runner/{combined-stream-output => }/index.test.js (100%) rename test/fixtures/test-runner/{combined-stream-output => }/nested.js (100%) delete mode 100644 test/fixtures/test-runner/specific-test-files/failure.test.mjs delete mode 100644 test/fixtures/test-runner/specific-test-files/skip_by_name.cjs delete mode 100644 test/fixtures/test-runner/specific-test-files/success.cjs delete mode 100644 test/fixtures/test-runner/specific-test-files/success.test.cjs delete mode 100644 test/fixtures/test-runner/specific-test-files/throwing.js rename test/fixtures/test-runner/{default-behavior => }/test/random.cjs (100%) rename test/fixtures/test-runner/{default-behavior => }/test/skip_by_name.cjs (100%) diff --git a/test/fixtures/test-runner/combined-stream-output/invalid-tap.js b/test/fixtures/test-runner/combined-stream-output/invalid-tap.js deleted file mode 100644 index d43fb8ad5cb374..00000000000000 --- a/test/fixtures/test-runner/combined-stream-output/invalid-tap.js +++ /dev/null @@ -1 +0,0 @@ -console.log('invalid tap output'); diff --git a/test/fixtures/test-runner/default-behavior/index.test.js b/test/fixtures/test-runner/default-behavior/index.test.js deleted file mode 100644 index 2a722c504b9fa5..00000000000000 --- a/test/fixtures/test-runner/default-behavior/index.test.js +++ /dev/null @@ -1,4 +0,0 @@ -'use strict'; -const test = require('node:test'); - -test('this should pass'); diff --git a/test/fixtures/test-runner/default-behavior/node_modules/test-nm.js b/test/fixtures/test-runner/default-behavior/node_modules/test-nm.js deleted file mode 100644 index 30024eab1f17e4..00000000000000 --- a/test/fixtures/test-runner/default-behavior/node_modules/test-nm.js +++ /dev/null @@ -1,2 +0,0 @@ -'use strict'; -throw new Error('thrown from node_modules'); diff --git a/test/fixtures/test-runner/default-behavior/random.test.mjs b/test/fixtures/test-runner/default-behavior/random.test.mjs deleted file mode 100644 index a87a671d006ab6..00000000000000 --- a/test/fixtures/test-runner/default-behavior/random.test.mjs +++ /dev/null @@ -1,5 +0,0 @@ -import test from 'node:test'; - -test('this should fail', () => { - throw new Error('this is a failing test'); -}); diff --git a/test/fixtures/test-runner/default-behavior/subdir/subdir_test.js b/test/fixtures/test-runner/default-behavior/subdir/subdir_test.js deleted file mode 100644 index e69de29bb2d1d6..00000000000000 diff --git a/test/fixtures/test-runner/index.js b/test/fixtures/test-runner/index.js new file mode 100644 index 00000000000000..fcf4b4d8eaa0ad --- /dev/null +++ b/test/fixtures/test-runner/index.js @@ -0,0 +1,2 @@ +'use strict'; +throw new Error('thrown from index.js'); diff --git a/test/fixtures/test-runner/combined-stream-output/index.test.js b/test/fixtures/test-runner/index.test.js similarity index 100% rename from test/fixtures/test-runner/combined-stream-output/index.test.js rename to test/fixtures/test-runner/index.test.js diff --git a/test/fixtures/test-runner/combined-stream-output/nested.js b/test/fixtures/test-runner/nested.js similarity index 100% rename from test/fixtures/test-runner/combined-stream-output/nested.js rename to test/fixtures/test-runner/nested.js diff --git a/test/fixtures/test-runner/specific-test-files/failure.test.mjs b/test/fixtures/test-runner/specific-test-files/failure.test.mjs deleted file mode 100644 index a87a671d006ab6..00000000000000 --- a/test/fixtures/test-runner/specific-test-files/failure.test.mjs +++ /dev/null @@ -1,5 +0,0 @@ -import test from 'node:test'; - -test('this should fail', () => { - throw new Error('this is a failing test'); -}); diff --git a/test/fixtures/test-runner/specific-test-files/skip_by_name.cjs b/test/fixtures/test-runner/specific-test-files/skip_by_name.cjs deleted file mode 100644 index 14856df43e50f5..00000000000000 --- a/test/fixtures/test-runner/specific-test-files/skip_by_name.cjs +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; -const test = require('node:test'); - -test('this should be skipped'); -test('this should be executed'); diff --git a/test/fixtures/test-runner/specific-test-files/success.cjs b/test/fixtures/test-runner/specific-test-files/success.cjs deleted file mode 100644 index 2a722c504b9fa5..00000000000000 --- a/test/fixtures/test-runner/specific-test-files/success.cjs +++ /dev/null @@ -1,4 +0,0 @@ -'use strict'; -const test = require('node:test'); - -test('this should pass'); diff --git a/test/fixtures/test-runner/specific-test-files/success.test.cjs b/test/fixtures/test-runner/specific-test-files/success.test.cjs deleted file mode 100644 index 2a722c504b9fa5..00000000000000 --- a/test/fixtures/test-runner/specific-test-files/success.test.cjs +++ /dev/null @@ -1,4 +0,0 @@ -'use strict'; -const test = require('node:test'); - -test('this should pass'); diff --git a/test/fixtures/test-runner/specific-test-files/throwing.js b/test/fixtures/test-runner/specific-test-files/throwing.js deleted file mode 100644 index 313259039afa34..00000000000000 --- a/test/fixtures/test-runner/specific-test-files/throwing.js +++ /dev/null @@ -1,2 +0,0 @@ -'use strict'; -throw new Error('thrown from throwing.js'); diff --git a/test/fixtures/test-runner/default-behavior/test/random.cjs b/test/fixtures/test-runner/test/random.cjs similarity index 100% rename from test/fixtures/test-runner/default-behavior/test/random.cjs rename to test/fixtures/test-runner/test/random.cjs diff --git a/test/fixtures/test-runner/default-behavior/test/skip_by_name.cjs b/test/fixtures/test-runner/test/skip_by_name.cjs similarity index 100% rename from test/fixtures/test-runner/default-behavior/test/skip_by_name.cjs rename to test/fixtures/test-runner/test/skip_by_name.cjs diff --git a/test/parallel/test-runner-cli.js b/test/parallel/test-runner-cli.js index bb483f7d0b9698..ec62a0dd2e047d 100644 --- a/test/parallel/test-runner-cli.js +++ b/test/parallel/test-runner-cli.js @@ -55,14 +55,14 @@ const testFixtures = fixtures.path('test-runner'); { // User specified files that don't match the pattern are still run. - const args = ['--test', join(testFixtures, 'specific-test-files/throwing.js')]; + const args = ['--test', join(testFixtures, 'default-behavior', 'index.js')]; const child = spawnSync(process.execPath, args, { cwd: testFixtures }); assert.strictEqual(child.status, 1); assert.strictEqual(child.signal, null); assert.strictEqual(child.stderr.toString(), ''); const stdout = child.stdout.toString(); - assert.match(stdout, /not ok 1 - .+throwing\.js/); + assert.match(stdout, /not ok 1 - .+index\.js/); } { @@ -119,9 +119,9 @@ const testFixtures = fixtures.path('test-runner'); // Test combined stream outputs const args = [ '--test', - 'test/fixtures/test-runner/combined-stream-output/index.test.js', - 'test/fixtures/test-runner/combined-stream-output/nested.js', - 'test/fixtures/test-runner/combined-stream-output/invalid-tap.js', + 'test/fixtures/test-runner/index.test.js', + 'test/fixtures/test-runner/nested.js', + 'test/fixtures/test-runner/invalid-tap.js', ]; const child = spawnSync(process.execPath, args); @@ -197,7 +197,7 @@ const testFixtures = fixtures.path('test-runner'); const args = ['--no-warnings', '--experimental-loader', 'data:text/javascript,', '--require', fixtures.path('empty.js'), - '--test', join(testFixtures, 'specific-test-files/success.cjs')]; + '--test', join(testFixtures, 'default-behavior', 'index.test.js')]; const child = spawnSync(process.execPath, args); assert.strictEqual(child.stderr.toString(), ''); @@ -209,7 +209,7 @@ const testFixtures = fixtures.path('test-runner'); { // --test-shard option validation - const args = ['--test', '--test-shard=1', join(testFixtures, 'specific-test-files/success.cjs')]; + const args = ['--test', '--test-shard=1', join(testFixtures, 'default-behavior', 'index.js')]; const child = spawnSync(process.execPath, args, { cwd: testFixtures }); assert.strictEqual(child.status, 1); @@ -221,7 +221,7 @@ const testFixtures = fixtures.path('test-runner'); { // --test-shard option validation - const args = ['--test', '--test-shard=1/2/3', join(testFixtures, 'specific-test-files/success.cjs')]; + const args = ['--test', '--test-shard=1/2/3', join(testFixtures, 'default-behavior', 'index.js')]; const child = spawnSync(process.execPath, args, { cwd: testFixtures }); assert.strictEqual(child.status, 1); @@ -233,7 +233,7 @@ const testFixtures = fixtures.path('test-runner'); { // --test-shard option validation - const args = ['--test', '--test-shard=0/3', join(testFixtures, 'specific-test-files/success.cjs')]; + const args = ['--test', '--test-shard=0/3', join(testFixtures, 'default-behavior', 'index.js')]; const child = spawnSync(process.execPath, args, { cwd: testFixtures }); assert.strictEqual(child.status, 1); @@ -245,7 +245,7 @@ const testFixtures = fixtures.path('test-runner'); { // --test-shard option validation - const args = ['--test', '--test-shard=0xf/20abcd', join(testFixtures, 'specific-test-files/success.cjs')]; + const args = ['--test', '--test-shard=0xf/20abcd', join(testFixtures, 'default-behavior', 'index.js')]; const child = spawnSync(process.execPath, args, { cwd: testFixtures }); assert.strictEqual(child.status, 1); @@ -257,7 +257,7 @@ const testFixtures = fixtures.path('test-runner'); { // --test-shard option validation - const args = ['--test', '--test-shard=hello', join(testFixtures, 'specific-test-files/success.cjs')]; + const args = ['--test', '--test-shard=hello', join(testFixtures, 'default-behavior', 'index.js')]; const child = spawnSync(process.execPath, args, { cwd: testFixtures }); assert.strictEqual(child.status, 1); diff --git a/test/parallel/test-runner-inspect.mjs b/test/parallel/test-runner-inspect.mjs index f8c915d1f42699..e2bc0ceb735294 100644 --- a/test/parallel/test-runner-inspect.mjs +++ b/test/parallel/test-runner-inspect.mjs @@ -11,11 +11,7 @@ common.skipIfInspectorDisabled(); tmpdir.refresh(); { - const child = new NodeInstance( - ['--test', '--inspect-brk=0'], - undefined, - fixtures.path('test-runner/specific-test-files/success.test.cjs') - ); + const child = new NodeInstance(['--test', '--inspect-brk=0'], undefined, fixtures.path('test-runner/default-behavior/index.test.js')); let stdout = ''; let stderr = ''; @@ -35,12 +31,12 @@ tmpdir.refresh(); { - const args = ['--test', '--inspect=0', fixtures.path('test-runner/specific-test-files/throwing.js')]; + const args = ['--test', '--inspect=0', fixtures.path('test-runner/default-behavior/index.js')]; const { stderr, stdout, code, signal } = await common.spawnPromisified(process.execPath, args); assert.match(stderr, /Warning: Using the inspector with --test forces running at a concurrency of 1\. Use the inspectPort option to run with concurrency/); - assert.match(stdout, /not ok 1 - .+throwing\.js/); + assert.match(stdout, /not ok 1 - .+index\.js/); assert.strictEqual(code, 1); assert.strictEqual(signal, null); } diff --git a/test/parallel/test-runner-run.mjs b/test/parallel/test-runner-run.mjs index 75308f94500652..620facccb2d4ae 100644 --- a/test/parallel/test-runner-run.mjs +++ b/test/parallel/test-runner-run.mjs @@ -26,7 +26,7 @@ describe('require(\'node:test\').run', { concurrency: true }, () => { }); it('should succeed with a file', async () => { - const stream = run({ files: [join(testFixtures, 'specific-test-files', 'success.cjs')] }); + const stream = run({ files: [join(testFixtures, 'test/default-behavior/random.cjs')] }); stream.on('test:fail', common.mustNotCall()); stream.on('test:pass', common.mustCall(1)); // eslint-disable-next-line no-unused-vars @@ -34,8 +34,7 @@ describe('require(\'node:test\').run', { concurrency: true }, () => { }); it('should run same file twice', async () => { - const testFile = join(testFixtures, 'specific-test-files', 'success.cjs'); - const stream = run({ files: [testFile, testFile] }); + const stream = run({ files: [join(testFixtures, 'test/default-behavior/random.cjs'), join(testFixtures, 'test/default-behavior/random.cjs')] }); stream.on('test:fail', common.mustNotCall()); stream.on('test:pass', common.mustCall(2)); // eslint-disable-next-line no-unused-vars @@ -69,7 +68,7 @@ describe('require(\'node:test\').run', { concurrency: true }, () => { }); it('should be piped with dot', async () => { - const result = await run({ files: [join(testFixtures, 'specific-test-files/success.cjs')] }).compose(dot).toArray(); + const result = await run({ files: [join(testFixtures, 'test/default-behavior/random.cjs')] }).compose(dot).toArray(); assert.deepStrictEqual(result, [ '.', '\n', @@ -78,9 +77,7 @@ describe('require(\'node:test\').run', { concurrency: true }, () => { it('should be piped with spec', async () => { const specReporter = new spec(); - const result = await run({ - files: [join(testFixtures, 'specific-test-files/success.cjs')] - }).compose(specReporter).toArray(); + const result = await run({ files: [join(testFixtures, 'test/default-behavior/random.cjs')] }).compose(specReporter).toArray(); const stringResults = result.map((bfr) => bfr.toString()); assert.match(stringResults[0], /this should pass/); assert.match(stringResults[1], /tests 1/); @@ -88,7 +85,7 @@ describe('require(\'node:test\').run', { concurrency: true }, () => { }); it('should be piped with tap', async () => { - const result = await run({ files: [join(testFixtures, 'specific-test-files/success.cjs')] }).compose(tap).toArray(); + const result = await run({ files: [join(testFixtures, 'test/default-behavior/random.cjs')] }).compose(tap).toArray(); assert.strictEqual(result.length, 13); assert.strictEqual(result[0], 'TAP version 13\n'); assert.strictEqual(result[1], '# Subtest: this should pass\n'); @@ -106,7 +103,7 @@ describe('require(\'node:test\').run', { concurrency: true }, () => { }); it('should skip tests not matching testNamePatterns - RegExp', async () => { - const result = await run({ files: [join(testFixtures, 'specific-test-files/skip_by_name.cjs')], testNamePatterns: [/executed/] }) + const result = await run({ files: [join(testFixtures, 'test/skip_by_name.cjs')], testNamePatterns: [/executed/] }) .compose(tap) .toArray(); assert.strictEqual(result[2], 'ok 1 - this should be skipped # SKIP test name does not match pattern\n'); @@ -114,10 +111,7 @@ describe('require(\'node:test\').run', { concurrency: true }, () => { }); it('should skip tests not matching testNamePatterns - string', async () => { - const result = await run({ - files: [join(testFixtures, 'specific-test-files/skip_by_name.cjs')], - testNamePatterns: ['executed'] - }) + const result = await run({ files: [join(testFixtures, 'test/skip_by_name.cjs')], testNamePatterns: ['executed'] }) .compose(tap) .toArray(); assert.strictEqual(result[2], 'ok 1 - this should be skipped # SKIP test name does not match pattern\n'); @@ -141,10 +135,9 @@ describe('require(\'node:test\').run', { concurrency: true }, () => { it('should stop watch mode when abortSignal aborts', async () => { const controller = new AbortController(); const result = await run({ - files: [join(testFixtures, 'specific-test-files/success.cjs')], + files: [join(testFixtures, 'test/default-behavior/random.cjs')], watch: true, - signal: controller.signal - , + signal: controller.signal, }) .compose(async function* (source) { for await (const chunk of source) { From 34b6eff2378dc2e478606a3a607311c61bf37baf Mon Sep 17 00:00:00 2001 From: Raz Luvaton <16746759+rluvaton@users.noreply.github.com> Date: Wed, 26 Jul 2023 11:36:28 +0300 Subject: [PATCH 4/8] only reorder files --- .../{ => default-behavior}/index.test.js | 0 .../{ => default-behavior}/random.test.mjs | 0 .../subdir/subdir_test.js | 0 .../{ => default-behavior}/test/random.cjs | 0 .../test/skip_by_name.cjs | 0 test/parallel/test-runner-cli.js | 14 +++++++------- test/parallel/test-runner-exit-code.js | 2 +- test/parallel/test-runner-inspect.mjs | 2 +- test/parallel/test-runner-run.mjs | 18 +++++++++--------- 9 files changed, 18 insertions(+), 18 deletions(-) rename test/fixtures/test-runner/{ => default-behavior}/index.test.js (100%) rename test/fixtures/test-runner/{ => default-behavior}/random.test.mjs (100%) rename test/fixtures/test-runner/{ => default-behavior}/subdir/subdir_test.js (100%) rename test/fixtures/test-runner/{ => default-behavior}/test/random.cjs (100%) rename test/fixtures/test-runner/{ => default-behavior}/test/skip_by_name.cjs (100%) diff --git a/test/fixtures/test-runner/index.test.js b/test/fixtures/test-runner/default-behavior/index.test.js similarity index 100% rename from test/fixtures/test-runner/index.test.js rename to test/fixtures/test-runner/default-behavior/index.test.js diff --git a/test/fixtures/test-runner/random.test.mjs b/test/fixtures/test-runner/default-behavior/random.test.mjs similarity index 100% rename from test/fixtures/test-runner/random.test.mjs rename to test/fixtures/test-runner/default-behavior/random.test.mjs diff --git a/test/fixtures/test-runner/subdir/subdir_test.js b/test/fixtures/test-runner/default-behavior/subdir/subdir_test.js similarity index 100% rename from test/fixtures/test-runner/subdir/subdir_test.js rename to test/fixtures/test-runner/default-behavior/subdir/subdir_test.js diff --git a/test/fixtures/test-runner/test/random.cjs b/test/fixtures/test-runner/default-behavior/test/random.cjs similarity index 100% rename from test/fixtures/test-runner/test/random.cjs rename to test/fixtures/test-runner/default-behavior/test/random.cjs diff --git a/test/fixtures/test-runner/test/skip_by_name.cjs b/test/fixtures/test-runner/default-behavior/test/skip_by_name.cjs similarity index 100% rename from test/fixtures/test-runner/test/skip_by_name.cjs rename to test/fixtures/test-runner/default-behavior/test/skip_by_name.cjs diff --git a/test/parallel/test-runner-cli.js b/test/parallel/test-runner-cli.js index ec62a0dd2e047d..3edd1a0cf9ab4f 100644 --- a/test/parallel/test-runner-cli.js +++ b/test/parallel/test-runner-cli.js @@ -55,7 +55,7 @@ const testFixtures = fixtures.path('test-runner'); { // User specified files that don't match the pattern are still run. - const args = ['--test', join(testFixtures, 'default-behavior', 'index.js')]; + const args = ['--test', join(testFixtures, 'index.js')]; const child = spawnSync(process.execPath, args, { cwd: testFixtures }); assert.strictEqual(child.status, 1); @@ -119,7 +119,7 @@ const testFixtures = fixtures.path('test-runner'); // Test combined stream outputs const args = [ '--test', - 'test/fixtures/test-runner/index.test.js', + 'test/fixtures/test-runner/default-behavior/index.test.js', 'test/fixtures/test-runner/nested.js', 'test/fixtures/test-runner/invalid-tap.js', ]; @@ -209,7 +209,7 @@ const testFixtures = fixtures.path('test-runner'); { // --test-shard option validation - const args = ['--test', '--test-shard=1', join(testFixtures, 'default-behavior', 'index.js')]; + const args = ['--test', '--test-shard=1', join(testFixtures, 'index.js')]; const child = spawnSync(process.execPath, args, { cwd: testFixtures }); assert.strictEqual(child.status, 1); @@ -221,7 +221,7 @@ const testFixtures = fixtures.path('test-runner'); { // --test-shard option validation - const args = ['--test', '--test-shard=1/2/3', join(testFixtures, 'default-behavior', 'index.js')]; + const args = ['--test', '--test-shard=1/2/3', join(testFixtures, 'index.js')]; const child = spawnSync(process.execPath, args, { cwd: testFixtures }); assert.strictEqual(child.status, 1); @@ -233,7 +233,7 @@ const testFixtures = fixtures.path('test-runner'); { // --test-shard option validation - const args = ['--test', '--test-shard=0/3', join(testFixtures, 'default-behavior', 'index.js')]; + const args = ['--test', '--test-shard=0/3', join(testFixtures, 'index.js')]; const child = spawnSync(process.execPath, args, { cwd: testFixtures }); assert.strictEqual(child.status, 1); @@ -245,7 +245,7 @@ const testFixtures = fixtures.path('test-runner'); { // --test-shard option validation - const args = ['--test', '--test-shard=0xf/20abcd', join(testFixtures, 'default-behavior', 'index.js')]; + const args = ['--test', '--test-shard=0xf/20abcd', join(testFixtures, 'index.js')]; const child = spawnSync(process.execPath, args, { cwd: testFixtures }); assert.strictEqual(child.status, 1); @@ -257,7 +257,7 @@ const testFixtures = fixtures.path('test-runner'); { // --test-shard option validation - const args = ['--test', '--test-shard=hello', join(testFixtures, 'default-behavior', 'index.js')]; + const args = ['--test', '--test-shard=hello', join(testFixtures, 'index.js')]; const child = spawnSync(process.execPath, args, { cwd: testFixtures }); assert.strictEqual(child.status, 1); diff --git a/test/parallel/test-runner-exit-code.js b/test/parallel/test-runner-exit-code.js index d177ec438bdd45..51622c322a1563 100644 --- a/test/parallel/test-runner-exit-code.js +++ b/test/parallel/test-runner-exit-code.js @@ -43,7 +43,7 @@ if (process.argv[2] === 'child') { assert.strictEqual(child.status, 0); assert.strictEqual(child.signal, null); - child = spawnSync(process.execPath, ['--test', fixtures.path('test-runner', 'subdir', 'subdir_test.js')]); + child = spawnSync(process.execPath, ['--test', fixtures.path('test-runner', 'default-behavior', 'subdir', 'subdir_test.js')]); assert.strictEqual(child.status, 0); assert.strictEqual(child.signal, null); diff --git a/test/parallel/test-runner-inspect.mjs b/test/parallel/test-runner-inspect.mjs index e2bc0ceb735294..97bbe1164a0e01 100644 --- a/test/parallel/test-runner-inspect.mjs +++ b/test/parallel/test-runner-inspect.mjs @@ -31,7 +31,7 @@ tmpdir.refresh(); { - const args = ['--test', '--inspect=0', fixtures.path('test-runner/default-behavior/index.js')]; + const args = ['--test', '--inspect=0', fixtures.path('test-runner/index.js')]; const { stderr, stdout, code, signal } = await common.spawnPromisified(process.execPath, args); assert.match(stderr, diff --git a/test/parallel/test-runner-run.mjs b/test/parallel/test-runner-run.mjs index 620facccb2d4ae..e264b42e310c1d 100644 --- a/test/parallel/test-runner-run.mjs +++ b/test/parallel/test-runner-run.mjs @@ -26,7 +26,7 @@ describe('require(\'node:test\').run', { concurrency: true }, () => { }); it('should succeed with a file', async () => { - const stream = run({ files: [join(testFixtures, 'test/default-behavior/random.cjs')] }); + const stream = run({ files: [join(testFixtures, 'default-behavior/test/random.cjs')] }); stream.on('test:fail', common.mustNotCall()); stream.on('test:pass', common.mustCall(1)); // eslint-disable-next-line no-unused-vars @@ -34,7 +34,7 @@ describe('require(\'node:test\').run', { concurrency: true }, () => { }); it('should run same file twice', async () => { - const stream = run({ files: [join(testFixtures, 'test/default-behavior/random.cjs'), join(testFixtures, 'test/default-behavior/random.cjs')] }); + const stream = run({ files: [join(testFixtures, 'default-behavior/test/random.cjs'), join(testFixtures, 'default-behavior/test/random.cjs')] }); stream.on('test:fail', common.mustNotCall()); stream.on('test:pass', common.mustCall(2)); // eslint-disable-next-line no-unused-vars @@ -68,7 +68,7 @@ describe('require(\'node:test\').run', { concurrency: true }, () => { }); it('should be piped with dot', async () => { - const result = await run({ files: [join(testFixtures, 'test/default-behavior/random.cjs')] }).compose(dot).toArray(); + const result = await run({ files: [join(testFixtures, 'default-behavior/test/random.cjs')] }).compose(dot).toArray(); assert.deepStrictEqual(result, [ '.', '\n', @@ -77,7 +77,7 @@ describe('require(\'node:test\').run', { concurrency: true }, () => { it('should be piped with spec', async () => { const specReporter = new spec(); - const result = await run({ files: [join(testFixtures, 'test/default-behavior/random.cjs')] }).compose(specReporter).toArray(); + const result = await run({ files: [join(testFixtures, 'default-behavior/test/random.cjs')] }).compose(specReporter).toArray(); const stringResults = result.map((bfr) => bfr.toString()); assert.match(stringResults[0], /this should pass/); assert.match(stringResults[1], /tests 1/); @@ -85,7 +85,7 @@ describe('require(\'node:test\').run', { concurrency: true }, () => { }); it('should be piped with tap', async () => { - const result = await run({ files: [join(testFixtures, 'test/default-behavior/random.cjs')] }).compose(tap).toArray(); + const result = await run({ files: [join(testFixtures, 'default-behavior/test/random.cjs')] }).compose(tap).toArray(); assert.strictEqual(result.length, 13); assert.strictEqual(result[0], 'TAP version 13\n'); assert.strictEqual(result[1], '# Subtest: this should pass\n'); @@ -103,7 +103,7 @@ describe('require(\'node:test\').run', { concurrency: true }, () => { }); it('should skip tests not matching testNamePatterns - RegExp', async () => { - const result = await run({ files: [join(testFixtures, 'test/skip_by_name.cjs')], testNamePatterns: [/executed/] }) + const result = await run({ files: [join(testFixtures, 'default-behavior/test/skip_by_name.cjs')], testNamePatterns: [/executed/] }) .compose(tap) .toArray(); assert.strictEqual(result[2], 'ok 1 - this should be skipped # SKIP test name does not match pattern\n'); @@ -111,7 +111,7 @@ describe('require(\'node:test\').run', { concurrency: true }, () => { }); it('should skip tests not matching testNamePatterns - string', async () => { - const result = await run({ files: [join(testFixtures, 'test/skip_by_name.cjs')], testNamePatterns: ['executed'] }) + const result = await run({ files: [join(testFixtures, 'default-behavior/test/skip_by_name.cjs')], testNamePatterns: ['executed'] }) .compose(tap) .toArray(); assert.strictEqual(result[2], 'ok 1 - this should be skipped # SKIP test name does not match pattern\n'); @@ -121,7 +121,7 @@ describe('require(\'node:test\').run', { concurrency: true }, () => { it('should emit "test:watch:drained" event on watch mode', async () => { const controller = new AbortController(); await run({ - files: [join(testFixtures, 'test/random.cjs')], + files: [join(testFixtures, 'default-behavior/test/random.cjs')], watch: true, signal: controller.signal, }).on('data', function({ type }) { @@ -135,7 +135,7 @@ describe('require(\'node:test\').run', { concurrency: true }, () => { it('should stop watch mode when abortSignal aborts', async () => { const controller = new AbortController(); const result = await run({ - files: [join(testFixtures, 'test/default-behavior/random.cjs')], + files: [join(testFixtures, 'default-behavior/test/random.cjs')], watch: true, signal: controller.signal, }) From c434e53ba8e59fc03caead120446a0993ef8fbec Mon Sep 17 00:00:00 2001 From: Raz Luvaton <16746759+rluvaton@users.noreply.github.com> Date: Wed, 26 Jul 2023 11:38:20 +0300 Subject: [PATCH 5/8] only reorder files --- .../{ => default-behavior}/node_modules/reporter-cjs/index.js | 0 .../node_modules/reporter-cjs/package.json | 0 .../{ => default-behavior}/node_modules/reporter-esm/index.mjs | 0 .../node_modules/reporter-esm/package.json | 0 .../test-runner/{ => default-behavior}/node_modules/test-nm.js | 0 test/parallel/test-runner-cli.js | 2 +- 6 files changed, 1 insertion(+), 1 deletion(-) rename test/fixtures/test-runner/{ => default-behavior}/node_modules/reporter-cjs/index.js (100%) rename test/fixtures/test-runner/{ => default-behavior}/node_modules/reporter-cjs/package.json (100%) rename test/fixtures/test-runner/{ => default-behavior}/node_modules/reporter-esm/index.mjs (100%) rename test/fixtures/test-runner/{ => default-behavior}/node_modules/reporter-esm/package.json (100%) rename test/fixtures/test-runner/{ => default-behavior}/node_modules/test-nm.js (100%) diff --git a/test/fixtures/test-runner/node_modules/reporter-cjs/index.js b/test/fixtures/test-runner/default-behavior/node_modules/reporter-cjs/index.js similarity index 100% rename from test/fixtures/test-runner/node_modules/reporter-cjs/index.js rename to test/fixtures/test-runner/default-behavior/node_modules/reporter-cjs/index.js diff --git a/test/fixtures/test-runner/node_modules/reporter-cjs/package.json b/test/fixtures/test-runner/default-behavior/node_modules/reporter-cjs/package.json similarity index 100% rename from test/fixtures/test-runner/node_modules/reporter-cjs/package.json rename to test/fixtures/test-runner/default-behavior/node_modules/reporter-cjs/package.json diff --git a/test/fixtures/test-runner/node_modules/reporter-esm/index.mjs b/test/fixtures/test-runner/default-behavior/node_modules/reporter-esm/index.mjs similarity index 100% rename from test/fixtures/test-runner/node_modules/reporter-esm/index.mjs rename to test/fixtures/test-runner/default-behavior/node_modules/reporter-esm/index.mjs diff --git a/test/fixtures/test-runner/node_modules/reporter-esm/package.json b/test/fixtures/test-runner/default-behavior/node_modules/reporter-esm/package.json similarity index 100% rename from test/fixtures/test-runner/node_modules/reporter-esm/package.json rename to test/fixtures/test-runner/default-behavior/node_modules/reporter-esm/package.json diff --git a/test/fixtures/test-runner/node_modules/test-nm.js b/test/fixtures/test-runner/default-behavior/node_modules/test-nm.js similarity index 100% rename from test/fixtures/test-runner/node_modules/test-nm.js rename to test/fixtures/test-runner/default-behavior/node_modules/test-nm.js diff --git a/test/parallel/test-runner-cli.js b/test/parallel/test-runner-cli.js index 3edd1a0cf9ab4f..34ce67caa5e6a5 100644 --- a/test/parallel/test-runner-cli.js +++ b/test/parallel/test-runner-cli.js @@ -67,7 +67,7 @@ const testFixtures = fixtures.path('test-runner'); { // Searches node_modules if specified. - const args = ['--test', join(testFixtures, 'node_modules/*.js')]; + const args = ['--test', join(testFixtures, 'default-behavior/node_modules/*.js')]; const child = spawnSync(process.execPath, args); assert.strictEqual(child.status, 1); From eb9795eb612cd9ad6630f70a3c283709c15d1198 Mon Sep 17 00:00:00 2001 From: Raz Luvaton <16746759+rluvaton@users.noreply.github.com> Date: Wed, 26 Jul 2023 11:57:30 +0300 Subject: [PATCH 6/8] eslint --- test/parallel/test-runner-exit-code.js | 5 ++++- test/parallel/test-runner-inspect.mjs | 6 +++++- test/parallel/test-runner-run.mjs | 29 ++++++++++++++++++++------ 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/test/parallel/test-runner-exit-code.js b/test/parallel/test-runner-exit-code.js index 51622c322a1563..8eeebc21d31753 100644 --- a/test/parallel/test-runner-exit-code.js +++ b/test/parallel/test-runner-exit-code.js @@ -43,7 +43,10 @@ if (process.argv[2] === 'child') { assert.strictEqual(child.status, 0); assert.strictEqual(child.signal, null); - child = spawnSync(process.execPath, ['--test', fixtures.path('test-runner', 'default-behavior', 'subdir', 'subdir_test.js')]); + child = spawnSync(process.execPath, [ + '--test', + fixtures.path('test-runner', 'default-behavior', 'subdir', 'subdir_test.js'), + ]); assert.strictEqual(child.status, 0); assert.strictEqual(child.signal, null); diff --git a/test/parallel/test-runner-inspect.mjs b/test/parallel/test-runner-inspect.mjs index 97bbe1164a0e01..20c4cdf354451b 100644 --- a/test/parallel/test-runner-inspect.mjs +++ b/test/parallel/test-runner-inspect.mjs @@ -11,7 +11,11 @@ common.skipIfInspectorDisabled(); tmpdir.refresh(); { - const child = new NodeInstance(['--test', '--inspect-brk=0'], undefined, fixtures.path('test-runner/default-behavior/index.test.js')); + const child = new NodeInstance( + ['--test', '--inspect-brk=0'], + undefined, + fixtures.path('test-runner/default-behavior/index.test.js') + ); let stdout = ''; let stderr = ''; diff --git a/test/parallel/test-runner-run.mjs b/test/parallel/test-runner-run.mjs index e264b42e310c1d..62fab0af146f4d 100644 --- a/test/parallel/test-runner-run.mjs +++ b/test/parallel/test-runner-run.mjs @@ -34,7 +34,12 @@ describe('require(\'node:test\').run', { concurrency: true }, () => { }); it('should run same file twice', async () => { - const stream = run({ files: [join(testFixtures, 'default-behavior/test/random.cjs'), join(testFixtures, 'default-behavior/test/random.cjs')] }); + const stream = run({ + files: [ + join(testFixtures, 'default-behavior/test/random.cjs'), + join(testFixtures, 'default-behavior/test/random.cjs'), + ] + }); stream.on('test:fail', common.mustNotCall()); stream.on('test:pass', common.mustCall(2)); // eslint-disable-next-line no-unused-vars @@ -68,7 +73,9 @@ describe('require(\'node:test\').run', { concurrency: true }, () => { }); it('should be piped with dot', async () => { - const result = await run({ files: [join(testFixtures, 'default-behavior/test/random.cjs')] }).compose(dot).toArray(); + const result = await run({ + files: [join(testFixtures, 'default-behavior/test/random.cjs')] + }).compose(dot).toArray(); assert.deepStrictEqual(result, [ '.', '\n', @@ -77,7 +84,9 @@ describe('require(\'node:test\').run', { concurrency: true }, () => { it('should be piped with spec', async () => { const specReporter = new spec(); - const result = await run({ files: [join(testFixtures, 'default-behavior/test/random.cjs')] }).compose(specReporter).toArray(); + const result = await run({ + files: [join(testFixtures, 'default-behavior/test/random.cjs')] + }).compose(specReporter).toArray(); const stringResults = result.map((bfr) => bfr.toString()); assert.match(stringResults[0], /this should pass/); assert.match(stringResults[1], /tests 1/); @@ -85,7 +94,9 @@ describe('require(\'node:test\').run', { concurrency: true }, () => { }); it('should be piped with tap', async () => { - const result = await run({ files: [join(testFixtures, 'default-behavior/test/random.cjs')] }).compose(tap).toArray(); + const result = await run({ + files: [join(testFixtures, 'default-behavior/test/random.cjs')] + }).compose(tap).toArray(); assert.strictEqual(result.length, 13); assert.strictEqual(result[0], 'TAP version 13\n'); assert.strictEqual(result[1], '# Subtest: this should pass\n'); @@ -103,7 +114,10 @@ describe('require(\'node:test\').run', { concurrency: true }, () => { }); it('should skip tests not matching testNamePatterns - RegExp', async () => { - const result = await run({ files: [join(testFixtures, 'default-behavior/test/skip_by_name.cjs')], testNamePatterns: [/executed/] }) + const result = await run({ + files: [join(testFixtures, 'default-behavior/test/skip_by_name.cjs')], + testNamePatterns: [/executed/] + }) .compose(tap) .toArray(); assert.strictEqual(result[2], 'ok 1 - this should be skipped # SKIP test name does not match pattern\n'); @@ -111,7 +125,10 @@ describe('require(\'node:test\').run', { concurrency: true }, () => { }); it('should skip tests not matching testNamePatterns - string', async () => { - const result = await run({ files: [join(testFixtures, 'default-behavior/test/skip_by_name.cjs')], testNamePatterns: ['executed'] }) + const result = await run({ + files: [join(testFixtures, 'default-behavior/test/skip_by_name.cjs')], + testNamePatterns: ['executed'] + }) .compose(tap) .toArray(); assert.strictEqual(result[2], 'ok 1 - this should be skipped # SKIP test name does not match pattern\n'); From 00a53bec99af11b33a2e1ed51c948bb8a1b2ef03 Mon Sep 17 00:00:00 2001 From: Raz Luvaton <16746759+rluvaton@users.noreply.github.com> Date: Wed, 26 Jul 2023 14:47:40 +0300 Subject: [PATCH 7/8] move the reporters --- .../{default-behavior => }/node_modules/reporter-cjs/index.js | 0 .../node_modules/reporter-cjs/package.json | 0 .../{default-behavior => }/node_modules/reporter-esm/index.mjs | 0 .../node_modules/reporter-esm/package.json | 0 test/fixtures/test-runner/node_modules/test-nm.js | 2 ++ 5 files changed, 2 insertions(+) rename test/fixtures/test-runner/{default-behavior => }/node_modules/reporter-cjs/index.js (100%) rename test/fixtures/test-runner/{default-behavior => }/node_modules/reporter-cjs/package.json (100%) rename test/fixtures/test-runner/{default-behavior => }/node_modules/reporter-esm/index.mjs (100%) rename test/fixtures/test-runner/{default-behavior => }/node_modules/reporter-esm/package.json (100%) create mode 100644 test/fixtures/test-runner/node_modules/test-nm.js diff --git a/test/fixtures/test-runner/default-behavior/node_modules/reporter-cjs/index.js b/test/fixtures/test-runner/node_modules/reporter-cjs/index.js similarity index 100% rename from test/fixtures/test-runner/default-behavior/node_modules/reporter-cjs/index.js rename to test/fixtures/test-runner/node_modules/reporter-cjs/index.js diff --git a/test/fixtures/test-runner/default-behavior/node_modules/reporter-cjs/package.json b/test/fixtures/test-runner/node_modules/reporter-cjs/package.json similarity index 100% rename from test/fixtures/test-runner/default-behavior/node_modules/reporter-cjs/package.json rename to test/fixtures/test-runner/node_modules/reporter-cjs/package.json diff --git a/test/fixtures/test-runner/default-behavior/node_modules/reporter-esm/index.mjs b/test/fixtures/test-runner/node_modules/reporter-esm/index.mjs similarity index 100% rename from test/fixtures/test-runner/default-behavior/node_modules/reporter-esm/index.mjs rename to test/fixtures/test-runner/node_modules/reporter-esm/index.mjs diff --git a/test/fixtures/test-runner/default-behavior/node_modules/reporter-esm/package.json b/test/fixtures/test-runner/node_modules/reporter-esm/package.json similarity index 100% rename from test/fixtures/test-runner/default-behavior/node_modules/reporter-esm/package.json rename to test/fixtures/test-runner/node_modules/reporter-esm/package.json diff --git a/test/fixtures/test-runner/node_modules/test-nm.js b/test/fixtures/test-runner/node_modules/test-nm.js new file mode 100644 index 00000000000000..30024eab1f17e4 --- /dev/null +++ b/test/fixtures/test-runner/node_modules/test-nm.js @@ -0,0 +1,2 @@ +'use strict'; +throw new Error('thrown from node_modules'); From 1196e0df3b846d0f92fdd2920d25513f1502f1a4 Mon Sep 17 00:00:00 2001 From: Raz Luvaton <16746759+rluvaton@users.noreply.github.com> Date: Wed, 26 Jul 2023 14:54:10 +0300 Subject: [PATCH 8/8] move the reporters --- test/fixtures/test-runner/node_modules/test-nm.js | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 test/fixtures/test-runner/node_modules/test-nm.js diff --git a/test/fixtures/test-runner/node_modules/test-nm.js b/test/fixtures/test-runner/node_modules/test-nm.js deleted file mode 100644 index 30024eab1f17e4..00000000000000 --- a/test/fixtures/test-runner/node_modules/test-nm.js +++ /dev/null @@ -1,2 +0,0 @@ -'use strict'; -throw new Error('thrown from node_modules');