mirror of
https://github.com/kuhyx/utils.git
synced 2026-11-18 20:34:33 +01:00
godot_dev_tools 0.2.1: reporter off when headless
Some checks are pending
dependency freshness / dependencies on newest stable (push) Waiting to run
file length / file-length (push) Waiting to run
godot_dev_tools tests / test (push) Waiting to run
md-naming / markdown naming convention (push) Waiting to run
palette drift / palette (push) Waiting to run
repo-contract / repo contract (push) Waiting to run
shared gate tests / gate unit tests (push) Waiting to run
Some checks are pending
dependency freshness / dependencies on newest stable (push) Waiting to run
file length / file-length (push) Waiting to run
godot_dev_tools tests / test (push) Waiting to run
md-naming / markdown naming convention (push) Waiting to run
palette drift / palette (push) Waiting to run
repo-contract / repo contract (push) Waiting to run
shared gate tests / gate unit tests (push) Waiting to run
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 <noreply@anthropic.com>
This commit is contained in:
parent
dfc5d07f52
commit
6f4ca64218
@ -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/<app>.jsonl`. They need no RTDB, because
|
||||
the ingest runs on the same PC.
|
||||
|
||||
@ -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/<app>.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
|
||||
|
||||
|
||||
@ -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/<app>.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]
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
; Release of the dev_tools addon. The git tag is godot-dev-tools-v<version>.
|
||||
[addon]
|
||||
|
||||
version = "0.2.0"
|
||||
version = "0.2.1"
|
||||
|
||||
@ -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(), [])
|
||||
|
||||
Loading…
Reference in New Issue
Block a user