1
1
const t = require ( 'tap' )
2
2
const { spawnSync } = require ( 'child_process' )
3
3
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' )
5
5
const Diff = require ( 'diff' )
6
6
const { sync : which } = require ( 'which' )
7
7
const { version } = require ( '../../package.json' )
@@ -84,7 +84,6 @@ t.test('node-gyp', t => {
84
84
t . test ( 'run shims' , t => {
85
85
const path = t . testdir ( {
86
86
...SHIMS ,
87
- 'node.exe' : NODE ,
88
87
// simulate the state where one version of npm is installed
89
88
// with node, but we should load the globally installed one
90
89
'global-prefix' : {
@@ -109,6 +108,16 @@ t.test('run shims', t => {
109
108
} ,
110
109
} )
111
110
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
+
112
121
const spawnPath = ( cmd , args , { log, stdioString = true , ...opts } = { } ) => {
113
122
if ( cmd . endsWith ( 'bash.exe' ) ) {
114
123
// only cygwin *requires* the -l, but the others are ok with it
0 commit comments