Skip to content

Commit 908ee54

Browse files
committed
chore: add test flake improvements to windows shim tests
1 parent 0dba79a commit 908ee54

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

test/bin/windows-shims.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const t = require('tap')
22
const { spawnSync } = require('child_process')
33
const { resolve, join, extname, basename, sep } = require('path')
4-
const { readFileSync, chmodSync, readdirSync, rmSync, statSync } = require('fs')
4+
const { copyFileSync, readFileSync, chmodSync, readdirSync, rmSync, statSync } = require('fs')
55
const Diff = require('diff')
66
const { sync: which } = require('which')
77
const { version } = require('../../package.json')
@@ -84,7 +84,6 @@ t.test('node-gyp', t => {
8484
t.test('run shims', t => {
8585
const path = t.testdir({
8686
...SHIMS,
87-
'node.exe': NODE,
8887
// simulate the state where one version of npm is installed
8988
// with node, but we should load the globally installed one
9089
'global-prefix': {
@@ -109,6 +108,16 @@ t.test('run shims', t => {
109108
},
110109
})
111110

111+
// hacky fix to decrease flakes of this test from `NOTEMPTY: directory not empty, rmdir`
112+
// this should get better in tap@18 and we can try removing it then
113+
copyFileSync(process.execPath, join(path, 'node.exe'))
114+
t.teardown(async () => {
115+
rmSync(join(path, 'node.exe'))
116+
await new Promise(res => setTimeout(res, 100))
117+
// this is superstition
118+
rmSync(join(path, 'node.exe'), { force: true })
119+
})
120+
112121
const spawnPath = (cmd, args, { log, stdioString = true, ...opts } = {}) => {
113122
if (cmd.endsWith('bash.exe')) {
114123
// only cygwin *requires* the -l, but the others are ok with it

0 commit comments

Comments
 (0)