Skip to content

Fix other.test_argv0_node with Windows 8.3 short paths - #28195

Merged
dschuff merged 2 commits into
emscripten-core:mainfrom
dschuff:node-argv
Nov 7, 2026
Merged

dschuff merged 2 commits into
emscripten-core:mainfrom
dschuff:node-argv

Conversation

@dschuff

@dschuff dschuff commented Nov 6, 2026

Copy link
Copy Markdown
Member

Node sets process.argv[1] via fs.realpathSync(), which resolves symlinks (such as /var -> /private/var on macOS) without expanding Windows 8.3 short names (such as C:/Users/RUNNER~1/... when %TEMP% belongs to a username longer than 8 characters like runneradmin). Python 3.8+'s os.path.realpath() on Windows uses GetFinalPathNameByHandleW and expands 8.3 short names, so normalize both the expected path and the path reported in argv[0] with os.path.realpath().

Node sets process.argv[1] via fs.realpathSync(), which resolves symlinks (such as /var -> /private/var on macOS) without expanding Windows 8.3 short names (such as C:/Users/RUNNER~1/... when %TEMP% belongs to a username longer than 8 characters like runneradmin). Python 3.8+'s os.path.realpath() on Windows uses GetFinalPathNameByHandleW and expands 8.3 short names, so normalize both the expected path and the path reported in argv[0] with os.path.realpath().

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates a test in test/test_other.py to extract a path from the output using a regular expression and compare it using assertPathsIdentical to handle platform-specific path resolution. The reviewer identified a potential issue on Windows where carriage return characters could cause the regular expression match to fail, and provided a suggestion to make the regex pattern more robust.

Comment thread test/test_other.py Resolved
Comment thread test/test_other.py Outdated
# Resolve both paths with realpath: Node's process.argv[1] resolves symlinks
# (e.g. /var -> /private/var on macOS) without expanding Windows 8.3 short
# names (e.g. RUNNER~1 -> runneradmin), whereas Python's realpath resolves both.
self.assertPathsIdentical(os.path.realpath(self.in_dir('code.js')), os.path.realpath(m.group(1)))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you do something like this:

expected = os.path.realpath(self.in_dir('code.js))
self.assertContains(output, f'I am ${expected}')

?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have to run realpath on both the expected path and the output. But here's a version that's simpler and doesn't need the regex.

Comment thread test/test_other.py
# Resolve both paths with realpath: Node's process.argv[1] resolves symlinks
# (e.g. /var -> /private/var on macOS) without expanding Windows 8.3 short
# names (e.g. RUNNER~1 -> runneradmin), whereas Python's realpath resolves both.
self.assertPathsIdentical(os.path.realpath(self.in_dir('code.js')), os.path.realpath(output))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whats wrong with keeping the assertContained version? I'm not sure what assertPathsIdentical does?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assertPathsIdentical just calls utils.normalize_path (which just swaps windows for Unix forward slashes) on each path. I guess it's jsut a bit more robust.
Also I think the problem with the assertContained version is that you want to run realpath on both the expected output (which your suggestion does) and also the actual output (which it doesn't).

@dschuff
dschuff merged commit 57c9a53 into emscripten-core:main Nov 7, 2026
36 of 43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants