diff options
author | Gar <gar+gh@danger.computer> | 2022-04-13 18:43:23 +0300 |
---|---|---|
committer | Nathan Fritz <fritzy@github.com> | 2022-04-14 00:36:24 +0300 |
commit | 0cd852f62e1453e647a2551e98c78ce7e0c8ea03 (patch) | |
tree | 1c81c0e800e4f52835227980944dddfc6e6962b8 | |
parent | 71ab00ac3021e147c3fac19268f8e22bd163e529 (diff) |
fix: mitigate doctor test race condition
cacache appears to not write everything to the cache by the time doctor
is checking permissions. This limits the permissions error to a single
directory that we know exists by the time the checks run.
-rw-r--r-- | tap-snapshots/test/lib/commands/doctor.js.test.cjs | 98 | ||||
-rw-r--r-- | test/lib/commands/doctor.js | 6 |
2 files changed, 5 insertions, 99 deletions
diff --git a/tap-snapshots/test/lib/commands/doctor.js.test.cjs b/tap-snapshots/test/lib/commands/doctor.js.test.cjs index a28654e5d..d84d7d368 100644 --- a/tap-snapshots/test/lib/commands/doctor.js.test.cjs +++ b/tap-snapshots/test/lib/commands/doctor.js.test.cjs @@ -467,7 +467,7 @@ node -v ok current: v1.0.0, recommended: v1.0.0 npm config get registry ok using default registry (https://registry.npmjs.org/) which git ok /path/to/git Perms check on cached files not ok Check the permissions of files in {CWD}/test/lib/commands/tap-testdir-doctor-incorrect-owner/cache (should be owned by current user) -Perms check on local node_modules not ok Check the permissions of files in {CWD}/test/lib/commands/tap-testdir-doctor-incorrect-owner/prefix/node_modules (should be owned by current user) +Perms check on local node_modules ok Perms check on global node_modules ok Perms check on local bin folder ok Perms check on global bin folder ok @@ -516,104 +516,8 @@ Object { "warn": Array [ Array [ "checkFilesPermission", - "should be owner of {CWD}/test/lib/commands/tap-testdir-doctor-incorrect-owner/cache", - ], - Array [ - "checkFilesPermission", "should be owner of {CWD}/test/lib/commands/tap-testdir-doctor-incorrect-owner/cache/_cacache", ], - Array [ - "checkFilesPermission", - "should be owner of {CWD}/test/lib/commands/tap-testdir-doctor-incorrect-owner/cache/_logs", - ], - Array [ - "checkFilesPermission", - "should be owner of {CWD}/test/lib/commands/tap-testdir-doctor-incorrect-owner/cache/_cacache/content-v2", - ], - Array [ - "checkFilesPermission", - "should be owner of {CWD}/test/lib/commands/tap-testdir-doctor-incorrect-owner/cache/_cacache/index-v5", - ], - Array [ - "checkFilesPermission", - "should be owner of {CWD}/test/lib/commands/tap-testdir-doctor-incorrect-owner/cache/_cacache/tmp", - ], - Array [ - "checkFilesPermission", - "should be owner of {CWD}/test/lib/commands/tap-testdir-doctor-incorrect-owner/cache/_logs/{DATE}-debug-0.log", - ], - Array [ - "checkFilesPermission", - "should be owner of {CWD}/test/lib/commands/tap-testdir-doctor-incorrect-owner/cache/_cacache/content-v2/sha512", - ], - Array [ - "checkFilesPermission", - "should be owner of {CWD}/test/lib/commands/tap-testdir-doctor-incorrect-owner/cache/_cacache/index-v5/5e", - ], - Array [ - "checkFilesPermission", - "should be owner of {CWD}/test/lib/commands/tap-testdir-doctor-incorrect-owner/cache/_cacache/index-v5/af", - ], - Array [ - "checkFilesPermission", - "should be owner of {CWD}/test/lib/commands/tap-testdir-doctor-incorrect-owner/cache/_cacache/content-v2/sha512/{sha}", - ], - Array [ - "checkFilesPermission", - "should be owner of {CWD}/test/lib/commands/tap-testdir-doctor-incorrect-owner/cache/_cacache/content-v2/sha512/{sha}", - ], - Array [ - "checkFilesPermission", - "should be owner of {CWD}/test/lib/commands/tap-testdir-doctor-incorrect-owner/cache/_cacache/index-v5/5e/be", - ], - Array [ - "checkFilesPermission", - "should be owner of {CWD}/test/lib/commands/tap-testdir-doctor-incorrect-owner/cache/_cacache/index-v5/af/03", - ], - Array [ - "checkFilesPermission", - "should be owner of {CWD}/test/lib/commands/tap-testdir-doctor-incorrect-owner/cache/_cacache/content-v2/sha512/{sha}", - ], - Array [ - "checkFilesPermission", - "should be owner of {CWD}/test/lib/commands/tap-testdir-doctor-incorrect-owner/cache/_cacache/content-v2/sha512/{sha}", - ], - Array [ - "checkFilesPermission", - "should be owner of {CWD}/test/lib/commands/tap-testdir-doctor-incorrect-owner/cache/_cacache/index-v5/5e/be/ccdeeea0a01ebb0e365e566161f7c68ddcbbe04206d8542742d98875f03f", - ], - Array [ - "checkFilesPermission", - "should be owner of {CWD}/test/lib/commands/tap-testdir-doctor-incorrect-owner/cache/_cacache/index-v5/af/03/5c781820370e585dc2323edbbc80669bf714da5b47d56510c7d0bd7521ee", - ], - Array [ - "checkFilesPermission", - "should be owner of {CWD}/test/lib/commands/tap-testdir-doctor-incorrect-owner/cache/_cacache/content-v2/sha512/{sha}", - ], - Array [ - "checkFilesPermission", - "should be owner of {CWD}/test/lib/commands/tap-testdir-doctor-incorrect-owner/cache/_cacache/content-v2/sha512/{sha}", - ], - Array [ - "checkFilesPermission", - "should be owner of {CWD}/test/lib/commands/tap-testdir-doctor-incorrect-owner/prefix/node_modules", - ], - Array [ - "checkFilesPermission", - "should be owner of {CWD}/test/lib/commands/tap-testdir-doctor-incorrect-owner/prefix/node_modules/.bin", - ], - Array [ - "checkFilesPermission", - "should be owner of {CWD}/test/lib/commands/tap-testdir-doctor-incorrect-owner/prefix/node_modules/testDir", - ], - Array [ - "checkFilesPermission", - "should be owner of {CWD}/test/lib/commands/tap-testdir-doctor-incorrect-owner/prefix/node_modules/testLink", - ], - Array [ - "checkFilesPermission", - "should be owner of {CWD}/test/lib/commands/tap-testdir-doctor-incorrect-owner/prefix/node_modules/testDir/testFile", - ], ], } ` diff --git a/test/lib/commands/doctor.js b/test/lib/commands/doctor.js index 620d908d3..eaf2ee6c6 100644 --- a/test/lib/commands/doctor.js +++ b/test/lib/commands/doctor.js @@ -359,8 +359,10 @@ t.test('incorrect owner', async t => { ...fs, lstat: (p, cb) => { const stat = fs.lstatSync(p) - stat.uid += 1 - stat.gid += 1 + if (p.endsWith('_cacache')) { + stat.uid += 1 + stat.gid += 1 + } return cb(null, stat) }, }, |