MetaMask / module-lint

Analyzes one or more repos for divergence from a template repo.
1 stars 3 forks source link

BUG: module-lint test folder already exists #69

Open kanthesha opened 3 months ago

kanthesha commented 3 months ago

When we run the unit tests in module-lint, we use sandbox to create temp directory and files required for the unit tests and they'll be removed at the end of test cycle. But some times, we get temp folder which we create for unit tests, already exists error. This has been reported earlier and instead of creating a temp folder name with postfixing timestamp in miliseconds, it's been changed to uuid. But seems like, that bugfix is not working! I'm getting the same error when running the unit tests.

Summary of all failing tests
 FAIL  src/rules/package-typescript-scripts-conform.test.ts
  ● Rule: package-typescript-scripts-conform › passes if the typescript related scripts in template exist in project and its value matches

    ErrorWithCause: Could not write file '/var/folders/25/ryczmnrj08g0xdlfv3h5jlpw0000gn/T/module-lint-tests--1710248545124/project/package.json'

      30 |         directoryPath: path.join(sandbox.directoryPath, 'project'),
      31 |       });
    > 32 |       await writeFile(
         |       ^
      33 |         path.join(project.directoryPath, 'package.json'),
      34 |         buildPackageManifestMock({
      35 |           scripts: {

      at wrapError (node_modules/@metamask/utils/src/errors.ts:107:11)
      at writeFile (node_modules/@metamask/utils/src/fs.ts:53:28)
      at src/rules/package-typescript-scripts-conform.test.ts:32:7
      at withinSandbox (node_modules/@metamask/utils/src/fs.ts:258:9)
      at Object.<anonymous> (src/rules/package-typescript-scripts-conform.test.ts:14:5)

  ● Rule: package-typescript-scripts-conform › fails if the project has the same referenced scripts as the template, but its value does not match

    /var/folders/25/ryczmnrj08g0xdlfv3h5jlpw0000gn/T/module-lint-tests--1710248545124 already exists. Cannot continue.

      51 |
      52 |   it('fails if the project has the same referenced scripts as the template, but its value does not match', async () => {
    > 53 |     await withinSandbox(async (sandbox) => {
         |     ^
      54 |       const template = buildMetaMaskRepository({
      55 |         shortname: 'template',
      56 |         directoryPath: path.join(sandbox.directoryPath, 'template'),

      at withinSandbox (node_modules/@metamask/utils/src/fs.ts:252:15)
      at Object.<anonymous> (src/rules/package-typescript-scripts-conform.test.ts:53:5)

  ● Rule: package-typescript-scripts-conform › fails if the project does not have the same referenced script as the template

    /var/folders/25/ryczmnrj08g0xdlfv3h5jlpw0000gn/T/module-lint-tests--1710248545124 already exists. Cannot continue.

       98 |
       99 |   it('fails if the project does not have the same referenced script as the template', async () => {
    > 100 |     await withinSandbox(async (sandbox) => {
          |     ^
      101 |       const template = buildMetaMaskRepository({
      102 |         shortname: 'template',
      103 |         directoryPath: path.join(sandbox.directoryPath, 'template'),

      at withinSandbox (node_modules/@metamask/utils/src/fs.ts:252:15)
      at Object.<anonymous> (src/rules/package-typescript-scripts-conform.test.ts:100:5)

  ● Rule: package-typescript-scripts-conform › throws error if the script does not exist in the template scripts

    /var/folders/25/ryczmnrj08g0xdlfv3h5jlpw0000gn/T/module-lint-tests--1710248545124 already exists. Cannot continue.

      144 |
      145 |   it('throws error if the script does not exist in the template scripts', async () => {
    > 146 |     await withinSandbox(async (sandbox) => {
          |     ^
      147 |       const template = buildMetaMaskRepository({
      148 |         shortname: 'template',
      149 |         directoryPath: path.join(sandbox.directoryPath, 'template'),

      at withinSandbox (node_modules/@metamask/utils/src/fs.ts:252:15)
      at Object.<anonymous> (src/rules/package-typescript-scripts-conform.test.ts:146:5)

Test Suites: 1 failed, 42 passed, 43 total
Tests:       4 failed, 226 passed, 230 total
mcmire commented 3 months ago

@kanthesha Have you experienced this recently? Do you think we can mark this as solved?

kanthesha commented 3 months ago

Seems working fine after the fix. We can close this bug.