11const t = require ( 'tap' )
22const { spawnSync } = require ( 'child_process' )
33const { 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' )
55const Diff = require ( 'diff' )
66const { sync : which } = require ( 'which' )
77const { version } = require ( '../../package.json' )
@@ -84,7 +84,6 @@ t.test('node-gyp', t => {
8484t . 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