Skip to content

Commit 4645131

Browse files
authored
Merge pull request #4510 from Sebastian-Webster/non-tty
fix: prevent issues with tests running in non-TTY environments
2 parents ba04441 + 554732d commit 4645131

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

tests/e2e/samples.js

+15-5
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,12 @@ async function processSamples(command, paths) {
195195
})
196196

197197
await cluster.task(async ({ page, data: sample }) => {
198-
process.stdout.clearLine()
199-
process.stdout.cursorTo(0)
200-
const percentComplete = Math.round((100 * numCompleted) / samples.length)
201-
process.stdout.write(`Processing samples: ${percentComplete}%`)
198+
if (process.stdout.isTTY) {
199+
process.stdout.clearLine()
200+
process.stdout.cursorTo(0)
201+
const percentComplete = Math.round((100 * numCompleted) / samples.length)
202+
process.stdout.write(`Processing samples: ${percentComplete}%`)
203+
}
202204

203205
// BUG: some chart are animated - need special processing. Some just need to be skipped.
204206

@@ -214,7 +216,9 @@ async function processSamples(command, paths) {
214216
})
215217
}
216218
numCompleted++
217-
process.stdout.clearLine()
219+
if (!process.stdout.isTTY) {
220+
console.log(`Processed samples: ${numCompleted}/${samples.length}`)
221+
}
218222
})
219223

220224
for (const sample of samples) {
@@ -224,6 +228,12 @@ async function processSamples(command, paths) {
224228
await cluster.idle()
225229
await cluster.close()
226230

231+
if (process.stdout.isTTY) {
232+
process.stdout.clearLine()
233+
} else {
234+
console.log('All samples have now been processed')
235+
}
236+
227237
console.log('')
228238

229239
if (command === 'test') {

0 commit comments

Comments
 (0)