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

fix: check `find` binary supports the `-iname` parameter #10308

Merged
merged 4 commits into from Jul 24, 2020

Conversation

@richardlau
Copy link
Contributor

richardlau commented Jul 23, 2020

Summary

The -iname parameter is a non-POSIX extension and may not be supported
by a POSIX compliant find binary. Add a check that the parameter is
supported when determining whether to use the native find binary.

Fixes: #10263

Test plan

Wrote included test first that failed. Test passes with changes.

@richardlau
Copy link
Contributor Author

richardlau commented Jul 23, 2020

This is the first PR I've made to a Facebook open source project. I have signed the CLA.

@richardlau richardlau force-pushed the richardlau:find branch 2 times, most recently from 7505a40 to ba354fe Jul 23, 2020
@SimenB
SimenB approved these changes Jul 24, 2020
Copy link
Collaborator

SimenB left a comment

Thanks! Can we remove the windows check now?

if (forceNodeFilesystemAPI || process.platform === 'win32') {

packages/jest-haste-map/src/crawlers/node.ts Outdated Show resolved Hide resolved
@richardlau
Copy link
Contributor Author

richardlau commented Jul 24, 2020

Thanks! Can we remove the windows check now?

I think so but when I removed

and ran the test suite on Windows I started getting test failures like:

  ● node crawler › uses node fs APIs if "forceNodeFilesystemAPI" is set to true, regardless of platform

    expect(received).toEqual(expected) // deep equality

    - Expected  - 9
    + Received  + 1

    @@ -1,15 +1,7 @@
      Map {
    -   "fruits/directory/strawberry.js" => Array [
    -     "",
    -     33,
    -     42,
    -     0,
    -     "",
    -     null,
    -   ],
    -   "fruits/tomato.js" => Array [
    +   "fruits\\tomato.js" => Array [
          "",
          32,
          42,
          0,
          "",

      at toEqual (packages/jest-haste-map/src/crawlers/__tests__/node.test.js:362:30)

so I was a bit hesitant to remove that check. Now I have some working code (the PR as it currently is) I'll take a look again (this is my first time with Jest and TypeScript so I've had to learn a lot to get to this point).

@SimenB
Copy link
Collaborator

SimenB commented Jul 24, 2020

so I was a bit hesitant to remove that check

Seems we should normalize the separator in the paths a bit. We've used slash a few places for this, maybe worth a go? I don't have access to a Windows machine myself unfortunately, so I'm not able to provide much help 😞

this is my first time with Jest and TypeScript so I've had to learn a lot to get to this point

Thank you so much for spending the time! 🙏

@SimenB
Copy link
Collaborator

SimenB commented Jul 24, 2020

Btw, making those unit tests work on Windows is not in any way a blocker. We run almost all integration tests on windows as well, and if removing that check for windows still passes CI I'm happy to merge while still skipping the unit tests on Windows 🙂

@richardlau
Copy link
Contributor Author

richardlau commented Jul 24, 2020

I have the jest-haste-map test suite passing on Windows locally now (🎉). Hopefully the CI agrees 🤞.

richardlau added 3 commits Jul 23, 2020
The `-iname` parameter is a non-POSIX extension and may not be supported
by a POSIX compliant find binary. Add a check that the parameter is
supported when determining whether to use the native find binary.
Enable detection of a compatible find binary on Windows. Fix tests
so that they run and pass on Windows.
@richardlau richardlau force-pushed the richardlau:find branch from 15d3b68 to 6e1dd00 Jul 24, 2020
@SimenB
SimenB approved these changes Jul 24, 2020
Copy link
Collaborator

SimenB left a comment

Thank you!

@SimenB SimenB changed the title Check find binary supports the `-iname` parameter fix: check `find` binary supports the `-iname` parameter Jul 24, 2020
@SimenB SimenB merged commit 6ad3a74 into facebook:master Jul 24, 2020
14 of 23 checks passed
14 of 23 checks passed
cleanup-runs
Details
Running TypeScript compiler & ESLint
Details
Node v10.x on ubuntu-latest
Details
Node v10.x on macOS-latest
Details
Node v10.x on windows-latest
Details
Node v12.x on ubuntu-latest
Details
Node v12.x on macOS-latest
Details
Node v12.x on windows-latest
Details
Node v13.x on ubuntu-latest
Details
Node v13.x on macOS-latest
Details
Node v13.x on windows-latest
Details
Node v14.x on ubuntu-latest
Details
Node v14.x on macOS-latest
Details
Node v14.x on windows-latest Node v14.x on windows-latest
Details
ci/circleci: test-jest-circus CircleCI is running your tests
Details
ci/circleci: test-node-10 CircleCI is running your tests
Details
ci/circleci: test-node-12 CircleCI is running your tests
Details
ci/circleci: test-node-13 CircleCI is running your tests
Details
ci/circleci: test-node-14 CircleCI is running your tests
Details
ci/circleci: test-or-deploy-website CircleCI is running your tests
Details
continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
facebook.jest in progress
Details
Facebook CLA Check Contributor License Agreement is valid!
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

3 participants
You can’t perform that action at this time.