berry icon indicating copy to clipboard operation
berry copied to clipboard

[Bug?]: `ZipFS › should create archives with -rw-r--r--` fails locally

Open ylemkimon opened this issue 4 years ago • 1 comments

Self-service

  • [ ] I'd be willing to implement a fix

Describe the bug

 FAIL  packages/yarnpkg-fslib/tests/ZipFS.test.ts
  ● ZipFS › should create archives with -rw-r--r--

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

    Expected: 33188
    Received: 33204

      718 |     zipFs.saveAndClose();
      719 |
    > 720 |     expect((await xfs.statPromise(archive)).mode).toStrictEqual(S_IFREG | 0o644);
          |                                                   ^
      721 |   });
      722 |
      723 |   ifNotWin32It(`should create archives with -rw-r--r-- (empty archive)`, async () => {

      at Object.<anonymous> (packages/yarnpkg-fslib/tests/ZipFS.test.ts:720:51)

  ● ZipFS › should create archives with -rw-r--r-- (empty archive)

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

    Expected: 33188
    Received: 33204

      731 |     zipFs.saveAndClose();
      732 |
    > 733 |     expect((await xfs.statPromise(archive)).mode).toStrictEqual(S_IFREG | 0o644);
          |                                                   ^
      734 |   });
      735 |
      736 |   it(`should support chmod`, async () => {

      at Object.<anonymous> (packages/yarnpkg-fslib/tests/ZipFS.test.ts:733:51)

The archive seems to be created with -rw-rw-r-- (664) in my system.

To reproduce

N/A

Environment

System:
  OS: Linux 5.8 Ubuntu 20.04.2 LTS (Focal Fossa)
  CPU: (16) x64 AMD Ryzen 7 3700X 8-Core Processor
Binaries:
  Node: 14.17.3 - /tmp/xfs-94263513/node
  Yarn: 3.1.0-rc.1.dev - /tmp/xfs-94263513/yarn
  npm: 7.19.1 - ~/.nvm/versions/node/v14.17.3/bin/npm

Also confirmed on:

Binaries:
  Node: 16.7.0 - /tmp/xfs-4e9d7c15/node
  Yarn: 3.1.0-rc.1.dev - /tmp/xfs-4e9d7c15/yarn
  npm: 7.20.3 - ~/.nvm/versions/node/v16.7.0/bin/npm

Additional context

The tests were added in #3241. /cc @paul-soporan

ylemkimon avatar Aug 29 '21 10:08 ylemkimon

I think the test may not be valid across all environments, as default file permissions depend on system configuration. Here is more information on this topic: https://stackoverflow.com/a/10221511/1857556

My Ubuntu installation has the same error. By default, UMASK is set to 022, and as a result, the expected file permissions for ZipFS must be 664.

pudovmaxim avatar Aug 21 '25 19:08 pudovmaxim