node icon indicating copy to clipboard operation
node copied to clipboard

test_runner: Convert file URLs to paths in test enqueue method

Open mertcanaltin opened this issue 1 year ago • 8 comments

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

mertcanaltin avatar Jan 31 '24 13:01 mertcanaltin

Review requested:

  • [ ] @nodejs/test_runner

nodejs-github-bot avatar Jan 31 '24 13:01 nodejs-github-bot

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)

aduh95 avatar Jan 31 '24 13:01 aduh95

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.

mcollina avatar Jan 31 '24 16:01 mcollina

I added a test, so sorry for my delay ❤️

mertcanaltin avatar Feb 02 '24 19:02 mertcanaltin

please check test failures

MoLow avatar Feb 11 '24 11:02 MoLow

Isn't this a breaking change? Also docs should be updated

rluvaton avatar Feb 13 '24 08:02 rluvaton

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 ?

mertcanaltin avatar Feb 17 '24 08:02 mertcanaltin

@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.

GeoffreyBooth avatar Feb 17 '24 19:02 GeoffreyBooth

The linked issue is now closed, so I'll go ahead and close this as well. Thanks for the PR though.

cjihrig avatar Mar 24 '24 14:03 cjihrig