@@ -12,7 +12,7 @@ import * as minimist from 'minimist';
1212import * as vscodetest from '@vscode/test-electron' ;
1313import fetch from 'node-fetch' ;
1414import { Quality , MultiLogger , Logger , ConsoleLogger , FileLogger , measureAndLog , getDevElectronPath , getBuildElectronPath , getBuildVersion , ApplicationOptions } from '../../automation' ;
15- import { retry , timeout } from './utils' ;
15+ import { retry } from './utils' ;
1616
1717import { setup as setupDataLossTests } from './areas/workbench/data-loss.test' ;
1818import { setup as setupPreferencesTests } from './areas/preferences/preferences.test' ;
@@ -102,7 +102,7 @@ function createLogger(): Logger {
102102 }
103103
104104 // Prepare logs rot path
105- fs . rmSync ( logsRootPath , { recursive : true , force : true , maxRetries : 3 } ) ;
105+ fs . rmSync ( logsRootPath , { recursive : true , force : true , maxRetries : 10 , retryDelay : 1000 } ) ;
106106 fs . mkdirSync ( logsRootPath , { recursive : true } ) ;
107107
108108 // Always log to log file
@@ -117,19 +117,6 @@ try {
117117 logger . log ( `Error enabling graceful-fs: ${ error } ` ) ;
118118}
119119
120- const testDataPath = path . join ( os . tmpdir ( ) , 'vscsmoke' ) ;
121- if ( fs . existsSync ( testDataPath ) ) {
122- fs . rmSync ( testDataPath , { recursive : true , force : true , maxRetries : 10 } ) ;
123- }
124- fs . mkdirSync ( testDataPath , { recursive : true } ) ;
125- process . once ( 'exit' , ( ) => {
126- try {
127- fs . rmSync ( testDataPath , { recursive : true , force : true , maxRetries : 10 } ) ;
128- } catch {
129- // noop
130- }
131- } ) ;
132-
133120function getTestTypeSuffix ( ) : string {
134121 if ( opts . web ) {
135122 return 'browser' ;
@@ -140,8 +127,21 @@ function getTestTypeSuffix(): string {
140127 }
141128}
142129
130+ const testDataPath = path . join ( os . tmpdir ( ) , `vscsmoke-${ getTestTypeSuffix ( ) } ` ) ;
131+ if ( fs . existsSync ( testDataPath ) ) {
132+ fs . rmSync ( testDataPath , { recursive : true , force : true , maxRetries : 10 , retryDelay : 1000 } ) ;
133+ }
134+ fs . mkdirSync ( testDataPath , { recursive : true } ) ;
135+ process . once ( 'exit' , ( ) => {
136+ try {
137+ fs . rmSync ( testDataPath , { recursive : true , force : true , maxRetries : 10 , retryDelay : 1000 } ) ;
138+ } catch {
139+ // noop
140+ }
141+ } ) ;
142+
143143const testRepoUrl = 'https://github.com/microsoft/vscode-smoketest-express' ;
144- const workspacePath = path . join ( testDataPath , `vscode-smoketest-express- ${ getTestTypeSuffix ( ) } ` ) ;
144+ const workspacePath = path . join ( testDataPath , `vscode-smoketest-express` ) ;
145145const extensionsPath = path . join ( testDataPath , 'extensions-dir' ) ;
146146fs . mkdirSync ( extensionsPath , { recursive : true } ) ;
147147
@@ -245,7 +245,7 @@ const userDataDir = path.join(testDataPath, 'd');
245245async function setupRepository ( ) : Promise < void > {
246246 if ( opts [ 'test-repo' ] ) {
247247 logger . log ( 'Copying test project repository:' , opts [ 'test-repo' ] ) ;
248- fs . rmSync ( workspacePath , { recursive : true , force : true , maxRetries : 10 } ) ;
248+ fs . rmSync ( workspacePath , { recursive : true , force : true , maxRetries : 10 , retryDelay : 1000 } ) ;
249249 // not platform friendly
250250 if ( process . platform === 'win32' ) {
251251 cp . execSync ( `xcopy /E "${ opts [ 'test-repo' ] } " "${ workspacePath } "\\*` ) ;
@@ -314,15 +314,9 @@ async function ensureStableCode(): Promise<void> {
314314 } ,
315315 error : error => logger . log ( `download stable code error: ${ error } ` )
316316 }
317- } ) , 'download stable code' , logger ) , 1000 , 3 , ( ) => new Promise < void > ( ( resolve , reject ) => {
318- fs . rm ( stableCodeDestination , { recursive : true , force : true , maxRetries : 10 } , error => {
319- if ( error ) {
320- reject ( error ) ;
321- } else {
322- resolve ( ) ;
323- }
324- } ) ;
325- } ) ) ;
317+ } ) , 'download stable code' , logger ) , 1000 , 3 , async ( ) => {
318+ fs . rmSync ( stableCodeDestination , { recursive : true , force : true , maxRetries : 10 , retryDelay : 1000 } ) ;
319+ } ) ;
326320
327321 if ( process . platform === 'darwin' ) {
328322 // Visual Studio Code.app/Contents/MacOS/Electron
@@ -388,22 +382,9 @@ before(async function () {
388382// After main suite (after all tests)
389383after ( async function ( ) {
390384 try {
391- let deleted = false ;
392- await measureAndLog ( ( ) => Promise . race ( [
393- new Promise < void > ( ( resolve , reject ) => fs . rm ( testDataPath , { recursive : true , force : true , maxRetries : 10 } , error => {
394- if ( error ) {
395- reject ( error ) ;
396- } else {
397- deleted = true ;
398- resolve ( ) ;
399- }
400- } ) ) ,
401- timeout ( 30000 ) . then ( ( ) => {
402- if ( ! deleted ) {
403- throw new Error ( 'giving up after 30s' ) ;
404- }
405- } )
406- ] ) , 'rimraf(testDataPath)' , logger ) ;
385+ await measureAndLog ( async ( ) => {
386+ fs . rmSync ( testDataPath , { recursive : true , force : true , maxRetries : 10 , retryDelay : 1000 } ) ;
387+ } , 'rimraf(testDataPath)' , logger ) ;
407388 } catch ( error ) {
408389 logger . log ( `Unable to delete smoke test workspace: ${ error } . This indicates some process is locking the workspace folder.` ) ;
409390 }
0 commit comments