@@ -109,7 +109,7 @@ function createTestFileList(patterns) {
109109
110110function filterExecArgv ( arg , i , arr ) {
111111 return ! ArrayPrototypeIncludes ( kFilterArgs , arg ) &&
112- ! ArrayPrototypeSome ( kFilterArgValues , ( p ) => arg === p || ( i > 0 && arr [ i - 1 ] === p ) || StringPrototypeStartsWith ( arg , `${ p } =` ) ) ;
112+ ! ArrayPrototypeSome ( kFilterArgValues , ( p ) => arg === p || ( i > 0 && arr [ i - 1 ] === p ) || StringPrototypeStartsWith ( arg , `${ p } =` ) ) ;
113113}
114114
115115function getRunArgs ( path , { forceExit, inspectPort, testNamePatterns, testSkipPatterns, only } ) {
@@ -166,7 +166,7 @@ class FileTest extends Test {
166166 if ( firstSpaceIndex === - 1 ) return false ;
167167 const secondSpaceIndex = StringPrototypeIndexOf ( comment , ' ' , firstSpaceIndex + 1 ) ;
168168 return secondSpaceIndex === - 1 &&
169- ArrayPrototypeIncludes ( kDiagnosticsFilterArgs , StringPrototypeSlice ( comment , 0 , firstSpaceIndex ) ) ;
169+ ArrayPrototypeIncludes ( kDiagnosticsFilterArgs , StringPrototypeSlice ( comment , 0 , firstSpaceIndex ) ) ;
170170 }
171171 #handleReportItem( item ) {
172172 const isTopLevel = item . data . nesting === 0 ;
@@ -416,7 +416,22 @@ function watchFiles(testFiles, opts) {
416416 const watcher = new FilesWatcher ( { __proto__ : null , debounce : 200 , mode : 'filter' , signal : opts . signal } ) ;
417417 const filesWatcher = { __proto__ : null , watcher, runningProcesses, runningSubtests } ;
418418 opts . root . harness . watching = true ;
419+ // Watch for created/deleted files in the current directory
420+ const allFilesWatcher = new FilesWatcher ( { __proto__ : null , debounce : 200 , mode : 'all' , signal : opts . signal } ) ;
421+ allFilesWatcher . watchPath ( process . cwd ( ) ) ;
422+ allFilesWatcher . on ( 'changed' , ( { owners, eventType } ) => {
423+ if ( eventType === 'rename' ) {
424+ const updatedTestFiles = createTestFileList ( opts . globPatterns ) ;
425+
426+ const newFiles = ArrayPrototypeFilter ( updatedTestFiles , ( x ) => ! ArrayPrototypeIncludes ( testFiles , x ) ) ;
419427
428+ testFiles = updatedTestFiles ;
429+ newFiles . forEach ( ( newFile ) => {
430+ watcher . emit ( 'changed' , { __proto__ : null , owners : new SafeSet ( ) . add ( newFile ) , eventType : 'rename' } ) ;
431+ } ) ;
432+ }
433+ } ) ;
434+ // Watch for changes in current filtered files
420435 watcher . on ( 'changed' , ( { owners, eventType } ) => {
421436 if ( ! opts . hasFiles && eventType === 'rename' ) {
422437 const updatedTestFiles = createTestFileList ( opts . globPatterns ) ;
0 commit comments