1+ import assert from "assert" ;
12import { execSync } from "child_process" ;
2- import { readdirSync } from "fs" ;
3+ import { statSync } from "fs" ;
4+ import path from "path" ;
5+ import { globIterateSync } from "glob" ;
36import type { ExecSyncOptionsWithBufferEncoding } from "child_process" ;
47
58// Turbo only supports caching on the individual task level, but for Wrangler's
@@ -27,19 +30,22 @@ const command =
2730 extraParams . join ( " " ) ;
2831
2932const failed : string [ ] = [ ] ;
30- for ( const file of readdirSync ( "packages/wrangler/e2e" ) ) {
31- if ( ! file . endsWith ( ".test.ts" ) ) {
32- // Ignore other files in the e2e directory (the README, for instance)
33- continue ;
34- }
3533
36- const WRANGLER_E2E_TEST_FILE = `e2e/${ file } ` ;
34+ const wranglerPath = path . join ( __dirname , "../../packages/wrangler" ) ;
35+ assert ( statSync ( wranglerPath ) . isDirectory ( ) ) ;
36+
37+ for ( const testFile of globIterateSync ( "e2e/**/*.test.ts" , {
38+ cwd : wranglerPath ,
39+ // Return `/` delimited paths, even on Windows.
40+ posix : true ,
41+ } ) ) {
3742 const options : ExecSyncOptionsWithBufferEncoding = {
3843 stdio : "inherit" ,
39- env : { ...process . env , WRANGLER_E2E_TEST_FILE } ,
44+ env : { ...process . env , WRANGLER_E2E_TEST_FILE : testFile } ,
4045 } ;
4146
42- console . log ( "::group::Testing: " + WRANGLER_E2E_TEST_FILE ) ;
47+ console . log ( `::group::Testing: ${ testFile } ` ) ;
48+
4349 try {
4450 execSync ( command , options ) ;
4551 } catch {
@@ -48,7 +54,7 @@ for (const file of readdirSync("packages/wrangler/e2e")) {
4854 execSync ( command , options ) ;
4955 } catch {
5056 console . error ( "Still failed, moving on" ) ;
51- failed . push ( file ) ;
57+ failed . push ( testFile ) ;
5258 }
5359 }
5460 console . log ( "::endgroup::" ) ;
0 commit comments