Skip to content

Commit

Permalink
test: chmod ordering is nondeterministic
Browse files Browse the repository at this point in the history
This just snapshots *whether* we had some chmods, since many of these
cases, it can be one of 2 different files in either order.
  • Loading branch information
isaacs committed Mar 4, 2023
1 parent 4cb1d47 commit ed7b2a6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 57 deletions.
54 changes: 12 additions & 42 deletions tap-snapshots/test/rimraf-windows.js.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -113,56 +113,26 @@ Array [
]
`

exports[`test/rimraf-windows.js TAP handle EPERMs on unlink by trying to chmod 0o666 async > must match snapshot 1`] = `
Array [
Array [
"chmod",
"{CWD}/test/tap-testdir-rimraf-windows-handle-EPERMs-on-unlink-by-trying-to-chmod-0o666-async/test/a",
"438",
],
]
exports[`test/rimraf-windows.js TAP handle EPERMs on unlink by trying to chmod 0o666 async > chmods 1`] = `
1
`

exports[`test/rimraf-windows.js TAP handle EPERMs on unlink by trying to chmod 0o666 sync > must match snapshot 1`] = `
Array [
Array [
"chmodSync",
"{CWD}/test/tap-testdir-rimraf-windows-handle-EPERMs-on-unlink-by-trying-to-chmod-0o666-sync/test/a",
"438",
],
]
exports[`test/rimraf-windows.js TAP handle EPERMs on unlink by trying to chmod 0o666 sync > chmods 1`] = `
1
`

exports[`test/rimraf-windows.js TAP handle EPERMs, chmod raises something other than ENOENT async > must match snapshot 1`] = `
Array []
exports[`test/rimraf-windows.js TAP handle EPERMs, chmod raises something other than ENOENT async > chmods 1`] = `
0
`

exports[`test/rimraf-windows.js TAP handle EPERMs, chmod raises something other than ENOENT sync > must match snapshot 1`] = `
Array [
Array [
"chmodSync",
"{CWD}/test/tap-testdir-rimraf-windows-handle-EPERMs-chmod-raises-something-other-than-ENOENT-sync/test/a",
"438",
],
]
exports[`test/rimraf-windows.js TAP handle EPERMs, chmod raises something other than ENOENT sync > chmods 1`] = `
1
`

exports[`test/rimraf-windows.js TAP handle EPERMs, chmod returns ENOENT async > must match snapshot 1`] = `
Array [
Array [
"chmod",
"{CWD}/test/tap-testdir-rimraf-windows-handle-EPERMs-chmod-returns-ENOENT-async/test/a",
"438",
],
]
exports[`test/rimraf-windows.js TAP handle EPERMs, chmod returns ENOENT async > chmods 1`] = `
1
`

exports[`test/rimraf-windows.js TAP handle EPERMs, chmod returns ENOENT sync > must match snapshot 1`] = `
Array [
Array [
"chmodSync",
"{CWD}/test/tap-testdir-rimraf-windows-handle-EPERMs-chmod-returns-ENOENT-sync/test/a",
"438",
],
]
exports[`test/rimraf-windows.js TAP handle EPERMs, chmod returns ENOENT sync > chmods 1`] = `
1
`
32 changes: 17 additions & 15 deletions test/rimraf-windows.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@ const t = require('tap')
const { parse, basename, relative } = require('path')
const { statSync } = require('fs')
t.formatSnapshot = calls =>
calls.map(args =>
args.map(arg =>
String(arg)
.split(process.cwd())
.join('{CWD}')
.replace(/\\/g, '/')
.replace(/.*\/(\.[a-z]\.)[^/]*$/, '{tmpfile}')
)
)
Array.isArray(calls)
? calls.map(args =>
args.map(arg =>
String(arg)
.split(process.cwd())
.join('{CWD}')
.replace(/\\/g, '/')
.replace(/.*\/(\.[a-z]\.)[^/]*$/, '{tmpfile}')
)
)
: calls

const fixture = {
a: 'a',
Expand Down Expand Up @@ -310,14 +312,14 @@ t.test('handle EPERMs on unlink by trying to chmod 0o666', async t => {
// nest it so that we clean up the mess
const path = t.testdir({ test: fixture }) + '/test'
rimrafWindowsSync(path, {})
t.matchSnapshot(CHMODS)
t.matchSnapshot(CHMODS.length, 'chmods')
t.end()
})
t.test('async', async t => {
// nest it so that we clean up the mess
const path = t.testdir({ test: fixture }) + '/test'
await rimrafWindows(path, {})
t.matchSnapshot(CHMODS)
t.matchSnapshot(CHMODS.length, 'chmods')
t.end()
})
t.end()
Expand Down Expand Up @@ -374,14 +376,14 @@ t.test('handle EPERMs, chmod returns ENOENT', async t => {
// nest it so that we clean up the mess
const path = t.testdir({ test: fixture }) + '/test'
rimrafWindowsSync(path, {})
t.matchSnapshot(CHMODS)
t.matchSnapshot(CHMODS.length, 'chmods')
t.end()
})
t.test('async', async t => {
// nest it so that we clean up the mess
const path = t.testdir({ test: fixture }) + '/test'
await rimrafWindows(path, {})
t.matchSnapshot(CHMODS)
t.matchSnapshot(CHMODS.length, 'chmods')
t.end()
})
t.end()
Expand Down Expand Up @@ -438,14 +440,14 @@ t.test('handle EPERMs, chmod raises something other than ENOENT', async t => {
// nest it so that we clean up the mess
const path = t.testdir({ test: fixture }) + '/test'
t.throws(() => rimrafWindowsSync(path, {}), { code: 'EPERM' })
t.matchSnapshot(CHMODS)
t.matchSnapshot(CHMODS.length, 'chmods')
t.end()
})
t.test('async', async t => {
// nest it so that we clean up the mess
const path = t.testdir({ test: fixture }) + '/test'
t.rejects(rimrafWindows(path, {}), { code: 'EPERM' })
t.matchSnapshot(CHMODS)
t.matchSnapshot(CHMODS.length, 'chmods')
t.end()
})
t.end()
Expand Down

0 comments on commit ed7b2a6

Please sign in to comment.