GeezerVison is showing github.com — test: use unusual chars in the path to ensure our tests are robust · nodejs/node@510649f
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: .github/workflows/test-linux.yml +10-2Lines changed: 10 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 40 | 40 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | 41 | 41 | with: | 42 | 42 | persist-credentials: false | | 43 | + path: node | 43 | 44 | - name: Set up Python ${{ env.PYTHON_VERSION }} | 44 | 45 | uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0 | 45 | 46 | with: | | 51 | 52 | - name: Environment Information | 52 | 53 | run: npx envinfo | 53 | 54 | - name: Build | 54 | | - run: make build-ci -j4 V=1 CONFIG_FLAGS="--error-on-warn" | | 55 | + run: make -C node build-ci -j4 V=1 CONFIG_FLAGS="--error-on-warn" | 55 | 56 | - name: Test | 56 | | - run: make run-ci -j4 V=1 TEST_CI_ARGS="-p actions --node-args='--test-reporter=spec' --node-args='--test-reporter-destination=stdout' --measure-flakiness 9" | | 57 | + run: make -C node run-ci -j4 V=1 TEST_CI_ARGS="-p actions --node-args='--test-reporter=spec' --node-args='--test-reporter-destination=stdout' --measure-flakiness 9" | | 58 | + - name: Re-run test in a folder whose name contains unusual chars | | 59 | + run: | | | 60 | + mv node "$DIR" | | 61 | + cd "$DIR" | | 62 | + ./tools/test.py --flaky-tests keep_retrying -p actions -j 4 | | 63 | + env: | | 64 | + DIR: dir%20with $unusual"chars?'åß∂ƒ©∆¬…` |
Collapse file Copy file name to clipboardExpand all lines: .github/workflows/test-macos.yml +11-3Lines changed: 11 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 51 | 51 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | 52 | 52 | with: | 53 | 53 | persist-credentials: false | | 54 | + path: node | 54 | 55 | - name: Set up Python ${{ env.PYTHON_VERSION }} | 55 | 56 | uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0 | 56 | 57 | with: | | 68 | 69 | # happen anymore running this step here first, that's also useful | 69 | 70 | # information.) | 70 | 71 | - name: tools/doc/node_modules workaround | 71 | | - run: make tools/doc/node_modules | | 72 | + run: make -C node tools/doc/node_modules | 72 | 73 | # This is needed due to https://github.com/nodejs/build/issues/3878 | 73 | 74 | - name: Cleanup | 74 | 75 | run: | | | 84 | 85 | df -h | 85 | 86 | echo "::endgroup::" | 86 | 87 | - name: Build | 87 | | - run: make build-ci -j$(getconf _NPROCESSORS_ONLN) V=1 CONFIG_FLAGS="--error-on-warn" | | 88 | + run: make -C node build-ci -j$(getconf _NPROCESSORS_ONLN) V=1 CONFIG_FLAGS="--error-on-warn" | 88 | 89 | - name: Free Space After Build | 89 | 90 | run: df -h | 90 | 91 | - name: Test | 91 | | - run: make run-ci -j$(getconf _NPROCESSORS_ONLN) V=1 TEST_CI_ARGS="-p actions --node-args='--test-reporter=spec' --node-args='--test-reporter-destination=stdout' --measure-flakiness 9" | | 92 | + run: make -C node run-ci -j$(getconf _NPROCESSORS_ONLN) V=1 TEST_CI_ARGS="-p actions --node-args='--test-reporter=spec' --node-args='--test-reporter-destination=stdout' --measure-flakiness 9" | | 93 | + - name: Re-run test in a folder whose name contains unusual chars | | 94 | + run: | | | 95 | + mv node "$DIR" | | 96 | + cd "$DIR" | | 97 | + ./tools/test.py --flaky-tests keep_retrying -p actions -j 4 | | 98 | + env: | | 99 | + DIR: dir%20with $unusual"chars?'åß∂ƒ©∆¬…` |
Collapse file Copy file name to clipboardExpand all lines: test/common/index.js +9Lines changed: 9 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1135,6 +1135,15 @@ const common = { | 1135 | 1135 | get checkoutEOL() { | 1136 | 1136 | return fs.readFileSync(__filename).includes('\r\n') ? '\r\n' : '\n'; | 1137 | 1137 | }, | | 1138 | + | | 1139 | + get isInsideDirWithUnusualChars() { | | 1140 | + return __dirname.includes('%') || | | 1141 | + (!isWindows && __dirname.includes('\\')) || | | 1142 | + __dirname.includes('$') || | | 1143 | + __dirname.includes('\n') || | | 1144 | + __dirname.includes('\r') || | | 1145 | + __dirname.includes('\t'); | | 1146 | + }, | 1138 | 1147 | }; | 1139 | 1148 |
| 1140 | 1149 | const validProperties = new Set(Object.keys(common)); | |
Collapse file Copy file name to clipboardExpand all lines: test/common/index.mjs +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -26,6 +26,7 @@ const { | 26 | 26 | isDumbTerminal, | 27 | 27 | isFreeBSD, | 28 | 28 | isIBMi, | | 29 | + isInsideDirWithUnusualChars, | 29 | 30 | isLinux, | 30 | 31 | isLinuxPPCBE, | 31 | 32 | isMainThread, | @@ -81,6 +82,7 @@ export { | 81 | 82 | isDumbTerminal, | 82 | 83 | isFreeBSD, | 83 | 84 | isIBMi, | | 85 | + isInsideDirWithUnusualChars, | 84 | 86 | isLinux, | 85 | 87 | isLinuxPPCBE, | 86 | 88 | isMainThread, | |
Collapse file Copy file name to clipboardExpand all lines: test/es-module/test-esm-invalid-pjson.js +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -19,6 +19,8 @@ describe('ESM: Package.json', { concurrency: !process.env.TEST_PARALLEL }, () => | 19 | 19 | assert.ok( | 20 | 20 | stderr.includes( | 21 | 21 | `Invalid package config ${path.toNamespacedPath(invalidJson)} while importing "invalid-pjson" from ${entry}.` | | 22 | + ) || stderr.includes( | | 23 | + `Invalid package config ${path.toNamespacedPath(invalidJson)} while importing "invalid-pjson" from ${path.toNamespacedPath(entry)}.` | 22 | 24 | ), | 23 | 25 | stderr | 24 | 26 | ); | |
Collapse file Copy file name to clipboardExpand all lines: test/fixtures/snapshot/child-process-sync.js +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 8 | 8 | function spawn() { | 9 | 9 | const { spawnSync, execFileSync, execSync } = require('child_process'); | 10 | 10 | spawnSync(process.execPath, [ __filename, 'spawnSync' ], { stdio: 'inherit' }); | 11 | | - execSync(`"${process.execPath}" "${__filename}" "execSync"`, { stdio: 'inherit' }); | | 11 | + if (!process.env.DIRNAME_CONTAINS_SHELL_UNSAFE_CHARS) | | 12 | + execSync(`"${process.execPath}" "${__filename}" "execSync"`, { stdio: 'inherit' }); | 12 | 13 | execFileSync(process.execPath, [ __filename, 'execFileSync' ], { stdio: 'inherit' }); | 13 | 14 | } | 14 | 15 |
| |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-fs-cp.mjs +7-7Lines changed: 7 additions & 7 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | | -import { mustCall, mustNotMutateObjectDeep } from '../common/index.mjs'; | | 1 | +import { mustCall, mustNotMutateObjectDeep, isInsideDirWithUnusualChars } from '../common/index.mjs'; | 2 | 2 |
| 3 | 3 | import assert from 'assert'; | 4 | 4 | import fs from 'fs'; | @@ -264,7 +264,7 @@ function nextdir(dirname) { | 264 | 264 | } | 265 | 265 |
| 266 | 266 | // It throws error if parent directory of symlink in dest points to src. | 267 | | -{ | | 267 | +if (!isInsideDirWithUnusualChars) { | 268 | 268 | const src = nextdir(); | 269 | 269 | mkdirSync(join(src, 'a'), mustNotMutateObjectDeep({ recursive: true })); | 270 | 270 | const dest = nextdir(); | @@ -279,7 +279,7 @@ function nextdir(dirname) { | 279 | 279 | } | 280 | 280 |
| 281 | 281 | // It throws error if attempt is made to copy directory to file. | 282 | | -{ | | 282 | +if (!isInsideDirWithUnusualChars) { | 283 | 283 | const src = nextdir(); | 284 | 284 | mkdirSync(src, mustNotMutateObjectDeep({ recursive: true })); | 285 | 285 | const dest = './test/fixtures/copy/kitchen-sink/README.md'; | @@ -310,7 +310,7 @@ function nextdir(dirname) { | 310 | 310 |
| 311 | 311 |
| 312 | 312 | // It throws error if attempt is made to copy file to directory. | 313 | | -{ | | 313 | +if (!isInsideDirWithUnusualChars) { | 314 | 314 | const src = './test/fixtures/copy/kitchen-sink/README.md'; | 315 | 315 | const dest = nextdir(); | 316 | 316 | mkdirSync(dest, mustNotMutateObjectDeep({ recursive: true })); | @@ -346,7 +346,7 @@ function nextdir(dirname) { | 346 | 346 |
| 347 | 347 | // It throws error if attempt is made to copy src to dest | 348 | 348 | // when src is parent directory of the parent of dest | 349 | | -{ | | 349 | +if (!isInsideDirWithUnusualChars) { | 350 | 350 | const src = nextdir('a'); | 351 | 351 | const destParent = nextdir('a/b'); | 352 | 352 | const dest = nextdir('a/b/c'); | @@ -370,7 +370,7 @@ function nextdir(dirname) { | 370 | 370 | } | 371 | 371 |
| 372 | 372 | // It throws an error if attempt is made to copy socket. | 373 | | -if (!isWindows) { | | 373 | +if (!isWindows && !isInsideDirWithUnusualChars) { | 374 | 374 | const src = nextdir(); | 375 | 375 | mkdirSync(src); | 376 | 376 | const dest = nextdir(); | @@ -738,7 +738,7 @@ if (!isWindows) { | 738 | 738 | } | 739 | 739 |
| 740 | 740 | // It returns an error if attempt is made to copy socket. | 741 | | -if (!isWindows) { | | 741 | +if (!isWindows && !isInsideDirWithUnusualChars) { | 742 | 742 | const src = nextdir(); | 743 | 743 | mkdirSync(src); | 744 | 744 | const dest = nextdir(); | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-inspector-strip-types.js +4-2Lines changed: 4 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -7,8 +7,10 @@ if (!process.config.variables.node_use_amaro) common.skip('Requires Amaro'); | 7 | 7 | const { NodeInstance } = require('../common/inspector-helper.js'); | 8 | 8 | const fixtures = require('../common/fixtures'); | 9 | 9 | const assert = require('assert'); | | 10 | +const { pathToFileURL } = require('url'); | 10 | 11 |
| 11 | 12 | const scriptPath = fixtures.path('typescript/ts/test-typescript.ts'); | | 13 | +const scriptURL = pathToFileURL(scriptPath); | 12 | 14 |
| 13 | 15 | async function runTest() { | 14 | 16 | const child = new NodeInstance( | @@ -30,10 +32,10 @@ async function runTest() { | 30 | 32 | const scriptParsed = await session.waitForNotification((notification) => { | 31 | 33 | if (notification.method !== 'Debugger.scriptParsed') return false; | 32 | 34 |
| 33 | | - return notification.params.url === scriptPath; | | 35 | + return notification.params.url === scriptPath || notification.params.url === scriptURL.href; | 34 | 36 | }); | 35 | 37 | // Verify that the script has a sourceURL, hinting that it is a generated source. | 36 | | - assert(scriptParsed.params.hasSourceURL); | | 38 | + assert(scriptParsed.params.hasSourceURL || common.isInsideDirWithUnusualChars); | 37 | 39 |
| 38 | 40 | await session.waitForPauseOnStart(); | 39 | 41 | await session.runToCompletion(); | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-npm-install.js +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 2 | 2 | const common = require('../common'); | 3 | 3 | if (!common.hasCrypto) | 4 | 4 | common.skip('missing crypto'); | | 5 | +if (common.isInsideDirWithUnusualChars) | | 6 | + common.skip('npm does not support this install path'); | 5 | 7 |
| 6 | 8 | const path = require('path'); | 7 | 9 | const exec = require('child_process').exec; | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-snapshot-child-process-sync.js +4-2Lines changed: 4 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 3 | 3 | // This tests that process.cwd() is accurate when | 4 | 4 | // restoring state from a snapshot | 5 | 5 |
| 6 | | -require('../common'); | | 6 | +const { isInsideDirWithUnusualChars } = require('../common'); | 7 | 7 | const { spawnSyncAndAssert } = require('../common/child_process'); | 8 | 8 | const tmpdir = require('../common/tmpdir'); | 9 | 9 | const fixtures = require('../common/fixtures'); | @@ -14,7 +14,7 @@ const blobPath = tmpdir.resolve('snapshot.blob'); | 14 | 14 | const file = fixtures.path('snapshot', 'child-process-sync.js'); | 15 | 15 | const expected = [ | 16 | 16 | 'From child process spawnSync', | 17 | | - 'From child process execSync', | | 17 | + ...(isInsideDirWithUnusualChars ? [] : ['From child process execSync']), | 18 | 18 | 'From child process execFileSync', | 19 | 19 | ]; | 20 | 20 |
| @@ -27,6 +27,7 @@ const expected = [ | 27 | 27 | file, | 28 | 28 | ], { | 29 | 29 | cwd: tmpdir.path, | | 30 | + env: { ...process.env, DIRNAME_CONTAINS_SHELL_UNSAFE_CHARS: isInsideDirWithUnusualChars ? 'TRUE' : '' }, | 30 | 31 | }, { | 31 | 32 | trim: true, | 32 | 33 | stdout(output) { | @@ -43,6 +44,7 @@ const expected = [ | 43 | 44 | file, | 44 | 45 | ], { | 45 | 46 | cwd: tmpdir.path, | | 47 | + env: { ...process.env, DIRNAME_CONTAINS_SHELL_UNSAFE_CHARS: isInsideDirWithUnusualChars ? 'TRUE' : '' }, | 46 | 48 | }, { | 47 | 49 | trim: true, | 48 | 50 | stdout(output) { | |
|