docs(test_framework): add comprehensive integration test guide and fix runner blocking issue
- Document exception handling, zero-value BotResult trap, shared adversary bots - Add offline parsing example using parseServerOutput - Skip tests gracefully when JARs missing (guard before suite blocks) - Fix blocking readLine in runner_process.nim: poll with 50ms sleep + atEnd check (was preventing timeout enforcement, now blocks correctly during battle) - Add test task to QBot.nimble and config.nims setup docs to AGENTS.md - Add debug logging to TestBattleRunner for bot identity tracking Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -29,14 +29,15 @@ proc runBattleRunner*(serverUrl: string, botDirs: seq[string], rounds: int,
|
||||
let deadline = epochTime() + timeout.float / 1000.0
|
||||
var stdout = ""
|
||||
var line: string
|
||||
# ponytail: poll instead of blocking readLine; 50ms sleep is fine for battle timescales
|
||||
while epochTime() < deadline:
|
||||
if p.peekExitCode() != -1:
|
||||
# Process finished; drain remaining output
|
||||
while p.outputStream.readLine(line):
|
||||
# Process finished; drain remaining output without blocking
|
||||
while p.outputStream.atEnd == false:
|
||||
discard p.outputStream.readLine(line)
|
||||
stdout.add(line & "\n")
|
||||
break
|
||||
if p.outputStream.readLine(line):
|
||||
stdout.add(line & "\n")
|
||||
sleep(50)
|
||||
|
||||
if epochTime() >= deadline and p.peekExitCode() == -1:
|
||||
p.terminate()
|
||||
|
||||
Reference in New Issue
Block a user