From 6f4ca6421879232a534d3647fdb83e6e9bcd8869 Mon Sep 17 00:00:00 2001 From: Krzysztof kuhy Rudnicki Date: Tue, 17 Nov 2026 22:15:17 +0100 Subject: [PATCH] godot_dev_tools 0.2.1: reporter off when headless A game's own test and smoke gates leaked test errors into the spool; headless runs and APP_ERRORS_OFF=1 now write nothing. Co-Authored-By: Claude Opus 5.5 --- DOCS-app-errors.md | 4 +++- godot_dev_tools/README.md | 6 ++++-- .../addons/app_errors/error_reporter.gd | 16 +++++++++++++++- godot_dev_tools/addons/dev_tools/dev_tools.cfg | 2 +- godot_dev_tools/tests/test_error_reporter.gd | 17 +++++++++++++++++ 5 files changed, 40 insertions(+), 5 deletions(-) diff --git a/DOCS-app-errors.md b/DOCS-app-errors.md index cf8fe9c..40a29a8 100644 --- a/DOCS-app-errors.md +++ b/DOCS-app-errors.md @@ -22,7 +22,9 @@ board's half is todoImplementer `DOCS-errors.md`, with the contract in `rep.wait(...)` and `rep.begin(...)` time a wait. - Godot, `godot_dev_tools` 0.2.0, `addons/app_errors`: an `OS.add_logger` logger catches script errors and `push_error`. A frame over 1 s, or - `report_wait` over 1 s, becomes `perf.slow`. + `report_wait` over 1 s, becomes `perf.slow`. Headless runs and + `APP_ERRORS_OFF=1` write nothing, so a game's own test gates file no + tickets. - PC apps (Tk and Godot) append to the local spool `~/.local/state/app-errors-spool/.jsonl`. They need no RTDB, because the ingest runs on the same PC. diff --git a/godot_dev_tools/README.md b/godot_dev_tools/README.md index 9bf98b6..66c5903 100644 --- a/godot_dev_tools/README.md +++ b/godot_dev_tools/README.md @@ -37,7 +37,7 @@ the tag (shallow), then link or copy `godot_dev_tools/addons/dev_tools` to `res://addons/dev_tools` and gitignore that path: ```bash -git clone --depth 1 --branch godot-dev-tools-v0.2.0 https://github.com/kuhyx/utils "$cache" +git clone --depth 1 --branch godot-dev-tools-v0.2.1 https://github.com/kuhyx/utils "$cache" ln -sfn "$cache/godot_dev_tools/addons/dev_tools" addons/dev_tools # CI: cp -a instead ``` @@ -76,7 +76,9 @@ Script errors and `push_error` arrive through an `OS.add_logger` logger. Any frame over 1 s becomes the wait `godot.frame`. Reports go to `~/.local/state/app-errors-spool/.jsonl` on desktop Linux, and nothing is written on web. The `app-errors` ingest timer turns them into board tickets. -Nothing shows on screen. +Nothing shows on screen. Headless runs (tests, CI, bots) and `APP_ERRORS_OFF=1` +write nothing, so a game's own checks never file tickets; `APP_ERRORS_FORCE=1` +turns a headless end-to-end probe back on. ## The host interface diff --git a/godot_dev_tools/addons/app_errors/error_reporter.gd b/godot_dev_tools/addons/app_errors/error_reporter.gd index f332849..7401f36 100644 --- a/godot_dev_tools/addons/app_errors/error_reporter.gd +++ b/godot_dev_tools/addons/app_errors/error_reporter.gd @@ -12,6 +12,7 @@ extends Node ## reported as the wait `godot.frame`. Each report is one JSON line in ## $XDG_STATE_HOME/app-errors-spool/.jsonl, which the PC's app-errors ## ingest turns into a board ticket. Desktop only (a web build has no spool), +## off in headless runs and with APP_ERRORS_OFF=1 (see default_enabled), ## shows nothing on screen, and never reports from inside a report. Identical ## errors within WINDOW_SEC are dropped; at most MAX_PER_MINUTE are written. ## No class_name (the addon stays out of the global class cache). @@ -33,6 +34,8 @@ const KINDS := { var clock: Callable = Time.get_unix_time_from_system ## Folder of the spool; empty writes nothing (a web build). var spool_dir := default_spool_dir() +## False writes nothing: headless runs (tests, CI, bots) and APP_ERRORS_OFF. +var enabled := default_enabled() var logger: Logger var _app := "" @@ -58,6 +61,17 @@ static func default_spool_dir() -> String: return base.path_join("app-errors-spool") +## Whether this process reports: never with APP_ERRORS_OFF=1, and not when +## headless (tests, CI, smoke runs, export checks: their errors are not a +## player's) unless APP_ERRORS_FORCE=1 (an end-to-end probe). +static func default_enabled() -> bool: + if OS.get_environment("APP_ERRORS_OFF") == "1": + return false + if DisplayServer.get_name() == "headless": + return OS.get_environment("APP_ERRORS_FORCE") == "1" + return true + + ## Names the game: `app` as the board shows it, `repo` as owner/name, and the ## build number when the game knows one. func setup(app: String, repo: String, build := 0, version := "") -> void: @@ -181,7 +195,7 @@ func _allowed(bucket: String, cap: int, now: float) -> bool: ## Appends one entry; a missing spool folder is made, a failure drops it. func _write(entry: Dictionary, now: float) -> void: - if spool_dir == "": + if spool_dir == "" or not enabled: return var ms := int(fmod(now, 1.0) * 1000.0) entry.at = "%s.%03dZ" % [Time.get_datetime_string_from_unix_time(int(now)), ms] diff --git a/godot_dev_tools/addons/dev_tools/dev_tools.cfg b/godot_dev_tools/addons/dev_tools/dev_tools.cfg index 60f8036..16a212f 100644 --- a/godot_dev_tools/addons/dev_tools/dev_tools.cfg +++ b/godot_dev_tools/addons/dev_tools/dev_tools.cfg @@ -1,4 +1,4 @@ ; Release of the dev_tools addon. The git tag is godot-dev-tools-v. [addon] -version = "0.2.0" +version = "0.2.1" diff --git a/godot_dev_tools/tests/test_error_reporter.gd b/godot_dev_tools/tests/test_error_reporter.gd index 2b486e8..6a64ea6 100644 --- a/godot_dev_tools/tests/test_error_reporter.gd +++ b/godot_dev_tools/tests/test_error_reporter.gd @@ -12,6 +12,7 @@ var _rep: Node func before_each() -> void: _rep = Reporter.new() _rep.spool_dir = ProjectSettings.globalize_path(_dir) + _rep.enabled = true # tests run headless, where the reporter is off _rep.setup("car-rental-sim", "kuhyx/car-rental-sim", 12, "0.4.0") _rep.clock = func() -> float: return 1800000000.0 add_child_autofree(_rep) @@ -178,3 +179,19 @@ func test_real_push_error_reaches_the_spool() -> void: for entry in _lines(): errors.append(entry.error) assert_has(errors, "deliberate test error") + + +func test_headless_runs_are_off_unless_forced() -> void: + assert_false(Reporter.default_enabled(), "GUT runs headless: off by default") + OS.set_environment("APP_ERRORS_FORCE", "1") + assert_true(Reporter.default_enabled(), "a probe can force it on") + OS.set_environment("APP_ERRORS_OFF", "1") + assert_false(Reporter.default_enabled(), "APP_ERRORS_OFF always wins") + OS.unset_environment("APP_ERRORS_FORCE") + OS.unset_environment("APP_ERRORS_OFF") + + +func test_disabled_writes_nothing() -> void: + _rep.enabled = false + _rep.report_wait("level.load", 5000) + assert_eq(_lines(), [])