New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: Windows path parsing for JUnit (fixes #12507) #12509
Fix: Windows path parsing for JUnit (fixes #12507) #12509
Conversation
This commit aims to fix the issues described in eslint#12507 by removing the assumption that POSIX style filePaths are supplied by messages. The tests for this are also updated to run on both Windows and POSIX based systems. The results can be seen by running ESLint with the JUnit formatter on a Windows system. Full details can be seen in the issue mentioned above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally, I think this looks good. One question I have (and I'm not sure of the answer): Do we want to rely on our CI that runs our tests in multiple OS's to exercise this code, or should we be mocking process.platform
in these tests to ensure these code paths are always hit?
I did some investigation on this and it seems less feasible to test this way, although I agree this would have been nicer. If we mock |
Addresses some comments.
Understood - thanks for the detailed explanation! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This LGTM, but I'm not marking as accepted yet because I haven't been able to verify the issue. Will try to do so later today!
Sorry, my Windows machine is on the fritz. Will need to fix it tomorrow to be able to test this. If someone else from the team is able to verify this bug, please feel free to mark as accepted. |
Thanks for contributing! |
This commit aims to fix the issues described in #12507 by removing the
assumption that POSIX style filePaths are supplied by messages.
The tests for this are also updated to run on both Windows and POSIX
based systems. The results can be seen by running ESLint with the JUnit
formatter on a Windows system.
Full details can be seen in the issue mentioned above.
What is the purpose of this pull request? (put an "X" next to item)
This PR is a followup to fix a missed bug introduced in #11683 where Windows paths are not supported properly.
[ ] Documentation update
[X] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofixing to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:
What changes did you make? (Give an overview)
I changed the function
pathWithoutExt(filePath)
so that it does not assume POSIX style paths. Instead it will allow Node to determine which style of path to expect (POSIX or Windows) based on the OS.From looking at the original PR it seems that this change to assume POSIX was done after the changes were approved, and might have been to force tests to pass (but I did not verify this).
Hence, I also updated the tests for the JUnit formatter so that they should run correctly on both Windows and *Nix machines by passing in an OS relevant
suppliedFilePath
to the test, and verifying with an OS relevantexpectedClassName
.Is there anything you'd like reviewers to focus on?
Test sanity.