GeezerVison is showing github.com — test: make sure current run result is pushed and reset · nodejs/node@3df7938
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-runner-run-watch.mjs +32-11Lines changed: 32 additions & 11 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -12,6 +12,9 @@ import { join } from 'node:path'; | 12 | 12 | if (common.isIBMi) | 13 | 13 | common.skip('IBMi does not support `fs.watch()`'); | 14 | 14 |
| | 15 | +if (common.isAIX) | | 16 | + common.skip('folder watch capability is limited in AIX.'); | | 17 | + | 15 | 18 | // This test updates these files repeatedly, | 16 | 19 | // Reading them from disk is unreliable due to race conditions. | 17 | 20 | const fixtureContent = { | @@ -60,6 +63,8 @@ async function testWatch({ fileToUpdate, file, action = 'update', cwd = tmpdir.p | 60 | 63 |
| 61 | 64 | const testUpdate = async () => { | 62 | 65 | await ran1.promise; | | 66 | + runs.push(currentRun); | | 67 | + currentRun = ''; | 63 | 68 | const content = fixtureContent[fileToUpdate]; | 64 | 69 | const path = fixturePaths[fileToUpdate]; | 65 | 70 | const interval = setInterval(() => writeFileSync(path, content), common.platformTimeout(1000)); | @@ -68,6 +73,9 @@ async function testWatch({ fileToUpdate, file, action = 'update', cwd = tmpdir.p | 68 | 73 | clearInterval(interval); | 69 | 74 | child.kill(); | 70 | 75 | await once(child, 'exit'); | | 76 | + | | 77 | + assert.strictEqual(runs.length, 2); | | 78 | + | 71 | 79 | for (const run of runs) { | 72 | 80 | assert.doesNotMatch(run, /run\(\) is being called recursively/); | 73 | 81 | assert.match(run, /# tests 1/); | @@ -79,6 +87,8 @@ async function testWatch({ fileToUpdate, file, action = 'update', cwd = tmpdir.p | 79 | 87 |
| 80 | 88 | const testRename = async () => { | 81 | 89 | await ran1.promise; | | 90 | + runs.push(currentRun); | | 91 | + currentRun = ''; | 82 | 92 | const fileToRenamePath = tmpdir.resolve(fileToUpdate); | 83 | 93 | const newFileNamePath = tmpdir.resolve(`test-renamed-${fileToUpdate}`); | 84 | 94 | const interval = setInterval(() => renameSync(fileToRenamePath, newFileNamePath), common.platformTimeout(1000)); | @@ -88,22 +98,31 @@ async function testWatch({ fileToUpdate, file, action = 'update', cwd = tmpdir.p | 88 | 98 | child.kill(); | 89 | 99 | await once(child, 'exit'); | 90 | 100 |
| 91 | | - for (const run of runs) { | 92 | | - assert.doesNotMatch(run, /run\(\) is being called recursively/); | 93 | | - if (action === 'rename2') { | 94 | | - assert.match(run, /MODULE_NOT_FOUND/); | 95 | | - } else { | 96 | | - assert.doesNotMatch(run, /MODULE_NOT_FOUND/); | 97 | | - } | 98 | | - assert.match(run, /# tests 1/); | 99 | | - assert.match(run, /# pass 1/); | 100 | | - assert.match(run, /# fail 0/); | 101 | | - assert.match(run, /# cancelled 0/); | | 101 | + assert.strictEqual(runs.length, 2); | | 102 | + | | 103 | + const [firstRun, secondRun] = runs; | | 104 | + assert.match(firstRun, /# tests 1/); | | 105 | + assert.match(firstRun, /# pass 1/); | | 106 | + assert.match(firstRun, /# fail 0/); | | 107 | + assert.match(firstRun, /# cancelled 0/); | | 108 | + assert.doesNotMatch(firstRun, /run\(\) is being called recursively/); | | 109 | + | | 110 | + if (action === 'rename2') { | | 111 | + assert.match(secondRun, /MODULE_NOT_FOUND/); | | 112 | + return; | 102 | 113 | } | | 114 | + | | 115 | + assert.match(secondRun, /# tests 1/); | | 116 | + assert.match(secondRun, /# pass 1/); | | 117 | + assert.match(secondRun, /# fail 0/); | | 118 | + assert.match(secondRun, /# cancelled 0/); | | 119 | + assert.doesNotMatch(secondRun, /run\(\) is being called recursively/); | 103 | 120 | }; | 104 | 121 |
| 105 | 122 | const testDelete = async () => { | 106 | 123 | await ran1.promise; | | 124 | + runs.push(currentRun); | | 125 | + currentRun = ''; | 107 | 126 | const fileToDeletePath = tmpdir.resolve(fileToUpdate); | 108 | 127 | const interval = setInterval(() => { | 109 | 128 | if (existsSync(fileToDeletePath)) { | @@ -118,6 +137,8 @@ async function testWatch({ fileToUpdate, file, action = 'update', cwd = tmpdir.p | 118 | 137 | child.kill(); | 119 | 138 | await once(child, 'exit'); | 120 | 139 |
| | 140 | + assert.strictEqual(runs.length, 2); | | 141 | + | 121 | 142 | for (const run of runs) { | 122 | 143 | assert.doesNotMatch(run, /MODULE_NOT_FOUND/); | 123 | 144 | } | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-runner-watch-mode.mjs +15Lines changed: 15 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -11,6 +11,9 @@ import tmpdir from '../common/tmpdir.js'; | 11 | 11 | if (common.isIBMi) | 12 | 12 | common.skip('IBMi does not support `fs.watch()`'); | 13 | 13 |
| | 14 | +if (common.isAIX) | | 15 | + common.skip('folder watch capability is limited in AIX.'); | | 16 | + | 14 | 17 | let fixturePaths; | 15 | 18 |
| 16 | 19 | // This test updates these files repeatedly, | @@ -54,6 +57,8 @@ async function testWatch({ fileToUpdate, file, action = 'update' }) { | 54 | 57 |
| 55 | 58 | const testUpdate = async () => { | 56 | 59 | await ran1.promise; | | 60 | + runs.push(currentRun); | | 61 | + currentRun = ''; | 57 | 62 | const content = fixtureContent[fileToUpdate]; | 58 | 63 | const path = fixturePaths[fileToUpdate]; | 59 | 64 | const interval = setInterval(() => writeFileSync(path, content), common.platformTimeout(1000)); | @@ -63,6 +68,8 @@ async function testWatch({ fileToUpdate, file, action = 'update' }) { | 63 | 68 | child.kill(); | 64 | 69 | await once(child, 'exit'); | 65 | 70 |
| | 71 | + assert.strictEqual(runs.length, 2); | | 72 | + | 66 | 73 | for (const run of runs) { | 67 | 74 | assert.match(run, /# tests 1/); | 68 | 75 | assert.match(run, /# pass 1/); | @@ -73,6 +80,8 @@ async function testWatch({ fileToUpdate, file, action = 'update' }) { | 73 | 80 |
| 74 | 81 | const testRename = async () => { | 75 | 82 | await ran1.promise; | | 83 | + runs.push(currentRun); | | 84 | + currentRun = ''; | 76 | 85 | const fileToRenamePath = tmpdir.resolve(fileToUpdate); | 77 | 86 | const newFileNamePath = tmpdir.resolve(`test-renamed-${fileToUpdate}`); | 78 | 87 | const interval = setInterval(() => renameSync(fileToRenamePath, newFileNamePath), common.platformTimeout(1000)); | @@ -82,6 +91,8 @@ async function testWatch({ fileToUpdate, file, action = 'update' }) { | 82 | 91 | child.kill(); | 83 | 92 | await once(child, 'exit'); | 84 | 93 |
| | 94 | + assert.strictEqual(runs.length, 2); | | 95 | + | 85 | 96 | for (const run of runs) { | 86 | 97 | assert.match(run, /# tests 1/); | 87 | 98 | assert.match(run, /# pass 1/); | @@ -92,6 +103,8 @@ async function testWatch({ fileToUpdate, file, action = 'update' }) { | 92 | 103 |
| 93 | 104 | const testDelete = async () => { | 94 | 105 | await ran1.promise; | | 106 | + runs.push(currentRun); | | 107 | + currentRun = ''; | 95 | 108 | const fileToDeletePath = tmpdir.resolve(fileToUpdate); | 96 | 109 | const interval = setInterval(() => { | 97 | 110 | if (existsSync(fileToDeletePath)) { | @@ -106,6 +119,8 @@ async function testWatch({ fileToUpdate, file, action = 'update' }) { | 106 | 119 | child.kill(); | 107 | 120 | await once(child, 'exit'); | 108 | 121 |
| | 122 | + assert.strictEqual(runs.length, 2); | | 123 | + | 109 | 124 | for (const run of runs) { | 110 | 125 | assert.doesNotMatch(run, /MODULE_NOT_FOUND/); | 111 | 126 | } | |
|