-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Add path case-insensitivity if onlyChanged option is active, fixes #4644 #4730
Conversation
Thanks for sending a PR. What if people use windows with a case sensitive file system? This would break for them, no? |
Or macOS with case sensitivity turned on, is it an issue there as well? That said, this is definitely a bug fix, and we have other breaking changes in master already, so next release should be a major anyways |
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.
Needs a test.
Also, please update the changelog
Is it possible to check for case sensitivity? https://superuser.com/a/1026536 or something in the startup |
Thanks for your feedback. I agree to you, this should be handled in a more complex way. I have reverted the original changes. Instead changed how If this solution is ok for you, maybe we can discuss about doing the same if For reference: |
packages/jest-cli/src/cli/index.js
Outdated
@@ -142,7 +142,11 @@ const getProjectListFromCLIArgs = (argv, project: ?Path) => { | |||
} | |||
|
|||
if (!projects.length) { | |||
projects.push(process.cwd()); | |||
if (process.platform === 'win32') { | |||
projects.push(process.binding('fs').realpath(process.cwd())); |
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.
why not fs.realpathSync()
? process.binding
seems overkill
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.
fs.realpathSync() does not correct the path.
They differ:
fs.realpathSync(process.cwd()):
C:\Users\pdanis\desktop\projects\my-js-learning\other\temp
(edit: corrected \\projects to \projects)
process.binding('fs').realpath(process.cwd()):
C:\Users\pdanis\Desktop\Projects\my-js-learning\other\temp
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.
Huh, that's weird
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.
If I understand it correctly fs.realpathSync()
uses JS
fs and process.binding('fs').realpath()
is using GetFinalPathNameByHandle()
on Windows.
There is a PR, which should expose process.binding('fs').realpath()
as fs.realpathSync.native()
.
nodejs/node#15776
I think the change here makes sense. @cpojer thoughts? This still needs a test, though 🙂 |
Test added and changelog updated. Should I squash the commits together? |
We squash on merge, so multiple commits are easier to review. Thanks! |
@@ -82,7 +82,12 @@ const cleanup = (directory: string) => rimraf.sync(directory); | |||
const writeFiles = (directory: string, files: {[filename: string]: string}) => { | |||
mkdirp.sync(directory); | |||
Object.keys(files).forEach(fileOrPath => { | |||
const filePath = fileOrPath.split(path.sep); // ['tmp', 'a.js'] |
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.
can we do const filePath = fileOrPath.split(path.posix.sep);
here? (or just fileOrPath.split('/')
)
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.
Thanks for suggestion. Changed to const filePath = fileOrPath.split('/')
@peterdanis this fails flow, run |
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.
Would love to actually see a green appveyor. Can we clear the queue manually? The site does not cooperate with mobile
The AppVeyor issues should be resolved, @cpojer reached out to me about it two weeks ago. I need to figure out how to move the Jest project to the Facebook org on AppVeyor. https://help.appveyor.com/discussions/problems/9507-large-number-of-builds-are-queued |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
This PR fixes #4644. On Windows
process.cwd
andgit rev-parse --show-toplevel
outputs can diverge in the same directory:This is causing Jest run in
onlyChanged
mode to find no suitable tests.Test plan
After changing theexists
function and_rootPattern
variable to case-insensitive regex (on "win32" platform only),jest -o
runs fine:I have reverted the original changes. Instead changed how projects array is constructed if no --projects option is defined. I think it is only affecting Windows, because on MacOS and Linux process.cwd() should return the correct case (see the first comment in nodejs/node#8237).