feat: add shared integration test framework for garages (#126)

Implements:
- BattleResult type and JSON-lines parser (#127)
- TR server lifecycle manager (#128)
- Bot compiler using nim c (#129)
- runBattle() orchestrator (#130)
- Example test in OscillatorBot_garage (#131)
- Framework usage guide (#132)
- TestBattleRunner.java for external server (#133)
- BattleRunner process lifecycle (#134)

Fix: runner_process.nim was redefining TimeoutError locally; now
uses std/net.TimeoutError consistently with server_manager.nim.
This commit is contained in:
2026-08-30 12:03:35 +02:00
parent a50571e6da
commit 57a1915b10
13 changed files with 654 additions and 2 deletions
@@ -0,0 +1,9 @@
{
"name": "SittingDuck",
"version": "0.1.0",
"authors": ["Test"],
"description": "Does nothing — test adversary",
"gameTypes": ["classic", "1v1"],
"platform": "Nim",
"programmingLang": "Nim"
}
@@ -0,0 +1,15 @@
# SittingDuck — does nothing, used as a test adversary.
import std/os
import tankroyale_botapi
const botJsonPath = currentSourcePath().parentDir / "SittingDuck.json"
type SittingDuck = ref object of Bot
method run*(bot: SittingDuck) =
while isRunning():
go()
when isMainModule:
var bot = SittingDuck()
start(bot, botJsonPath)
+1
View File
@@ -0,0 +1 @@
--path:"../../common_libs"
@@ -0,0 +1,30 @@
## Integration test: OscillatorBot vs SittingDuck, 3 rounds.
## Requires a running TR server (set TR_SERVER_JAR / TR_BATTLE_RUNNER env vars).
import std/[os, unittest]
import test_framework/test_framework
const
oscillatorDir = currentSourcePath().parentDir.parentDir # OscillatorBot_garage/
sittingDuckDir = currentSourcePath().parentDir / "bots" / "SittingDuck"
suite "OscillatorBot basic battle":
test "beats SittingDuck in 3 rounds":
let r = runBattle(@[oscillatorDir, sittingDuckDir], rounds = 3)
check r.rounds.len == 3
check r.results.len == 2
let oscillator = block:
var found: BotResult
for b in r.results:
if b.name == "OscillatorBot": found = b
found
let duck = block:
var found: BotResult
for b in r.results:
if b.name == "SittingDuck": found = b
found
check oscillator.totalScore > duck.totalScore
check "OscillatorBot" in r.winners