Skip to content

Commit

Permalink
Merge pull request #4510 from Sebastian-Webster/non-tty
Browse files Browse the repository at this point in the history
fix: prevent issues with tests running in non-TTY environments
  • Loading branch information
junedchhipa authored Jun 13, 2024
2 parents ba04441 + 554732d commit 4645131
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions tests/e2e/samples.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,12 @@ async function processSamples(command, paths) {
})

await cluster.task(async ({ page, data: sample }) => {
process.stdout.clearLine()
process.stdout.cursorTo(0)
const percentComplete = Math.round((100 * numCompleted) / samples.length)
process.stdout.write(`Processing samples: ${percentComplete}%`)
if (process.stdout.isTTY) {
process.stdout.clearLine()
process.stdout.cursorTo(0)
const percentComplete = Math.round((100 * numCompleted) / samples.length)
process.stdout.write(`Processing samples: ${percentComplete}%`)
}

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

Expand All @@ -214,7 +216,9 @@ async function processSamples(command, paths) {
})
}
numCompleted++
process.stdout.clearLine()
if (!process.stdout.isTTY) {
console.log(`Processed samples: ${numCompleted}/${samples.length}`)
}
})

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

if (process.stdout.isTTY) {
process.stdout.clearLine()
} else {
console.log('All samples have now been processed')
}

console.log('')

if (command === 'test') {
Expand Down

0 comments on commit 4645131

Please sign in to comment.