Skip to content

Commit

Permalink
chore: add test flake improvements to windows shim tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lukekarrys committed Oct 30, 2023
1 parent 0dba79a commit 908ee54
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions test/bin/windows-shims.js
Original file line number Diff line number Diff line change
@@ -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')
Expand Down Expand Up @@ -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': {
Expand All @@ -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
Expand Down

0 comments on commit 908ee54

Please sign in to comment.