Skip to content
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

Normalize --findRelatedTests paths on win32 platforms #8961

Merged
merged 1 commit into from
Jan 17, 2020
Merged

Normalize --findRelatedTests paths on win32 platforms #8961

merged 1 commit into from
Jan 17, 2020

Conversation

mbelsky
Copy link
Contributor

@mbelsky mbelsky commented Sep 17, 2019

Summary

Hey, there is a fix for #8900 however I'm not sure this is the right place to normalize non flag arguments.

Test plan

I've made a few runs with "wrong" cased path on my machine. For packages\jest-core\src\FailedTestsCache.ts file I've run jest --findRelatedTests packages/jest-core/SRC/FailedTestsCache.ts and that works well.

In addition I'll cover it with some test, just before do that I'm interested in your opinion about a correct place for paths normalization.

@codecov-io
Copy link

codecov-io commented Sep 18, 2019

Codecov Report

Merging #8961 into master will decrease coverage by 0.02%.
The diff coverage is 11.11%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #8961      +/-   ##
==========================================
- Coverage   64.77%   64.74%   -0.03%     
==========================================
  Files         280      280              
  Lines       11987    11994       +7     
  Branches     2956     2957       +1     
==========================================
+ Hits         7764     7766       +2     
- Misses       3591     3596       +5     
  Partials      632      632
Impacted Files Coverage Δ
packages/jest-core/src/SearchSource.ts 59.79% <11.11%> (-4.66%) ⬇️
packages/expect/src/utils.ts 96.22% <0%> (+1.25%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9419034...2a43fe4. Read the comment docs.

Copy link
Contributor

@jeysal jeysal left a comment

Choose a reason for hiding this comment

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

I don't think this is the right way to fix this, since it makes FS calls to find out what the right casing for the path is first, so that it will later match when compared with the HasteMap that already has the whole dependency tree without having to make additional calls. I believe the right solution would be to make the matching of paths itself case insensitive (if the FS is) - just like the FS itself doesn't care about casing when looking for entries.

packages/jest-core/src/SearchSource.ts Show resolved Hide resolved
@jeysal jeysal requested a review from SimenB September 18, 2019 08:30
Copy link
Member

@SimenB SimenB left a comment

Choose a reason for hiding this comment

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

While this might not be the perfect fix, it's probably better than what we currently have? Please add a test and update the changelog

@@ -13,6 +13,7 @@
"ansi-escapes": "^4.2.1",
"chalk": "^2.0.1",
"exit": "^0.1.2",
"glob": "^7.1.3",
Copy link
Member

Choose a reason for hiding this comment

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

we already depend on micromatch here, shouldn't need another glob module

Copy link
Contributor

Choose a reason for hiding this comment

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

The difference is that glob doesn't just match strings but matches files in the FS - that's what I was referring to as extra FS calls

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've reimplemented this with micromatch. Could you review please?

@mbelsky mbelsky requested review from jeysal and SimenB January 13, 2020 06:38

let paths = globalConfig.nonFlagArgs;

if (globalConfig.findRelatedTests && 'win32' === os.platform()) {
Copy link
Member

Choose a reason for hiding this comment

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

mac by default is also case insensitive, but I'm not sure if it's possible to detect it somehow beyond checking the os?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately I don't know any api that could be used to check it

@SimenB SimenB requested a review from thymikee January 13, 2020 09:55
thymikee
thymikee previously approved these changes Jan 13, 2020
Copy link
Collaborator

@thymikee thymikee left a comment

Choose a reason for hiding this comment

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

I wouldn't mind a comment on this block of logic explaining we're targeting case-insensitive OSes. Also left one comment, otherwise it looks good

packages/jest-core/src/SearchSource.ts Show resolved Hide resolved
@thymikee thymikee dismissed their stale review January 13, 2020 15:02

changes requested

@SimenB SimenB changed the title Normalize --findRelatedTests paths on win32 platforms Normalize --findRelatedTests paths on win32 platforms Jan 17, 2020
@SimenB SimenB merged commit abaea37 into jestjs:master Jan 17, 2020
@SimenB
Copy link
Member

SimenB commented Jan 17, 2020

Thanks!

@github-actions
Copy link

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.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants