@@ -12,6 +12,9 @@ import { join } from 'node:path';
12
12
if ( common . isIBMi )
13
13
common . skip ( 'IBMi does not support `fs.watch()`' ) ;
14
14
15
+ if ( common . isAIX )
16
+ common . skip ( 'folder watch capability is limited in AIX.' ) ;
17
+
15
18
// This test updates these files repeatedly,
16
19
// Reading them from disk is unreliable due to race conditions.
17
20
const fixtureContent = {
@@ -60,6 +63,8 @@ async function testWatch({ fileToUpdate, file, action = 'update', cwd = tmpdir.p
60
63
61
64
const testUpdate = async ( ) => {
62
65
await ran1 . promise ;
66
+ runs . push ( currentRun ) ;
67
+ currentRun = '' ;
63
68
const content = fixtureContent [ fileToUpdate ] ;
64
69
const path = fixturePaths [ fileToUpdate ] ;
65
70
const interval = setInterval ( ( ) => writeFileSync ( path , content ) , common . platformTimeout ( 1000 ) ) ;
@@ -68,6 +73,9 @@ async function testWatch({ fileToUpdate, file, action = 'update', cwd = tmpdir.p
68
73
clearInterval ( interval ) ;
69
74
child . kill ( ) ;
70
75
await once ( child , 'exit' ) ;
76
+
77
+ assert . strictEqual ( runs . length , 2 ) ;
78
+
71
79
for ( const run of runs ) {
72
80
assert . doesNotMatch ( run , / r u n \( \) i s b e i n g c a l l e d r e c u r s i v e l y / ) ;
73
81
assert . match ( run , / # t e s t s 1 / ) ;
@@ -79,6 +87,8 @@ async function testWatch({ fileToUpdate, file, action = 'update', cwd = tmpdir.p
79
87
80
88
const testRename = async ( ) => {
81
89
await ran1 . promise ;
90
+ runs . push ( currentRun ) ;
91
+ currentRun = '' ;
82
92
const fileToRenamePath = tmpdir . resolve ( fileToUpdate ) ;
83
93
const newFileNamePath = tmpdir . resolve ( `test-renamed-${ fileToUpdate } ` ) ;
84
94
const interval = setInterval ( ( ) => renameSync ( fileToRenamePath , newFileNamePath ) , common . platformTimeout ( 1000 ) ) ;
@@ -88,22 +98,31 @@ async function testWatch({ fileToUpdate, file, action = 'update', cwd = tmpdir.p
88
98
child . kill ( ) ;
89
99
await once ( child , 'exit' ) ;
90
100
91
- for ( const run of runs ) {
92
- assert . doesNotMatch ( run , / r u n \( \) i s b e i n g c a l l e d r e c u r s i v e l y / ) ;
93
- if ( action === 'rename2' ) {
94
- assert . match ( run , / M O D U L E _ N O T _ F O U N D / ) ;
95
- } else {
96
- assert . doesNotMatch ( run , / M O D U L E _ N O T _ F O U N D / ) ;
97
- }
98
- assert . match ( run , / # t e s t s 1 / ) ;
99
- assert . match ( run , / # p a s s 1 / ) ;
100
- assert . match ( run , / # f a i l 0 / ) ;
101
- assert . match ( run , / # c a n c e l l e d 0 / ) ;
101
+ assert . strictEqual ( runs . length , 2 ) ;
102
+
103
+ const [ firstRun , secondRun ] = runs ;
104
+ assert . match ( firstRun , / # t e s t s 1 / ) ;
105
+ assert . match ( firstRun , / # p a s s 1 / ) ;
106
+ assert . match ( firstRun , / # f a i l 0 / ) ;
107
+ assert . match ( firstRun , / # c a n c e l l e d 0 / ) ;
108
+ assert . doesNotMatch ( firstRun , / r u n \( \) i s b e i n g c a l l e d r e c u r s i v e l y / ) ;
109
+
110
+ if ( action === 'rename2' ) {
111
+ assert . match ( secondRun , / M O D U L E _ N O T _ F O U N D / ) ;
112
+ return ;
102
113
}
114
+
115
+ assert . match ( secondRun , / # t e s t s 1 / ) ;
116
+ assert . match ( secondRun , / # p a s s 1 / ) ;
117
+ assert . match ( secondRun , / # f a i l 0 / ) ;
118
+ assert . match ( secondRun , / # c a n c e l l e d 0 / ) ;
119
+ assert . doesNotMatch ( secondRun , / r u n \( \) i s b e i n g c a l l e d r e c u r s i v e l y / ) ;
103
120
} ;
104
121
105
122
const testDelete = async ( ) => {
106
123
await ran1 . promise ;
124
+ runs . push ( currentRun ) ;
125
+ currentRun = '' ;
107
126
const fileToDeletePath = tmpdir . resolve ( fileToUpdate ) ;
108
127
const interval = setInterval ( ( ) => {
109
128
if ( existsSync ( fileToDeletePath ) ) {
@@ -118,6 +137,8 @@ async function testWatch({ fileToUpdate, file, action = 'update', cwd = tmpdir.p
118
137
child . kill ( ) ;
119
138
await once ( child , 'exit' ) ;
120
139
140
+ assert . strictEqual ( runs . length , 2 ) ;
141
+
121
142
for ( const run of runs ) {
122
143
assert . doesNotMatch ( run , / M O D U L E _ N O T _ F O U N D / ) ;
123
144
}
0 commit comments