Repository navigation
Some tests are not fully CWD-agnostic #61303
Description
Activity
- addedtestIssues and PRs related to Node.js core tests and test infrastructure.Issues and PRs related to Node.js core tests and test infrastructure.good first issueIssues that are suitable for first-time contributors.Issues that are suitable for first-time contributors.
on Jan 7, 2026 Hi! I'd like to try working on this issue, if that's okay.
Reacted by Livia Medeiros, Mert Can Altin and sangwookReacted by Mert Can AltinThe Filesystem Hierarchy Standard (FHS) states in https://specifications.freedesktop.org/fhs/latest/rootFilesystem.html#rootPurpose
Applications must never create or require special files or subdirectories in the root directory. Other locations in the FHS hierarchy provide more than enough flexibility for any package.
so I'm not sure if it would be a valid repro scenario to be testing in the Linux root location
/.Hi, I investigated this and it looks like the root problem is that test output normalization blindly removes process.cwd(), which causes unintended string corruption (e.g.
/nodestripping parts ofnodejs.org).Would you be open to a small, scoped fix that only normalizes filesystem paths (instead of raw string replacement), possibly starting with test-node-output-* tests?
@MikeMcC399 The
/is an edge case indicating that test is not fully agnostic. Depending on the exact snapshot, test might fail in directories like/f,/node,/testwhatsoever; ensuring that it can run even in/would usually ensure that it won't fail in any other directory.On a side note, FHS is a standard oriented on distribution/package maintainers and applications. It doesn't forbid any usage.
The simplest repro scenario is something likegit clone https://github.com/nodejs/node && deploy_musl_32bit_casefolding_hardened_stage3_system.sh ./node && chroot ./node.Reacted by Mike McCready, Aryan Singh, Changwoo Kang and Abdul FaridThanks for the clarification — that makes sense
I’ll proceed by making
test/parallel/test-node-output-sourcemaps.mjsfully cwd-agnostic, focusing on making the snapshot normalization path-aware so it doesn’t accidentally touch URLs or unrelated strings.I’ll keep the change minimal and scoped to the test. I’ll open a PR once I have something ready.
Hi everyone, I've opened PR #61351 to address this.
I noticed there was some recent interest in this issue, but since there wasn't an open PR yet, I went ahead and submitted a fix for the CWD-agnostic path stripping.
@monam2 @gambare2 apologies if I stepped on any ongoing work—since the solution was ready, I thought I'd push it to keep things moving. Please feel free to review or let me know if you had a different approach in mind!
- added a commit that references this issue
on Jan 15, 2026 - added a commit that references this issue
on Feb 3, 2026 I'd like to work on this issue.
@legendecas did you fix that with #61590?
- removedgood first issueIssues that are suitable for first-time contributors.Issues that are suitable for first-time contributors.
on Feb 16, 2026 github-actions commented
on Jul 20, 2026 on Jul 20, 2026 – with GitHub ActionsContributorMore actionsThis issue has been marked as stale due to 90 days of inactivity.
It will be automatically closed in 30 days if no further activity occurs. If this is still relevant, please leave a comment or update it to keep it open.- addedstaleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.Issues and PRs marked stale due to inactivity and scheduled for automatic closure.
on Jul 20, 2026
Version
v26.0.0-pre
Platform
Subsystem
test
What steps will reproduce the bug?
In realistic scenarios,
cd /is implicit: for example, right afterchrootorpivot_rootinto disposable environment.How often does it reproduce? Is there a required condition?
Always.
What is the expected behavior? Why is that the expected behavior?
All tests are expected to pass.
What do you see instead?
A bunch of failing tests. Assertions are failing with something like:
Additional information
The reason is that the tests simply remove matches to
process.cwd(). In the examples above, CWD being/nodecorruptshttp://nodejs.organd/node_modules.Obviously there are other directories that may break tests, e.g.
/test.List of tests :
test/parallel/test-node-output-v8-warning.mjstest/parallel/test-node-output-vm.mjstest/parallel/test-node-output-console.mjstest/parallel/test-node-output-sourcemaps.mjstest/parallel/test-node-output-errors.mjsAlso the most edge case is CWD being
/, assuming no conflict with/lib. In this case, additional failing tests are:test/parallel/test-cli-permission-deny-fs.js- has skips if founds itself in/etcbut doesn't check if it's even worse.test/es-module/test-esm-import-meta.mjs- uses regexps that assume that leading/and/test...are not overlapped.All of the above might be a valid good first issueIssues that are suitable for first-time contributors.
material.
And then there are at least these tests in
test-runnerthat validate test output, usingcommon/assertSnapshot.jsto normalize it:test/test-runner/test-output-abort-runs-after-hook.mjstest/test-runner/test-output-abort-hooks.mjstest/test-runner/test-output-abort-suite.mjstest/test-runner/test-output-abort.mjstest/test-runner/test-output-filtered-suite-throws.mjstest/test-runner/test-output-default-output.mjstest/test-runner/test-output-global-after-should-fail-the-test.mjstest/test-runner/test-output-source-mapped-locations.mjstest/test-runner/test-output-describe-it.mjstest/test-runner/test-output-test-runner-plan.mjstest/test-runner/test-output-hooks.mjstest/test-runner/test-output-test-timeout-flag.mjstest/test-runner/test-output-output.mjstest/test-runner/test-output-unfinished-suite-async-error.mjstest/test-runner/test-output-test-timeout-flag-with-test.mjstest/test-runner/test-output-timeout-in-before-each.mjstest/test-runner/test-output-test-runner-plan-timeout.mjstest/test-runner/test-output-lcov-reporter.mjstest/test-runner/test-output-output-cli.mjsAdjusting them individually would be an exercise in futility, so it's just an extra in case of bright ideas on making transformations from
assertSnapshotmore strict&robust and unifytest-node-output-*as well.