@@ -27,6 +27,10 @@ describe("console/task-action", function () {
27
27
} ) ;
28
28
29
29
beforeEach ( function ( ) {
30
+ // Using process.stdin for the input during tests is not reliable as it
31
+ // causes the test runner to hang indefinitely. We use a PassThrough stream
32
+ // instead. This, in turn, prevents us from using process.stdout for output.
33
+ // Hence, we use a PassThrough stream for output as well.
30
34
const input = new PassThrough ( ) ;
31
35
const output = new PassThrough ( ) ;
32
36
output . pipe ( process . stdout ) ;
@@ -142,13 +146,18 @@ describe("console/task-action", function () {
142
146
let history : string ;
143
147
144
148
beforeEach ( async function ( ) {
149
+ // We use a temporary cache dir to avoid conflicts with other tests
150
+ // and global user settings.
145
151
cacheDir = await fsPromises . mkdtemp (
146
152
path . resolve ( os . tmpdir ( ) , "console-action-test-" ) ,
147
153
) ;
148
154
history = path . resolve ( cacheDir , "console-history.txt" ) ;
149
155
} ) ;
150
156
151
157
afterEach ( async function ( ) {
158
+ // We try to remove the temporary cache dir after each test, but we don't
159
+ // fail the test if it fails. For example, we have observed that in GHA
160
+ // on Windows, the temp dir cannot be removed due to permission issues.
152
161
try {
153
162
await remove ( cacheDir ) ;
154
163
} catch ( error ) {
0 commit comments