diff --git a/test/bin/windows-shims.js b/test/bin/windows-shims.js index 9ee8d9a0854c6..5fa6ff142b737 100644 --- a/test/bin/windows-shims.js +++ b/test/bin/windows-shims.js @@ -1,7 +1,7 @@ const t = require('tap') const { spawnSync } = require('child_process') const { resolve, join, extname, basename, sep } = require('path') -const { readFileSync, chmodSync, readdirSync, rmSync, statSync } = require('fs') +const { copyFileSync, readFileSync, chmodSync, readdirSync, rmSync, statSync } = require('fs') const Diff = require('diff') const { sync: which } = require('which') const { version } = require('../../package.json') @@ -84,7 +84,6 @@ t.test('node-gyp', t => { t.test('run shims', t => { const path = t.testdir({ ...SHIMS, - 'node.exe': NODE, // simulate the state where one version of npm is installed // with node, but we should load the globally installed one 'global-prefix': { @@ -109,6 +108,16 @@ t.test('run shims', t => { }, }) + // hacky fix to decrease flakes of this test from `NOTEMPTY: directory not empty, rmdir` + // this should get better in tap@18 and we can try removing it then + copyFileSync(process.execPath, join(path, 'node.exe')) + t.teardown(async () => { + rmSync(join(path, 'node.exe')) + await new Promise(res => setTimeout(res, 100)) + // this is superstition + rmSync(join(path, 'node.exe'), { force: true }) + }) + const spawnPath = (cmd, args, { log, stdioString = true, ...opts } = {}) => { if (cmd.endsWith('bash.exe')) { // only cygwin *requires* the -l, but the others are ok with it