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:
2026-09-13 10:54:56 +02:00
parent 2bfa8eb6a5
commit 7e1f1483a4
19 changed files with 281 additions and 6 deletions
+11 -1
View File
@@ -15,7 +15,7 @@ import java.util.stream.Collectors;
public class TestBattleRunner {
public static void main(String[] args) {
Logger.getLogger("dev.robocode.tankroyale").setLevel(Level.WARNING);
Logger.getLogger("dev.robocode.tankroyale").setLevel(Level.INFO);
String serverUrl = null;
int rounds = 1;
@@ -38,11 +38,20 @@ public class TestBattleRunner {
final int numRounds = rounds;
final var setup = BattleSetup.classic(s -> s.setNumberOfRounds(numRounds));
// Debug: check what JSON files the runner will find for each bot dir
for (String dir : botDirs) {
var path = java.nio.file.Path.of(dir);
var jsonPath = path.resolve(path.getFileName() + ".json");
System.err.println("[DEBUG] identity JSON: " + jsonPath + " exists=" + java.nio.file.Files.exists(jsonPath));
}
try (var runner = BattleRunner.create(b -> b.externalServer(url).suppressServerOutput())) {
var owner = new Object();
System.err.println("[DEBUG] bots: " + bots);
try (var handle = runner.startBattleAsync(setup, bots)) {
handle.getOnGameStarted().on(owner, event -> {
System.err.println("[DEBUG] game_started participants: " + event.getParticipants().stream().map(p -> p.getName() + "/" + p.getVersion() + "/" + p.getAuthors()).collect(Collectors.joining(", ")));
var names = event.getParticipants().stream()
.map(p -> "\"" + escape(p.getName()) + "\"")
.collect(Collectors.joining(","));
@@ -51,6 +60,7 @@ public class TestBattleRunner {
});
handle.getOnRoundEnded().on(owner, event -> {
System.err.println("[DEBUG] round_ended results count: " + event.getResults().size());
var results = event.getResults().stream().map(r ->
"{\"name\":\"" + escape(r.getName()) + "\"" +
",\"score\":" + r.getTotalScore() +