diff --git a/test/async-hooks/test-pipeconnectwrap.js b/test/async-hooks/test-pipeconnectwrap.js index b57cc63cf59e46..36980f018598f3 100644 --- a/test/async-hooks/test-pipeconnectwrap.js +++ b/test/async-hooks/test-pipeconnectwrap.js @@ -8,8 +8,7 @@ const { checkInvocations } = require('./hook-checks'); const tmpdir = require('../common/tmpdir'); const net = require('net'); -// Spawning messes up `async_hooks` state. -tmpdir.refresh({ spawn: false }); +tmpdir.refresh(); const hooks = initHooks(); hooks.enable(); diff --git a/test/async-hooks/test-statwatcher.js b/test/async-hooks/test-statwatcher.js index 48d7b0b22eedff..0b9302f21cbce5 100644 --- a/test/async-hooks/test-statwatcher.js +++ b/test/async-hooks/test-statwatcher.js @@ -11,7 +11,7 @@ const path = require('path'); if (!common.isMainThread) common.skip('Worker bootstrapping works differently -> different async IDs'); -tmpdir.refresh({ spawn: false }); +tmpdir.refresh(); const file1 = path.join(tmpdir.path, 'file1'); const file2 = path.join(tmpdir.path, 'file2'); diff --git a/test/common/README.md b/test/common/README.md index 11827d9743604a..afd054eae1fe34 100644 --- a/test/common/README.md +++ b/test/common/README.md @@ -898,11 +898,7 @@ The `tmpdir` module supports the use of a temporary directory for testing. The realpath of the testing temporary directory. -### refresh(\[opts\]) - -* `opts` [<Object>][] (optional) Extra options. - * `spawn` [<boolean>][] (default: `true`) Indicates that `refresh` is - allowed to optionally spawn a subprocess. +### refresh() Deletes and recreates the testing temporary directory. diff --git a/test/common/tmpdir.js b/test/common/tmpdir.js index 0b8465bb22fc73..defcd0da3b74fc 100644 --- a/test/common/tmpdir.js +++ b/test/common/tmpdir.js @@ -1,7 +1,6 @@ /* eslint-disable node-core/require-common-first, node-core/required-modules */ 'use strict'; -const { execSync } = require('child_process'); const fs = require('fs'); const path = require('path'); const { debuglog } = require('util'); @@ -9,7 +8,7 @@ const { isMainThread } = require('worker_threads'); const debug = debuglog('test/tmpdir'); -function rimrafSync(pathname, { spawn = true } = {}) { +function rimrafSync(pathname) { const st = (() => { try { return fs.lstatSync(pathname); @@ -25,17 +24,6 @@ function rimrafSync(pathname, { spawn = true } = {}) { return; } - // On Windows first try to delegate rmdir to a shell. - if (spawn && process.platform === 'win32' && st.isDirectory()) { - try { - // Try `rmdir` first. - execSync(`rmdir /q /s ${pathname}`, { timeout: 1000 }); - } catch (e) { - // Attempt failed. Log and carry on. - debug(e); - } - } - fs.rmdirSync(pathname, { recursive: true, maxRetries: 5 }); if (fs.existsSync(pathname)) @@ -70,7 +58,7 @@ function onexit() { process.chdir(testRoot); try { - rimrafSync(tmpPath, { spawn: false }); + rimrafSync(tmpPath); } catch (e) { console.error('Can\'t clean tmpdir:', tmpPath);