node
node copied to clipboard
test_runner: Convert file URLs to paths in test enqueue method
The enqueue method of the test runner now converts file URLs to file paths before emitting test events. This change ensures consistency in file representations and resolves parsing issues on platforms like Windows.
- Convert file URLs to paths in the enqueue method
- Emit file paths instead of file URLs in test events
- Improve platform compatibility and consistency in file handling
#51610
Review requested:
- [ ] @nodejs/test_runner
Should we consider using URLs everywhere instead? In case we want to support test input that are not in the file system (e.g. HTTPS modules)
Can you please add a test that validates that all URLs produced are parseable? Note that I had to do https://github.com/mcollina/borp/blob/c7c99c1c70afcbd13f903b678fbbec7c821e72fc/lib/reporters.js#L6-L14 to parse this. I think this currently fails on Windows.
I generically prefer paths because https://github.com/nodejs/node/issues/51609 and writing tests is more complicated if the implementation of the conversion is system dependent.
I added a test, so sorry for my delay ❤️
please check test failures
@MoLow @anonrig Do you think it would be good to fix these tests or should I focus on my code?
test/es-module/test-cjs-legacyMainResolve.js
test/es-module/test-cjs-esm-warn.js
test/es-module/test-cjs-legacyMainResolve-permission.js
test/es-module/test-esm-cjs-builtins.js
test/es-module/test-esm-cjs-exports.js
test/es-module/test-esm-cjs-main.js
test/es-module/test-esm-encoded-path-native.js
test/es-module/test-esm-invalid-pjson.js
test/es-module/test-esm-preserve-symlinks-main.js
test/es-module/test-esm-repl-imports.js
test/parallel/test-assert-calltracker-getCalls.js
test/parallel/test-assert-esm-cjs-message-verify.js
test/parallel/test-dotenv-edge-cases.js
test/parallel/test-dotenv-node-options.js
test/parallel/test-file-write-stream5.js
test/parallel/test-fs-append-file-flush.js
test/parallel/test-fs-write-file-flush.js
test/parallel/test-fs-write-stream-flush.js
Isn't this a breaking change? Also docs should be updated
instead of the old solution I made a normalizeFilePath method and replaced the path with file if
process.platform === 'win32'
@mcollina Is it healthy to control win32 ?
@MoLow @anonrig Do you think it would be good to fix these tests or should I focus on my code?
What are the test failures, for at least a few of the representative ones?
I’m suspicious about the several module- and filesystem-related failures. If this PR changes something core to Node about how file paths/file URLs are handled, and that’s resulting in broken tests in systems beyond the test runner, that smells like a bug being introduced. I’m sympathetic to the desire to see more useful representation of test files in test runner output, but not at the cost of a breaking change that affects core stuff.
The linked issue is now closed, so I'll go ahead and close this as well. Thanks for the PR though.