GeezerVison is showing github.com — test: reorder test files fixtures for better understanding · nodejs/node@0fea550
File treeExpand file treeCollapse file tree Open diff view settings fixtures/test-runner/default-behavior
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboard File renamed without changes. Collapse file Copy file name to clipboard File renamed without changes. Collapse file Copy file name to clipboard File renamed without changes. Collapse file Copy file name to clipboard File renamed without changes. Collapse file Copy file name to clipboard File renamed without changes. Collapse file Copy file name to clipboard File renamed without changes. Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-runner-cli.js +10-14Lines changed: 10 additions & 14 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -22,8 +22,8 @@ const testFixtures = fixtures.path('test-runner'); | 22 | 22 | { | 23 | 23 | // Default behavior. node_modules is ignored. Files that don't match the | 24 | 24 | // pattern are ignored except in test/ directories. | 25 | | - const args = ['--test', testFixtures]; | 26 | | - const child = spawnSync(process.execPath, args); | | 25 | + const args = ['--test']; | | 26 | + const child = spawnSync(process.execPath, args, { cwd: join(testFixtures, 'default-behavior') }); | 27 | 27 |
| 28 | 28 | assert.strictEqual(child.status, 1); | 29 | 29 | assert.strictEqual(child.signal, null); | @@ -39,8 +39,8 @@ const testFixtures = fixtures.path('test-runner'); | 39 | 39 |
| 40 | 40 | { | 41 | 41 | // Same but with a prototype mutation in require scripts. | 42 | | - const args = ['--require', join(testFixtures, 'protoMutation.js'), '--test', testFixtures]; | 43 | | - const child = spawnSync(process.execPath, args); | | 42 | + const args = ['--require', join(testFixtures, 'protoMutation.js'), '--test']; | | 43 | + const child = spawnSync(process.execPath, args, { cwd: join(testFixtures, 'default-behavior') }); | 44 | 44 |
| 45 | 45 | const stdout = child.stdout.toString(); | 46 | 46 | assert.match(stdout, /ok 1 - this should pass/); | @@ -56,23 +56,19 @@ const testFixtures = fixtures.path('test-runner'); | 56 | 56 |
| 57 | 57 | { | 58 | 58 | // User specified files that don't match the pattern are still run. | 59 | | - const args = ['--test', testFixtures, join(testFixtures, 'index.js')]; | 60 | | - const child = spawnSync(process.execPath, args); | | 59 | + const args = ['--test', join(testFixtures, 'index.js')]; | | 60 | + const child = spawnSync(process.execPath, args, { cwd: testFixtures }); | 61 | 61 |
| 62 | 62 | assert.strictEqual(child.status, 1); | 63 | 63 | assert.strictEqual(child.signal, null); | 64 | 64 | assert.strictEqual(child.stderr.toString(), ''); | 65 | 65 | const stdout = child.stdout.toString(); | 66 | 66 | assert.match(stdout, /not ok 1 - .+index\.js/); | 67 | | - assert.match(stdout, /ok 2 - this should pass/); | 68 | | - assert.match(stdout, /not ok 3 - this should fail/); | 69 | | - assert.match(stdout, /ok 4 - .+subdir.+subdir_test\.js/); | 70 | | - assert.match(stdout, /ok 5 - this should pass/); | 71 | 67 | } | 72 | 68 |
| 73 | 69 | { | 74 | 70 | // Searches node_modules if specified. | 75 | | - const args = ['--test', join(testFixtures, 'node_modules')]; | | 71 | + const args = ['--test', join(testFixtures, 'default-behavior/node_modules')]; | 76 | 72 | const child = spawnSync(process.execPath, args); | 77 | 73 |
| 78 | 74 | assert.strictEqual(child.status, 1); | @@ -85,7 +81,7 @@ const testFixtures = fixtures.path('test-runner'); | 85 | 81 | { | 86 | 82 | // The current directory is used by default. | 87 | 83 | const args = ['--test']; | 88 | | - const options = { cwd: testFixtures }; | | 84 | + const options = { cwd: join(testFixtures, 'default-behavior') }; | 89 | 85 | const child = spawnSync(process.execPath, args, options); | 90 | 86 |
| 91 | 87 | assert.strictEqual(child.status, 1); | @@ -124,7 +120,7 @@ const testFixtures = fixtures.path('test-runner'); | 124 | 120 | // Test combined stream outputs | 125 | 121 | const args = [ | 126 | 122 | '--test', | 127 | | - 'test/fixtures/test-runner/index.test.js', | | 123 | + 'test/fixtures/test-runner/default-behavior/index.test.js', | 128 | 124 | 'test/fixtures/test-runner/nested.js', | 129 | 125 | 'test/fixtures/test-runner/invalid-tap.js', | 130 | 126 | ]; | @@ -202,7 +198,7 @@ const testFixtures = fixtures.path('test-runner'); | 202 | 198 | const args = ['--no-warnings', | 203 | 199 | '--experimental-loader', 'data:text/javascript,', | 204 | 200 | '--require', fixtures.path('empty.js'), | 205 | | - '--test', join(testFixtures, 'index.test.js')]; | | 201 | + '--test', join(testFixtures, 'default-behavior', 'index.test.js')]; | 206 | 202 | const child = spawnSync(process.execPath, args); | 207 | 203 |
| 208 | 204 | assert.strictEqual(child.stderr.toString(), ''); | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-runner-exit-code.js +4-1Lines changed: 4 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -43,7 +43,10 @@ if (process.argv[2] === 'child') { | 43 | 43 | assert.strictEqual(child.status, 0); | 44 | 44 | assert.strictEqual(child.signal, null); | 45 | 45 |
| 46 | | - child = spawnSync(process.execPath, ['--test', fixtures.path('test-runner', 'subdir', 'subdir_test.js')]); | | 46 | + child = spawnSync(process.execPath, [ | | 47 | + '--test', | | 48 | + fixtures.path('test-runner', 'default-behavior', 'subdir', 'subdir_test.js'), | | 49 | + ]); | 47 | 50 | assert.strictEqual(child.status, 0); | 48 | 51 | assert.strictEqual(child.signal, null); | 49 | 52 |
| |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-runner-inspect.mjs +5-1Lines changed: 5 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -11,7 +11,11 @@ common.skipIfInspectorDisabled(); | 11 | 11 | tmpdir.refresh(); | 12 | 12 |
| 13 | 13 | { | 14 | | - const child = new NodeInstance(['--test', '--inspect-brk=0'], undefined, fixtures.path('test-runner/index.test.js')); | | 14 | + const child = new NodeInstance( | | 15 | + ['--test', '--inspect-brk=0'], | | 16 | + undefined, | | 17 | + fixtures.path('test-runner/default-behavior/index.test.js') | | 18 | + ); | 15 | 19 |
| 16 | 20 | let stdout = ''; | 17 | 21 | let stderr = ''; | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-runner-run.mjs +26-9Lines changed: 26 additions & 9 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -26,15 +26,20 @@ describe('require(\'node:test\').run', { concurrency: true }, () => { | 26 | 26 | }); | 27 | 27 |
| 28 | 28 | it('should succeed with a file', async () => { | 29 | | - const stream = run({ files: [join(testFixtures, 'test/random.cjs')] }); | | 29 | + const stream = run({ files: [join(testFixtures, 'default-behavior/test/random.cjs')] }); | 30 | 30 | stream.on('test:fail', common.mustNotCall()); | 31 | 31 | stream.on('test:pass', common.mustCall(1)); | 32 | 32 | // eslint-disable-next-line no-unused-vars | 33 | 33 | for await (const _ of stream); | 34 | 34 | }); | 35 | 35 |
| 36 | 36 | it('should run same file twice', async () => { | 37 | | - const stream = run({ files: [join(testFixtures, 'test/random.cjs'), join(testFixtures, 'test/random.cjs')] }); | | 37 | + const stream = run({ | | 38 | + files: [ | | 39 | + join(testFixtures, 'default-behavior/test/random.cjs'), | | 40 | + join(testFixtures, 'default-behavior/test/random.cjs'), | | 41 | + ] | | 42 | + }); | 38 | 43 | stream.on('test:fail', common.mustNotCall()); | 39 | 44 | stream.on('test:pass', common.mustCall(2)); | 40 | 45 | // eslint-disable-next-line no-unused-vars | @@ -68,7 +73,9 @@ describe('require(\'node:test\').run', { concurrency: true }, () => { | 68 | 73 | }); | 69 | 74 |
| 70 | 75 | it('should be piped with dot', async () => { | 71 | | - const result = await run({ files: [join(testFixtures, 'test/random.cjs')] }).compose(dot).toArray(); | | 76 | + const result = await run({ | | 77 | + files: [join(testFixtures, 'default-behavior/test/random.cjs')] | | 78 | + }).compose(dot).toArray(); | 72 | 79 | assert.deepStrictEqual(result, [ | 73 | 80 | '.', | 74 | 81 | '\n', | @@ -77,15 +84,19 @@ describe('require(\'node:test\').run', { concurrency: true }, () => { | 77 | 84 |
| 78 | 85 | it('should be piped with spec', async () => { | 79 | 86 | const specReporter = new spec(); | 80 | | - const result = await run({ files: [join(testFixtures, 'test/random.cjs')] }).compose(specReporter).toArray(); | | 87 | + const result = await run({ | | 88 | + files: [join(testFixtures, 'default-behavior/test/random.cjs')] | | 89 | + }).compose(specReporter).toArray(); | 81 | 90 | const stringResults = result.map((bfr) => bfr.toString()); | 82 | 91 | assert.match(stringResults[0], /this should pass/); | 83 | 92 | assert.match(stringResults[1], /tests 1/); | 84 | 93 | assert.match(stringResults[1], /pass 1/); | 85 | 94 | }); | 86 | 95 |
| 87 | 96 | it('should be piped with tap', async () => { | 88 | | - const result = await run({ files: [join(testFixtures, 'test/random.cjs')] }).compose(tap).toArray(); | | 97 | + const result = await run({ | | 98 | + files: [join(testFixtures, 'default-behavior/test/random.cjs')] | | 99 | + }).compose(tap).toArray(); | 89 | 100 | assert.strictEqual(result.length, 13); | 90 | 101 | assert.strictEqual(result[0], 'TAP version 13\n'); | 91 | 102 | assert.strictEqual(result[1], '# Subtest: this should pass\n'); | @@ -103,15 +114,21 @@ describe('require(\'node:test\').run', { concurrency: true }, () => { | 103 | 114 | }); | 104 | 115 |
| 105 | 116 | it('should skip tests not matching testNamePatterns - RegExp', async () => { | 106 | | - const result = await run({ files: [join(testFixtures, 'test/skip_by_name.cjs')], testNamePatterns: [/executed/] }) | | 117 | + const result = await run({ | | 118 | + files: [join(testFixtures, 'default-behavior/test/skip_by_name.cjs')], | | 119 | + testNamePatterns: [/executed/] | | 120 | + }) | 107 | 121 | .compose(tap) | 108 | 122 | .toArray(); | 109 | 123 | assert.strictEqual(result[2], 'ok 1 - this should be skipped # SKIP test name does not match pattern\n'); | 110 | 124 | assert.strictEqual(result[5], 'ok 2 - this should be executed\n'); | 111 | 125 | }); | 112 | 126 |
| 113 | 127 | it('should skip tests not matching testNamePatterns - string', async () => { | 114 | | - const result = await run({ files: [join(testFixtures, 'test/skip_by_name.cjs')], testNamePatterns: ['executed'] }) | | 128 | + const result = await run({ | | 129 | + files: [join(testFixtures, 'default-behavior/test/skip_by_name.cjs')], | | 130 | + testNamePatterns: ['executed'] | | 131 | + }) | 115 | 132 | .compose(tap) | 116 | 133 | .toArray(); | 117 | 134 | assert.strictEqual(result[2], 'ok 1 - this should be skipped # SKIP test name does not match pattern\n'); | @@ -121,7 +138,7 @@ describe('require(\'node:test\').run', { concurrency: true }, () => { | 121 | 138 | it('should emit "test:watch:drained" event on watch mode', async () => { | 122 | 139 | const controller = new AbortController(); | 123 | 140 | await run({ | 124 | | - files: [join(testFixtures, 'test/random.cjs')], | | 141 | + files: [join(testFixtures, 'default-behavior/test/random.cjs')], | 125 | 142 | watch: true, | 126 | 143 | signal: controller.signal, | 127 | 144 | }).on('data', function({ type }) { | @@ -135,7 +152,7 @@ describe('require(\'node:test\').run', { concurrency: true }, () => { | 135 | 152 | it('should stop watch mode when abortSignal aborts', async () => { | 136 | 153 | const controller = new AbortController(); | 137 | 154 | const result = await run({ | 138 | | - files: [join(testFixtures, 'test/random.cjs')], | | 155 | + files: [join(testFixtures, 'default-behavior/test/random.cjs')], | 139 | 156 | watch: true, | 140 | 157 | signal: controller.signal, | 141 | 158 | }) | |
|