diff --git a/tap-snapshots/test/rimraf-windows.js.test.cjs b/tap-snapshots/test/rimraf-windows.js.test.cjs index 92cd6a42..f51a2783 100644 --- a/tap-snapshots/test/rimraf-windows.js.test.cjs +++ b/tap-snapshots/test/rimraf-windows.js.test.cjs @@ -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 ` diff --git a/test/rimraf-windows.js b/test/rimraf-windows.js index eca02e6e..6e4722e6 100644 --- a/test/rimraf-windows.js +++ b/test/rimraf-windows.js @@ -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', @@ -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() @@ -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() @@ -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()