Skip to content

./integration-tests/yarn-workspaces/yarn-workspaces.test.ts fails #255

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

Closed
gomain opened this issue Sep 7, 2020 · 4 comments · Fixed by #256
Closed

./integration-tests/yarn-workspaces/yarn-workspaces.test.ts fails #255

gomain opened this issue Sep 7, 2020 · 4 comments · Fixed by #256

Comments

@gomain
Copy link
Contributor

gomain commented Sep 7, 2020

Running yarn test .*/integration-tests/yarn-workspaces/yarn-workspaces.test.ts produces these results.

yarn run v1.22.4
$ ./run-tests.sh --runInBand ./integration-tests/yarn-workspaces/yarn-workspaces.test.ts
$ rimraf dist patch-package.test*.tgz
$ tsc --project tsconfig.build.json
info Current version: 6.2.2
info New version: 0.0.0
$ rimraf dist/**/*.test.js
info Current version: 0.0.0
info New version: 6.2.2
$ /home/joe/patch-package/node_modules/.bin/jest --runInBand ./integration-tests/yarn-workspaces/yarn-workspaces.test.ts
FAIL integration-tests/yarn-workspaces/yarn-workspaces.test.ts (20.051s)
  Test yarn-workspaces:
    ✕ should exit with 0 status (7ms)
    ✓ should produce output (1ms)
    ✓ should not produce any snapshots (1ms)

  ● Test yarn-workspaces: › should exit with 0 status

    expect(received).toBe(expected) // Object.is equality

    Expected: 0
    Received: 1

      45 | 
      46 |     it("should exit with 0 status", () => {
    > 47 |       expect(result.status).toBe(0)
         |                             ^
      48 |     })
      49 | 
      50 |     const output = result.stdout.toString() + "\n" + result.stderr.toString()

      at Object.<anonymous> (integration-tests/runIntegrationTest.ts:47:29)

  console.error src/spawnSafe.ts:24
    warning workspace-aggregator-23706d10-cf86-423f-b6e1-2b2f76df610e > a > [email protected]: use String.prototype.padStart()
    warning /home/joe/patch-package/patch-package.test.1599467352.tgz > find-yarn-workspace-root > micromatch > snapdragon > source-map-resolve > [email protected]: https://github.com/lydell/resolve-url#deprecated
    warning /home/joe/patch-package/patch-package.test.1599467352.tgz > find-yarn-workspace-root > micromatch > snapdragon > source-map-resolve > [email protected]: Please see https://github.com/lydell/urix#deprecated
    npx: installed 150 in 9.722s
    Error: spawnSync git ENOENT
        at Object.spawnSync (internal/child_process.js:1066:20)
        at Object.spawnSync (child_process.js:602:24)
        at Function.spawnSync [as sync] (/home/joe/.npm/_npx/5705/lib/node_modules/patch-package/node_modules/cross-spawn/index.js:26:23)
        at Object.exports.spawnSafeSync (/home/joe/.npm/_npx/5705/lib/node_modules/patch-package/dist/spawnSafe.js:10:32)
        at git (/home/joe/.npm/_npx/5705/lib/node_modules/patch-package/dist/makePatch.js:106:32)
        at Object.makePatch (/home/joe/.npm/_npx/5705/lib/node_modules/patch-package/dist/makePatch.js:118:9)
        at /home/joe/.npm/_npx/5705/lib/node_modules/patch-package/dist/index.js:48:25
        at Array.forEach (<anonymous>)
        at Object.<anonymous> (/home/joe/.npm/_npx/5705/lib/node_modules/patch-package/dist/index.js:47:22)
        at Module._compile (internal/modules/cjs/loader.js:1075:30) {
      errno: -2,
      code: 'ENOENT',
      syscall: 'spawnSync git',
      path: 'git',
      spawnargs: [ 'init' ]
    }
    {
      error: Error: spawnSync git ENOENT
          at Object.spawnSync (internal/child_process.js:1066:20)
          at Object.spawnSync (child_process.js:602:24)
          at Function.spawnSync [as sync] (/home/joe/.npm/_npx/5705/lib/node_modules/patch-package/node_modules/cross-spawn/index.js:26:23)
          at Object.exports.spawnSafeSync (/home/joe/.npm/_npx/5705/lib/node_modules/patch-package/dist/spawnSafe.js:10:32)
          at git (/home/joe/.npm/_npx/5705/lib/node_modules/patch-package/dist/makePatch.js:106:32)
          at Object.makePatch (/home/joe/.npm/_npx/5705/lib/node_modules/patch-package/dist/makePatch.js:118:9)
          at /home/joe/.npm/_npx/5705/lib/node_modules/patch-package/dist/index.js:48:25
          at Array.forEach (<anonymous>)
          at Object.<anonymous> (/home/joe/.npm/_npx/5705/lib/node_modules/patch-package/dist/index.js:47:22)
          at Module._compile (internal/modules/cjs/loader.js:1075:30) {
        errno: -2,
        code: 'ENOENT',
        syscall: 'spawnSync git',
        path: 'git',
        spawnargs: [ 'init' ]
      },
      status: null,
      signal: null,
      output: null,
      pid: 5749,
      stdout: null,
      stderr: null
    }
    undefined
    

  console.error integration-tests/runIntegrationTest.ts:53
    tarball /home/joe/patch-package/patch-package.test.1599467352.tgz
    add patch-package to root
    [1/4] Resolving packages...
    [2/4] Fetching packages...
    [3/4] Linking dependencies...
    [4/4] Building fresh packages...
    success Saved lockfile.
    success Saved 69 new dependencies.
    info Direct dependencies
    └─ [email protected]
    info All dependencies
    ├─ @yarnpkg/[email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    └─ [email protected]
    set up postinstall scripts
    modify hoisted left-pad
    node_modules/left-pad/index.js
     7: module.exports = patch-package;
     22: function patch-package (str, len, ch) {
    create patch file
    patch-package 0.0.0
    • Creating temporary folder
    • Installing [email protected] with yarn
    • Diffing your files with clean files
    ✔ Created file patches/left-pad+1.2.0.patch
    modify unhoisted left-pad
    packages/a/node_modules/left-pad/index.js
     7: module.exports = patch-package;
     22: function patch-package (str, len, ch) {
    create patch file
    patch-package 6.2.2
    • Creating temporary folder
    • Installing [email protected] with yarn
    • Diffing your files with clean files
    
    warning workspace-aggregator-23706d10-cf86-423f-b6e1-2b2f76df610e > a > [email protected]: use String.prototype.padStart()
    warning /home/joe/patch-package/patch-package.test.1599467352.tgz > find-yarn-workspace-root > micromatch > snapdragon > source-map-resolve > [email protected]: https://github.com/lydell/resolve-url#deprecated
    warning /home/joe/patch-package/patch-package.test.1599467352.tgz > find-yarn-workspace-root > micromatch > snapdragon > source-map-resolve > [email protected]: Please see https://github.com/lydell/urix#deprecated
    npx: installed 150 in 9.722s
    Error: spawnSync git ENOENT
        at Object.spawnSync (internal/child_process.js:1066:20)
        at Object.spawnSync (child_process.js:602:24)
        at Function.spawnSync [as sync] (/home/joe/.npm/_npx/5705/lib/node_modules/patch-package/node_modules/cross-spawn/index.js:26:23)
        at Object.exports.spawnSafeSync (/home/joe/.npm/_npx/5705/lib/node_modules/patch-package/dist/spawnSafe.js:10:32)
        at git (/home/joe/.npm/_npx/5705/lib/node_modules/patch-package/dist/makePatch.js:106:32)
        at Object.makePatch (/home/joe/.npm/_npx/5705/lib/node_modules/patch-package/dist/makePatch.js:118:9)
        at /home/joe/.npm/_npx/5705/lib/node_modules/patch-package/dist/index.js:48:25
        at Array.forEach (<anonymous>)
        at Object.<anonymous> (/home/joe/.npm/_npx/5705/lib/node_modules/patch-package/dist/index.js:47:22)
        at Module._compile (internal/modules/cjs/loader.js:1075:30) {
      errno: -2,
      code: 'ENOENT',
      syscall: 'spawnSync git',
      path: 'git',
      spawnargs: [ 'init' ]
    }
    {
      error: Error: spawnSync git ENOENT
          at Object.spawnSync (internal/child_process.js:1066:20)
          at Object.spawnSync (child_process.js:602:24)
          at Function.spawnSync [as sync] (/home/joe/.npm/_npx/5705/lib/node_modules/patch-package/node_modules/cross-spawn/index.js:26:23)
          at Object.exports.spawnSafeSync (/home/joe/.npm/_npx/5705/lib/node_modules/patch-package/dist/spawnSafe.js:10:32)
          at git (/home/joe/.npm/_npx/5705/lib/node_modules/patch-package/dist/makePatch.js:106:32)
          at Object.makePatch (/home/joe/.npm/_npx/5705/lib/node_modules/patch-package/dist/makePatch.js:118:9)
          at /home/joe/.npm/_npx/5705/lib/node_modules/patch-package/dist/index.js:48:25
          at Array.forEach (<anonymous>)
          at Object.<anonymous> (/home/joe/.npm/_npx/5705/lib/node_modules/patch-package/dist/index.js:47:22)
          at Module._compile (internal/modules/cjs/loader.js:1075:30) {
        errno: -2,
        code: 'ENOENT',
        syscall: 'spawnSync git',
        path: 'git',
        spawnargs: [ 'init' ]
      },
      status: null,
      signal: null,
      output: null,
      pid: 5749,
      stdout: null,
      stderr: null
    }
    undefined
    

Test Suites: 1 failed, 1 total
Tests:       1 failed, 2 passed, 3 total
Snapshots:   0 total
Time:        20.855s
Ran all test suites matching /.\/integration-tests\/yarn-workspaces\/yarn-workspaces.test.ts/i.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Digging through the logs, I've narrowed down the root-cause to this line.

echo "create patch file"
cd packages/a
npx patch-package left-pad

I suspect npx simply downloads the released version of patch-package (which still has issue #181 #253)

Tests should use the current/working version? Not the one in the NPM registry.

@gomain
Copy link
Contributor Author

gomain commented Sep 7, 2020

It seems package/a/ is supposedly a sub-project. With it own package.json and node_modules/. How was this to come about? Is it missing from this script?

@gomain
Copy link
Contributor Author

gomain commented Sep 7, 2020

OK, I've just learned about yarn workspaces 😄

"scripts": {
"patch-package": "../../node_modules/.bin/patch-package"
},

I'm pretty sure all npx patch-package ... invocations were meant to be yarn patch-package ... invocationss. It wouldn't make sense otherwise. Doing so enables passing of the test!

I can make a PR for this.

This includes the invocation at

echo "create patch file"
npx patch-package left-pad

also is supposed to be yarn patch-package left-pad? But here, npx just happens to work.

gomain added a commit to gomain/patch-package that referenced this issue Sep 7, 2020
gomain added a commit to gomain/patch-package that referenced this issue Sep 7, 2020
@gomain
Copy link
Contributor Author

gomain commented Sep 8, 2020

I've noticed in all other integration-tests/ npx is preferred over yarn when invoking patch-package. Can someone explain to me why this is the case?

@gomain
Copy link
Contributor Author

gomain commented Sep 8, 2020

@ds300

gomain added a commit to gomain/patch-package that referenced this issue Sep 8, 2020
gomain added a commit to gomain/patch-package that referenced this issue Sep 8, 2020
@ds300 ds300 closed this as completed in #256 Mar 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant