Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test: only report details on failure #525

Open
mratsim opened this issue Jan 26, 2025 · 0 comments
Open

Test: only report details on failure #525

mratsim opened this issue Jan 26, 2025 · 0 comments

Comments

@mratsim
Copy link
Owner

mratsim commented Jan 26, 2025

The test_suite is verbose and reports the full details of the tests.

Image

With over 70 active tests and 40 benchmarks, the output is unreadable.

Instead we should report details only on failure otherwise:

  • if test is in progress
    spinning icon/emoji, test name, time started
  • if test is finished
    green checkmark or [OK], test name, time started, time taken

This concise output can be done for nimble test_parallel only leaving nimble test as-is.
Modification likely has to be done in pararun, by not flushing output in sync to stdout but keeping it in a buffer

proc flushCommandsOutput(wq: WorkQueue, total: int) {.async.} =
var id = 0
while true:
id += 1
let (cmd, p, processOutput) = await wq.outputQueue.get()
echo '\n', '='.repeat(80)
echo "||\n|| Running #", id, "/", total, ": ", cmd ,"\n||"
echo '='.repeat(80)
while true:
let output = await processOutput.get()
if output == "":
break
stdout.write(output)
let exitCode = p.peekExitCode()
if exitCode != 0:
quit exitCode
if wq.cmdQueue.len == 0 and wq.outputQueue.len == 0:
return
proc runCommands(commandFile: string, numWorkers: int) =
# State
# -----
let wq = WorkQueue(
sem: AsyncSemaphore.new(numWorkers),
cmdQueue: initDeque[string](),
outputQueue: newAsyncQueue[tuple[cmd: string, p: AsyncProcess, output: AsyncQueue[string]]]())
# Parse the file
# --------------
for cmd in lines(commandFile):
if cmd.len == 0: continue
wq.cmdQueue.addLast(cmd)
let total = wq.cmdQueue.len
echo "Found ", total, " commands to run"
# Run the commands
# ----------------
asyncCheck wq.enqueuePendingCommands()
waitFor wq.flushCommandsOutput(total)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant