Tests: 15 s budget, shared Godot workers; a freed Main cancels its roll
tools/run_tests.sh stops every run at 15 s and lists what was not run. Suites are nodes run by tests/run_suites.gd, several per Godot process; TestBase no longer compiles the app (AppTestBase does). Audit: fewer repeats and less setup; 51 suites in about 12 s (was 45 s). Fix a crash when a roll was still animating as its Main was freed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
d7d7fb66ea
commit
d41a6e40aa
63 changed files with 483 additions and 257 deletions
15
CLAUDE.md
Normal file
15
CLAUDE.md
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
# TableTarot (folder and repo are still named TableTower)
|
||||
|
||||
How to work on it: `docs/DESIGN.md` §5. Module map: `docs/ARCHITECTURE.md`.
|
||||
|
||||
## Test time budget: always follow
|
||||
- Run tests only through `tools/run_tests.sh [filter]`. It stops every run at **15 seconds**.
|
||||
- Only the user changes `BUDGET_SECS`. If the tests can't reasonably fit, ask them, with timings.
|
||||
- Don't get around it: no looping over suites, no several filtered runs to cover a full run,
|
||||
no background or repeated runs.
|
||||
- While working, run the suites for the area you changed, by filter. Do one full run at the end.
|
||||
- `NOT RUN` means not tested. Say which suites were not run; never report them as passing.
|
||||
- A new test must fit. Prefer adding to an existing suite; a new app suite costs about half a second to start.
|
||||
No real waiting: the runner uses simulated time (`--fixed-fps 60`).
|
||||
- A suite that loads its own board calls `start_main(false)`: building the demo is slow.
|
||||
- Suites extend `TestBase` (no UI) or, only if they need the app, `AppTestBase`.
|
||||
|
|
@ -156,7 +156,7 @@ docs/ design document
|
|||
## Tests
|
||||
|
||||
```sh
|
||||
for t in tests/test_*.gd; do godot --headless --path . -s "res://$t" -- --sample; done
|
||||
tools/run_tests.sh [name-filter] # stops after 15 seconds
|
||||
```
|
||||
|
||||
## Screenshots from the command line
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ ui/ main.gd: the app shell (shared fields, _ready, cards, collapse, inpu
|
|||
template_*, io_menu, collection_switcher, variables_panel, modal_card, rich_text, style
|
||||
help/ topics.txt: the Help window's text (# Title per topic)
|
||||
tools/ simulate_board.gd (headless simulator CLI), test_window.sh (background test windows)
|
||||
tests/ test_*.gd: 27 headless suites
|
||||
tests/ test_*.gd: 51 headless suites; run_suites (runs them in one process), testbase, app_testbase
|
||||
templates/ built-in templates · examples/logic_demo.json (original demo board) · assets/fonts (OFL)
|
||||
```
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
# Table Tarot (repo: TableTower) — Status and Plan
|
||||
|
||||
**Engine:** Godot 4.7.2 (GDScript) · **Started:** 2026-11-08 · **Last updated:** 2026-11-16 (papercuts + card threads
|
||||
round hand-tested, merged to `main` and pushed)
|
||||
**Engine:** Godot 4.7.2 (GDScript) · **Started:** 2026-11-08 · **Last updated:** 2026-11-25 (test time
|
||||
budget and test audit, branch `test-budget`)
|
||||
|
||||
The short page to read at the start of every session. Everything else is read only when needed:
|
||||
- `docs/ARCHITECTURE.md`: feature summary, file map (§3b lists the 2026-11-10 modules), storage, known gaps.
|
||||
|
|
@ -243,15 +243,29 @@ that works on any theme (solid background, stronger text, thicker borders, no ef
|
|||
Now rows/cells skip restyling when their look is unchanged, and Earlier reuses its rows: ~240 ms
|
||||
per roll, flat (most of it is the 2–3 questions, each relighting ~70 ms first). Timing tool:
|
||||
`tests/perf_roll.gd` (SPREAD=… CARD=…; not in the suite).
|
||||
- **Test budget and audit: done 2026-11-25** (branch `test-budget`, not merged). 51 suites in ~12 s
|
||||
(was 45 s). Cut coverage: fewer repeats in `test_roller`, `test_logic_ui` (chain of 321, above
|
||||
the cap of 300), `test_undo` (320 cards), `test_navigation` (20 rows); the 10,000-action limit
|
||||
stays in `test_logic` and `test_check_inputs` only, so nothing checks that message in the tray.
|
||||
App crash fixed: a roll still animating went on after `Main` was freed (`Main._exit_tree`).
|
||||
- **Next: the app is sluggish.** The user has a second request about this; ask what it is first.
|
||||
Measured headless 2026-11-25 on the demo cut to 12-row tables (~1,200 nodes): start ~400 ms,
|
||||
to Build 330–370 ms, to Play ~200 ms plus an ~85 ms frame, `_rebuild_cards` ~190 ms. Suspect:
|
||||
`MainLayout.set_mode` rebuilds every card. Logic demo: roll logic ~1 ms, app roll 130–170 ms.
|
||||
- Known gaps: ARCHITECTURE.md §7.
|
||||
|
||||
## 5. Working on it
|
||||
- **Godot:** `~/apps/Godot_v4.7.2-stable_linux.x86_64`. New `class_name` files need
|
||||
`godot --headless --path . --import` (the test runner does this).
|
||||
- **Tests:** `tools/run_tests.sh [filter]`: 51 suites in parallel, ~40 s. One line per suite; a
|
||||
failing suite prints 8 lines; a compile error shared by many suites prints once. Suites extend
|
||||
`TestBase` (`tests/testbase.gd`, named so the `test_*.gd` glob skips it): `start_main()`,
|
||||
`require_sample()`, `_check`, `_eq`, `_frames`, `_wipe` (temp folders), `finish()`.
|
||||
- **Tests:** `tools/run_tests.sh [filter]`: a hard 15 s budget per run (rules in `CLAUDE.md`).
|
||||
Six Godot workers (`tests/run_suites.gd`) share the suites, longest first; what doesn't fit is
|
||||
listed as NOT RUN (exit code 2). A full run takes ~12 s on an idle machine (2026-11-25). One
|
||||
line per suite; a failing suite prints 8 lines; a compile error shared by many suites prints
|
||||
once. A suite is a Node with `run()`, ending in `finish()`. It extends `TestBase`
|
||||
(`tests/testbase.gd`, no UI: `require_sample()`, `_check`, `_eq`, `_frames`, `_wipe`) or
|
||||
`AppTestBase` (`tests/app_testbase.gd`: `main`, `start_main()`; pass false to start on an
|
||||
empty spread). The suites' demo spread has tables of 12 rows at most. Suites share a process,
|
||||
so one that changes static state puts it back (`clean_up()`).
|
||||
- **Smoke test:** `godot --headless --path . --quit-after 120 -- --sample` (no SCRIPT ERROR; the
|
||||
"resources still in use at exit" line is normal).
|
||||
- **Windowed runs/screenshots: always `tools/test_window.sh -- --sample --screenshot=/path.png [flags]`**
|
||||
|
|
|
|||
63
tests/app_testbase.gd
Normal file
63
tests/app_testbase.gd
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
class_name AppTestBase
|
||||
extends TestBase
|
||||
## For suites that load the app. Call `if not await start_main(): return` first.
|
||||
|
||||
## Long demo tables are cut to this many rows: rebuilding them costs up to a
|
||||
## second per mode switch. test_roller checks the demo's full tables.
|
||||
const MAX_DEMO_ROWS := 12
|
||||
|
||||
var main: Main
|
||||
|
||||
|
||||
## Hook: suites that need a customised Main override this.
|
||||
func _create_main() -> Main:
|
||||
return load("res://ui/main.tscn").instantiate()
|
||||
|
||||
|
||||
## The app's demo spread with short tables.
|
||||
func _short_demo() -> TowerBoard:
|
||||
var board := SampleBoard.create()
|
||||
board.id = "fantasy-loot"
|
||||
board.name = "Fantasy Loot"
|
||||
for table in board.tables:
|
||||
if not table.is_ranged() and table.entries.size() > MAX_DEMO_ROWS:
|
||||
table.entries.resize(MAX_DEMO_ROWS)
|
||||
return board
|
||||
|
||||
|
||||
func _empty_spread() -> TowerBoard:
|
||||
var board := TowerBoard.new()
|
||||
board.id = "fantasy-loot"
|
||||
board.name = "Fantasy Loot"
|
||||
return board
|
||||
|
||||
|
||||
## A suite that loads its own board first should pass `with_demo` false: the
|
||||
## demo's cards take about half a second to build. Guard, then loads the app under root and waits for it. Returns false (after
|
||||
## aborting) if the guard fails or the app would save.
|
||||
func start_main(with_demo: bool = true) -> bool:
|
||||
if not require_sample():
|
||||
return false
|
||||
main = _create_main()
|
||||
if main.data == null:
|
||||
main.data = _short_demo() if with_demo else _empty_spread()
|
||||
root.add_child(main)
|
||||
await _frames(5)
|
||||
if main._saving_enabled:
|
||||
abort("Saving is enabled; refusing to run.")
|
||||
return false
|
||||
return true
|
||||
|
||||
|
||||
## Back to the default theme, window and shared UI state.
|
||||
func clean_up() -> void:
|
||||
if main != null:
|
||||
main.queue_free()
|
||||
ThemeStore.DIR = "user://themes/"
|
||||
ThemeStore.carry_board = null
|
||||
ThemeStore.current = {}
|
||||
ThemeAssets._cache.clear()
|
||||
Spellcheck.ignored.clear()
|
||||
TestBoardDialog.last = {}
|
||||
RulesView.fallback_plain = true
|
||||
SpreadLinks.loader = Callable()
|
||||
1
tests/app_testbase.gd.uid
Normal file
1
tests/app_testbase.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://cai0ym8kthl6s
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
extends TestBase
|
||||
extends AppTestBase
|
||||
## Times rolling one card on a big spread: the roll logic alone, then the
|
||||
## whole app roll (fast), then the parts of the screen update after it.
|
||||
## Not part of the suite (the name doesn't start with test_). Run:
|
||||
## SPREAD=/path/to/spread.json CARD=start \
|
||||
## godot --headless --path . -s res://tests/perf_roll.gd -- --sample
|
||||
## SUITES=perf_roll godot --headless --path . -s res://tests/run_suites.gd -- --sample
|
||||
## (--sample keeps the app from reading or writing saved spreads.)
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
func run() -> void:
|
||||
if not await start_main():
|
||||
return
|
||||
var card_id := OS.get_environment("CARD") if OS.get_environment("CARD") != "" else "start"
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
extends TestBase
|
||||
extends AppTestBase
|
||||
## Times typing on a long card in Build mode: one key in a result's field on
|
||||
## the card, in the card's name, and in the inspector's text field. Each number
|
||||
## is the frame after the key (an idle frame is ~7 ms headless). Not part of
|
||||
## the suite (the name doesn't start with test_). Run:
|
||||
## SPREAD=/path/to/spread.json CARD=card_id \
|
||||
## godot --headless --path . -s res://tests/perf_typing.gd -- --sample
|
||||
## SUITES=perf_typing godot --headless --path . -s res://tests/run_suites.gd -- --sample
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
func run() -> void:
|
||||
if not await start_main():
|
||||
return
|
||||
main.data.load_json(FileAccess.get_file_as_string(OS.get_environment("SPREAD")))
|
||||
|
|
|
|||
70
tests/run_suites.gd
Normal file
70
tests/run_suites.gd
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
extends SceneTree
|
||||
## Runs suites one after another in this process. SUITES (environment) lists
|
||||
## them in order; workers started with the same CLAIMS folder share the list,
|
||||
## each suite going to whichever worker claims it first.
|
||||
## Output per suite: "SUITE name", the suite's output, then
|
||||
## "DONE name <milliseconds> <failures>". tools/run_tests.sh reads it.
|
||||
|
||||
## After a script error, a suite that awaited the crashed function never ends:
|
||||
## it is abandoned this many frames later.
|
||||
const FRAMES_AFTER_ERROR := 30
|
||||
|
||||
|
||||
## Notices script errors, which don't reach the suite's own checks.
|
||||
class ErrorWatch extends Logger:
|
||||
var script_errors := 0
|
||||
|
||||
func _log_error(_function: String, _file: String, _line: int, _code: String, _rationale: String,
|
||||
_editor_notify: bool, error_type: int, _backtraces: Array[ScriptBacktrace]) -> void:
|
||||
if error_type == ERROR_TYPE_SCRIPT:
|
||||
script_errors += 1
|
||||
|
||||
|
||||
var _errors := ErrorWatch.new()
|
||||
var _original_children: Array[Node] = []
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
OS.add_logger(_errors)
|
||||
await process_frame
|
||||
_original_children = root.get_children()
|
||||
var claims := OS.get_environment("CLAIMS")
|
||||
var failed := false
|
||||
for suite in OS.get_environment("SUITES").split(",", false):
|
||||
# Making a folder is atomic, so only one worker gets each suite.
|
||||
if claims == "" or DirAccess.make_dir_absolute(claims.path_join(suite)) == OK:
|
||||
failed = await _run_suite(suite) > 0 or failed
|
||||
quit(1 if failed else 0)
|
||||
|
||||
|
||||
func _run_suite(suite_name: String) -> int:
|
||||
print("SUITE ", suite_name)
|
||||
var started := Time.get_ticks_msec()
|
||||
_errors.script_errors = 0
|
||||
var failures := 1
|
||||
var script: GDScript = load("res://tests/%s.gd" % suite_name)
|
||||
if script != null and script.can_instantiate():
|
||||
var suite: TestBase = script.new()
|
||||
root.add_child(suite)
|
||||
suite.run()
|
||||
var frames_left := FRAMES_AFTER_ERROR
|
||||
while not suite.done and frames_left > 0:
|
||||
await process_frame
|
||||
if _errors.script_errors > 0:
|
||||
frames_left -= 1
|
||||
failures = suite.failures + _errors.script_errors
|
||||
suite.clean_up()
|
||||
await _reset_tree()
|
||||
print("DONE %s %d %d" % [suite_name, Time.get_ticks_msec() - started, failures])
|
||||
return failures
|
||||
|
||||
|
||||
## Frees whatever the suite left under root and resets the window.
|
||||
func _reset_tree() -> void:
|
||||
paused = false
|
||||
Engine.time_scale = 1.0
|
||||
root.gui_release_focus()
|
||||
for child in root.get_children():
|
||||
if child not in _original_children:
|
||||
child.queue_free()
|
||||
await process_frame
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
extends TestBase
|
||||
extends AppTestBase
|
||||
## The shared action menus (Actions): what the card, thread, group and spread
|
||||
## menus offer in Play and Build, the ☰ menu, running an action, and placing
|
||||
## a new card where the spread was right-clicked.
|
||||
## Run: godot --headless --path . -s res://tests/test_actions.gd -- --sample
|
||||
## Run: tools/run_tests.sh actions
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
func run() -> void:
|
||||
if not await start_main():
|
||||
return
|
||||
await _test_lists()
|
||||
|
|
@ -75,8 +75,6 @@ func _test_popup_and_run() -> void:
|
|||
## The Delete key: asks first (by default), deletes the selection as one undo
|
||||
## step, and skips the question when "Ask before deleting" is off.
|
||||
func _test_delete_key() -> void:
|
||||
main.set_mode(Main.Mode.BUILD)
|
||||
await _frames()
|
||||
main.clear_selection()
|
||||
main.editing.toggle_selected("loot")
|
||||
main.editing.toggle_selected("names")
|
||||
|
|
@ -97,4 +95,3 @@ func _test_delete_key() -> void:
|
|||
_check(main.data.get_table("loot") != null and main.data.get_table("names") != null, "one undo brings both back")
|
||||
DeleteKey.set_asks(main, true)
|
||||
main.clear_selection()
|
||||
main.set_mode(Main.Mode.PLAY)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ extends TestBase
|
|||
## BoardTester: static checks, simulated runs, isolation from the caller's
|
||||
## variables and decks, batches, start-table detection, and the Test board
|
||||
## dialog driven through its methods.
|
||||
## Run: godot --headless --path . -s res://tests/test_board_tester.gd
|
||||
## Run: tools/run_tests.sh board_tester
|
||||
|
||||
|
||||
|
||||
|
|
@ -16,7 +16,7 @@ class FakeMain extends Control:
|
|||
focused.append([table_id, entry_id])
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
func run() -> void:
|
||||
var b := _board()
|
||||
|
||||
# ----- Static checks -----
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
extends TestBase
|
||||
extends AppTestBase
|
||||
## The Book: pages saved from results, linked results following a page's edits,
|
||||
## dropping a page onto a result or a card, unlinking, saving and undo.
|
||||
## Run: godot --headless --path . -s res://tests/test_book.gd -- --sample
|
||||
## Run: tools/run_tests.sh book
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
func run() -> void:
|
||||
if not await start_main():
|
||||
return
|
||||
main.set_mode(Main.Mode.BUILD)
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@ extends TestBase
|
|||
## phrase (column_join), "roll twice and combine" rows (TableEntry.repeat),
|
||||
## saving results into a list value, and a pick with one option answering
|
||||
## itself.
|
||||
## Run: godot --headless --path . -s res://tests/test_book_collect.gd -- --sample
|
||||
## Run: tools/run_tests.sh book_collect
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
func run() -> void:
|
||||
await _test_join_and_repeat()
|
||||
await _test_repeat_reroll()
|
||||
await _test_repeat_one_column()
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
extends TestBase
|
||||
## Book-table features in the engine: scale values, cards with columns, and
|
||||
## threads that roll with other dice or roll again on some results.
|
||||
## Run: godot --headless --path . -s res://tests/test_book_tables.gd -- --sample
|
||||
## Run: tools/run_tests.sh book_tables
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
func run() -> void:
|
||||
_test_scales()
|
||||
_test_scale_effects()
|
||||
await _test_columns_row()
|
||||
|
|
|
|||
|
|
@ -2,10 +2,10 @@ extends TestBase
|
|||
## Headless checks for Builder (docs/PLAIN.md §2): effect and condition models
|
||||
## that round-trip exactly with the stored text, the cases that don't fit a
|
||||
## builder (ok: false), and known_values().
|
||||
## Run: godot --headless --path . -s res://tests/test_builder.gd
|
||||
## Run: tools/run_tests.sh builder
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
func run() -> void:
|
||||
_test_parse_effect()
|
||||
_test_effect_round_trips()
|
||||
_test_effect_not_ok()
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
extends TestBase
|
||||
extends AppTestBase
|
||||
## Resizable cards: the grip's corner hit area, a dragged width and list
|
||||
## height (the list scrolls), saving them, and double-click back to automatic.
|
||||
## Run: godot --headless --path . -s res://tests/test_card_size.gd -- --sample
|
||||
## Run: tools/run_tests.sh card_size
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
func run() -> void:
|
||||
if not await start_main():
|
||||
return
|
||||
await _test_resize()
|
||||
|
|
@ -94,6 +94,9 @@ func _test_play_drag_selects() -> void:
|
|||
## A long card opened with "show all" has "▲ Show less" to fold it up again.
|
||||
func _test_show_less() -> void:
|
||||
var t := main.data.get_table("trinkets")
|
||||
# The suites' demo has short tables: make this one long again.
|
||||
for entry in SampleBoard.create().get_table("trinkets").entries.slice(t.entries.size()):
|
||||
t.entries.append(entry)
|
||||
if not t.collapsed:
|
||||
main.toggle_collapse("trinkets")
|
||||
await _frames(2)
|
||||
|
|
|
|||
|
|
@ -2,10 +2,10 @@ extends TestBase
|
|||
## Card threads (CardThreads, LOGIC.md §3g): threads off a card's bottom edge
|
||||
## that run after the card's result and that result's own threads, whatever
|
||||
## the result was ("Always"), or only when no result thread ran ("Otherwise").
|
||||
## Run: godot --headless --path . -s res://tests/test_card_threads.gd
|
||||
## Run: tools/run_tests.sh card_threads
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
func run() -> void:
|
||||
_test_always_runs_after()
|
||||
_test_otherwise()
|
||||
_test_card_condition()
|
||||
|
|
|
|||
|
|
@ -2,10 +2,10 @@ extends TestBase
|
|||
## Headless checks for the new engine features of docs/PLAIN.md §3–§4: check
|
||||
## cards, card inputs (pipe "with" values), collections, "nat" on roll tables,
|
||||
## the why facts they record, the file format and the lint.
|
||||
## Run: godot --headless --path . -s res://tests/test_check_inputs.gd
|
||||
## Run: tools/run_tests.sh check_inputs
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
func run() -> void:
|
||||
_test_check_success_failure()
|
||||
_test_check_le_and_dice()
|
||||
_test_check_errors()
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
extends TestBase
|
||||
extends AppTestBase
|
||||
## The choice pop-up's minimize pill and hover preview, and TablePreview.
|
||||
## Run: godot --headless --path . -s res://tests/test_choice_dialog.gd -- --sample
|
||||
## Run: tools/run_tests.sh choice_dialog
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
if not await start_main():
|
||||
func run() -> void:
|
||||
if not await start_main(false):
|
||||
return
|
||||
# Headless windows are tiny; give the app a real size.
|
||||
main.set_anchors_preset(Control.PRESET_TOP_LEFT)
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
extends TestBase
|
||||
extends AppTestBase
|
||||
## Help's demo spreads: every demo builds and rolls cleanly, Help links to
|
||||
## them, and opening one shows it unsaved with a way back.
|
||||
## Run: godot --headless --path . -s res://tests/test_demos.gd -- --sample
|
||||
## Run: tools/run_tests.sh demos
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
func run() -> void:
|
||||
if not require_sample():
|
||||
return
|
||||
_test_builds()
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@ extends TestBase
|
|||
## every effect op, the condition forms, dice, dynamic options, pipes, check
|
||||
## cards and why facts, with labels from variable cards, collections and card
|
||||
## inputs, and the fallbacks to the original text.
|
||||
## Run: godot --headless --path . -s res://tests/test_describe.gd
|
||||
## Run: tools/run_tests.sh describe
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
func run() -> void:
|
||||
_test_labels()
|
||||
_test_effects()
|
||||
_test_conditions()
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
extends TestBase
|
||||
extends AppTestBase
|
||||
## Build mode: dragging a result's handle reorders the card's results. Ranged
|
||||
## cards keep their ranges in place; the move is one undo step.
|
||||
## Run: godot --headless --path . -s res://tests/test_entry_drag.gd -- --sample
|
||||
## Run: tools/run_tests.sh entry_drag
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
func run() -> void:
|
||||
if not await start_main():
|
||||
return
|
||||
main.set_mode(Main.Mode.BUILD)
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
extends TestBase
|
||||
## if(condition, then, else) in expressions, and the refused inline ternary.
|
||||
## Run: godot --headless --path . -s res://tests/test_expr_if.gd -- --sample
|
||||
## Run: tools/run_tests.sh expr_if
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
func run() -> void:
|
||||
_value("if(1 > 2, 10, 20)", 20)
|
||||
_value("if(3 > 2, 10, 20)", 10)
|
||||
_value("if(1 = 1, \"yes\", \"no\")", "yes")
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
extends TestBase
|
||||
extends AppTestBase
|
||||
## Fast roll (Shift-click): the whole result shows at once, with no animation.
|
||||
## Run: godot --headless --path . -s res://tests/test_fast_roll.gd -- --sample
|
||||
## Run: tools/run_tests.sh fast_roll
|
||||
## (--sample keeps the app from reading or writing saved collections.)
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
func run() -> void:
|
||||
if not await start_main():
|
||||
return
|
||||
main.rng.seed = 7
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
extends TestBase
|
||||
extends AppTestBase
|
||||
## Group marks: a member card's top-right corner shows its group's colour (its
|
||||
## own, else the theme's GROUP); a card that only lies inside the frame has
|
||||
## none. The colour is saved and undoable.
|
||||
## Run: godot --headless --path . -s res://tests/test_group_marks.gd -- --sample
|
||||
## Run: tools/run_tests.sh group_marks
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
if not await start_main():
|
||||
func run() -> void:
|
||||
if not await start_main(false):
|
||||
return
|
||||
main.data.load_dict({"format_version": 2, "id": "marks-test", "name": "Marks", "tables": [
|
||||
{"id": "a", "name": "Alpha", "x": 40, "y": 60, "entries": [{"id": "e1", "text": "One"}]},
|
||||
|
|
|
|||
|
|
@ -1,17 +1,17 @@
|
|||
extends TestBase
|
||||
extends AppTestBase
|
||||
## Group cards: the model and file format, membership, and in the app the
|
||||
## frame, collapsing (hidden members, re-routed pipes, lit results, choice
|
||||
## pop-ups), moving, dropping cards in and out, ungroup and delete.
|
||||
## Run: godot --headless --path . -s res://tests/test_groups.gd -- --sample
|
||||
## Run: tools/run_tests.sh groups
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
func run() -> void:
|
||||
if not require_sample():
|
||||
return
|
||||
_test_model()
|
||||
_test_json()
|
||||
_test_import()
|
||||
if not await start_main():
|
||||
if not await start_main(false):
|
||||
return
|
||||
main.rng.seed = 5
|
||||
await _load(_board_dict())
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
extends TestBase
|
||||
extends AppTestBase
|
||||
## The Build inspector (docs/PLAIN.md §6): selection, the effects and
|
||||
## condition builders, Otherwise, pipe inputs, check fields and the modifier
|
||||
## picker, collection members, options source, the value picker, the
|
||||
## Plain/Text switch, undo, and dirty/save.
|
||||
## Run: godot --headless --path . -s res://tests/test_inspector.gd -- --sample
|
||||
## Run: tools/run_tests.sh inspector
|
||||
|
||||
var insp: Inspector
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
if not await start_main():
|
||||
func run() -> void:
|
||||
if not await start_main(false):
|
||||
return
|
||||
main.set_anchors_and_offsets_preset(Control.PRESET_TOP_LEFT)
|
||||
main.size = Vector2(1440, 900)
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
extends TestBase
|
||||
extends AppTestBase
|
||||
## The inspector's card page as one list (InspectorList): a section for the
|
||||
## card and one per result; selecting on the spread opens only that section;
|
||||
## sections opened by hand stay open and edits go to the section clicked in;
|
||||
## a result's weight, range and position (InspectorRange).
|
||||
## Run: godot --headless --path . -s res://tests/test_inspector_list.gd -- --sample
|
||||
## Run: tools/run_tests.sh inspector_list
|
||||
|
||||
var insp: Inspector
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
if not await start_main():
|
||||
func run() -> void:
|
||||
if not await start_main(false):
|
||||
return
|
||||
main.set_anchors_and_offsets_preset(Control.PRESET_TOP_LEFT)
|
||||
main.size = Vector2(1440, 900)
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
extends TestBase
|
||||
## Headless checks for the roller working with RollContext, TextExpander,
|
||||
## pipes that save variables, card decks and StateStore.
|
||||
## Run: godot --headless --path . -s res://tests/test_integration.gd
|
||||
## Run: tools/run_tests.sh integration
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
func run() -> void:
|
||||
_test_refs_and_vars()
|
||||
_test_pipe_save()
|
||||
_test_persistent_across_rolls()
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
extends TestBase
|
||||
## Headless checks for the import/export converters.
|
||||
## Run: godot --headless --path . -s res://tests/test_io.gd
|
||||
## Run: tools/run_tests.sh io
|
||||
|
||||
const TMP_DIR := "user://test_io_tmp/"
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
func run() -> void:
|
||||
DirAccess.make_dir_recursive_absolute(TMP_DIR)
|
||||
_test_json()
|
||||
_test_canvas()
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
extends TestBase
|
||||
extends AppTestBase
|
||||
## List view: rows for every card with thread counts and Roll, search, new
|
||||
## groups, and drag-and-drop moves (reorder, into a group, group in group).
|
||||
## Run: godot --headless --path . -s res://tests/test_list_view.gd -- --sample
|
||||
## Run: tools/run_tests.sh list_view
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
func run() -> void:
|
||||
if not await start_main():
|
||||
return
|
||||
await _test_rows()
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
extends TestBase
|
||||
extends AppTestBase
|
||||
## List values: the "Add to list" change row (picking a list, the result's own
|
||||
## text as the item, a new value made there is a list), and "Allow repeats".
|
||||
## Run: godot --headless --path . -s res://tests/test_lists.gd -- --sample
|
||||
## Run: tools/run_tests.sh lists
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
if not await start_main():
|
||||
func run() -> void:
|
||||
if not await start_main(false):
|
||||
return
|
||||
main.set_mode(Main.Mode.BUILD)
|
||||
main.data.load_dict({"format_version": 2, "id": "list-test", "name": "List test", "tables": [
|
||||
|
|
|
|||
|
|
@ -2,10 +2,10 @@ extends TestBase
|
|||
## Headless checks for logic cards (docs/LOGIC.md): expressions, effects,
|
||||
## variables, choice / loop / variable / sheet cards, the action limit, long
|
||||
## chains and the file format.
|
||||
## Run: godot --headless --path . -s res://tests/test_logic.gd
|
||||
## Run: tools/run_tests.sh logic
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
func run() -> void:
|
||||
_test_expressions()
|
||||
_test_effects()
|
||||
_test_variables()
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
extends TestBase
|
||||
extends AppTestBase
|
||||
## Logic cards in the app: the choice pop-up, progress while it's open,
|
||||
## cancelling, a new roll replacing an open question, live variable and sheet
|
||||
## cards, the long-chain tray and the Build-mode settings rules.
|
||||
## Run: godot --headless --path . -s res://tests/test_logic_ui.gd -- --sample
|
||||
## Run: tools/run_tests.sh logic_ui
|
||||
## (--sample keeps the app from reading or writing saved collections.)
|
||||
|
||||
const DEMO := "res://examples/logic_demo.json"
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
if not await start_main():
|
||||
func run() -> void:
|
||||
if not await start_main(false):
|
||||
return
|
||||
main.rng.seed = 11
|
||||
|
||||
|
|
@ -26,7 +26,6 @@ func _init() -> void:
|
|||
_test_settings_rules()
|
||||
_test_add_kinds()
|
||||
await _test_long_chain()
|
||||
await _test_action_limit()
|
||||
|
||||
finish()
|
||||
|
||||
|
|
@ -416,13 +415,13 @@ func _chips() -> int:
|
|||
|
||||
|
||||
func _test_long_chain() -> void:
|
||||
_long_chain(3000)
|
||||
_long_chain(320)
|
||||
await process_frame
|
||||
var t0 := Time.get_ticks_msec()
|
||||
main.start_roll("long_start")
|
||||
var ms := Time.get_ticks_msec() - t0
|
||||
var all: Array = main.current["all"]
|
||||
_eq(all.size(), 3001, "a 3,001-step chain")
|
||||
_eq(all.size(), 321, "a 321-step chain")
|
||||
_check(main.current.get("done", false), "a long chain shows at once, without animating")
|
||||
_check(main.is_entry_lit("long_link", "e1"), "its path is lit")
|
||||
_eq(_chips(), ResultTray.TAIL, "the tray shows only the last %d steps" % ResultTray.TAIL)
|
||||
|
|
@ -430,26 +429,17 @@ func _test_long_chain() -> void:
|
|||
for c in main.tray._flow.get_children():
|
||||
if c is HBoxContainer and c.get_child(0) is Button:
|
||||
toggle = c.get_child(0)
|
||||
_check(toggle != null and toggle.text == "+2,989 earlier steps", "a +N earlier steps toggle: %s" % (toggle.text if toggle else "none"))
|
||||
_check(toggle != null and toggle.text == "+309 earlier steps", "a +N earlier steps toggle: %s" % (toggle.text if toggle else "none"))
|
||||
if toggle:
|
||||
toggle.pressed.emit()
|
||||
_eq(_chips(), ResultTray.MAX_EXPANDED, "expanding shows more steps (capped)")
|
||||
_check(ms < 4000, "lighting 3,000 steps is quick (%d ms)" % ms)
|
||||
print(" (3,001-step roll, lit and shown in %d ms)" % ms)
|
||||
_check(main.rolling.result_text(all, ResultTray.COPY_TEXT).length() < 3001 * 40, "copy text indents are capped")
|
||||
_check(ms < 4000, "lighting 320 steps is quick (%d ms)" % ms)
|
||||
print(" (321-step roll, lit and shown in %d ms)" % ms)
|
||||
_check(main.rolling.result_text(all, ResultTray.COPY_TEXT).length() < 321 * 40, "copy text indents are capped")
|
||||
var line := EarlierRolls.earlier_line({"root_name": "x", "steps": all})
|
||||
_check(line.length() < 2000, "Earlier rows show the last few steps of a long chain")
|
||||
await process_frame
|
||||
|
||||
|
||||
func _test_action_limit() -> void:
|
||||
_long_chain(20000)
|
||||
await process_frame
|
||||
main.start_roll("long_start")
|
||||
_check(str(main.current.get("halted", "")).begins_with("Stopped after 10,000"), "the action limit is reported: %s" % str(main.current.get("halted", "")))
|
||||
_check(main.tray._halt.visible and main.tray._halt_label.text.contains("10,000"), "the tray shows the limit clearly")
|
||||
await process_frame
|
||||
|
||||
|
||||
# ---------------------------------------------------------------- checks
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
extends TestBase
|
||||
extends AppTestBase
|
||||
## The phone layout (List fills the screen, Spread/List swap, slim bar and
|
||||
## tray, View/Help/Play-Build in ☰) and touch gestures (pinch zoom, a long
|
||||
## press timing out into a right-click).
|
||||
## Run: godot --headless --path . -s res://tests/test_mobile.gd -- --sample
|
||||
## Run: tools/run_tests.sh mobile
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
func run() -> void:
|
||||
if not await start_main():
|
||||
return
|
||||
await _test_layout()
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
extends TestBase
|
||||
## Headless checks for dice, weights, pipe options, card mode and JSON.
|
||||
## Run: godot --headless --path . -s res://tests/test_model.gd
|
||||
## Run: tools/run_tests.sh model
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
func run() -> void:
|
||||
_test_dice()
|
||||
_test_weights()
|
||||
_test_ranged_dice()
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@ extends TestBase
|
|||
## RollRange): results past the dice, using the nearest result past the ends,
|
||||
## chances with a modifier, the file format, plain words and the Why line,
|
||||
## and the ModifierEditor's plain forms.
|
||||
## Run: godot --headless --path . -s res://tests/test_modifier.gd
|
||||
## Run: tools/run_tests.sh modifier
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
func run() -> void:
|
||||
_test_model()
|
||||
_test_chances()
|
||||
_test_rolls()
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
extends TestBase
|
||||
extends AppTestBase
|
||||
## Navigation on big boards: search (BoardSearch and the panel), focus_table,
|
||||
## the minimap, Pack collapsed groups (and making room when a packed group
|
||||
## expands), lazily built cards for collapsed groups, and the resizable tray
|
||||
## and inspector.
|
||||
## Run: godot --headless --path . -s res://tests/test_navigation.gd -- --sample
|
||||
## Run: tools/run_tests.sh navigation
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
func run() -> void:
|
||||
if not require_sample():
|
||||
return
|
||||
_test_fold_and_layout()
|
||||
if not await start_main():
|
||||
if not await start_main(false):
|
||||
return
|
||||
# The headless window is tiny; give the app a real screen's worth of room.
|
||||
main.set_anchors_and_offsets_preset(Control.PRESET_TOP_LEFT)
|
||||
|
|
@ -339,17 +339,17 @@ func _test_panels() -> void:
|
|||
_check(foot != null and side != null, "the tray and the inspector each have a drag handle")
|
||||
if foot == null or side == null:
|
||||
return
|
||||
# Sixty long Earlier rows scroll inside the tray instead of growing it.
|
||||
# Twenty long Earlier rows scroll inside the tray instead of growing it.
|
||||
var steps: Array = []
|
||||
for k in 8:
|
||||
steps.append({"text": "A long step with plenty of words in it, number %d" % k})
|
||||
main.history.clear()
|
||||
for i in 60:
|
||||
for i in 20:
|
||||
main.history.append({"root_name": "Start", "time": 0.0, "steps": steps})
|
||||
main.tray.set_side(ResultTray.Side.EARLIER)
|
||||
main.tray.render()
|
||||
await _frames()
|
||||
_check(absf(main.tray.size.y - foot.size_px) < 2.0, "the tray keeps its height with 60 earlier rolls (%.0f vs %.0f)" % [main.tray.size.y, foot.size_px])
|
||||
_check(absf(main.tray.size.y - foot.size_px) < 2.0, "the tray keeps its height with 20 earlier rolls (%.0f vs %.0f)" % [main.tray.size.y, foot.size_px])
|
||||
_check(main.tray._earlier.scroll.get_v_scroll_bar().max_value > main.tray._earlier.scroll.size.y, "Earlier scrolls")
|
||||
foot.set_size_px(400.0)
|
||||
await _frames()
|
||||
|
|
|
|||
|
|
@ -4,10 +4,10 @@ extends TestBase
|
|||
## docs/LOGIC.md §2a: candidates, labels and values, fixed extras, Random,
|
||||
## "No options available", the file format, lint, a small "raise a skill you
|
||||
## already have" board and the choice pop-up's rendering.
|
||||
## Run: godot --headless --path . -s res://tests/test_options.gd -- --sample
|
||||
## Run: tools/run_tests.sh options
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
func run() -> void:
|
||||
if not require_sample():
|
||||
return
|
||||
_test_prefix_options()
|
||||
|
|
@ -527,6 +527,7 @@ func _test_settings() -> void:
|
|||
|
||||
func _test_card() -> void:
|
||||
var main: Main = load("res://ui/main.tscn").instantiate()
|
||||
main.data = TowerBoard.new()
|
||||
root.add_child(main)
|
||||
for i in 5:
|
||||
await process_frame
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
extends TestBase
|
||||
extends AppTestBase
|
||||
## The display side of Plain Build (docs/PLAIN.md §6): plain chips and lines
|
||||
## on cards and their text-mode twins, the switch refreshing them, pipe
|
||||
## labels, check / collection / inputs visuals, "Why this?" sentences and the
|
||||
## tray's button, and Build-mode row selection.
|
||||
## Run: godot --headless --path . -s res://tests/test_plain_display.gd -- --sample
|
||||
## Run: tools/run_tests.sh plain_display
|
||||
##
|
||||
## Main here is a small subclass with the hooks the Build inspector adds
|
||||
## (rules_plain(), rules_view_changed, select_result(), select_card()), so the
|
||||
|
|
@ -53,12 +53,12 @@ const BOARD := {
|
|||
]}
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
func run() -> void:
|
||||
if not require_sample():
|
||||
return
|
||||
_test_why_sentences()
|
||||
_test_rules_view_helpers()
|
||||
if not await start_main():
|
||||
if not await start_main(false):
|
||||
return
|
||||
main.rng.seed = 7
|
||||
main.data.load_json(JSON.stringify(BOARD))
|
||||
|
|
|
|||
|
|
@ -2,10 +2,10 @@ extends TestBase
|
|||
## Headless checks for ranged cards edited by weight or by range (RangeWeights):
|
||||
## turning gaps into empty results, laying ranges out from weights, the total
|
||||
## warning, auto-sort, the file format, and an empty card switching to Ranged.
|
||||
## Run: godot --headless --path . -s res://tests/test_range_weights.gd
|
||||
## Run: tools/run_tests.sh range_weights
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
func run() -> void:
|
||||
_test_to_weights()
|
||||
_test_total_warning()
|
||||
_test_auto_sort()
|
||||
|
|
|
|||
|
|
@ -2,10 +2,10 @@ extends TestBase
|
|||
## Roll features in the engine: combining a thread's repeated rolls (add,
|
||||
## highest, lowest, choose), saving the combined value, and only the kept roll
|
||||
## following its threads.
|
||||
## Run: godot --headless --path . -s res://tests/test_roll_features.gd
|
||||
## Run: tools/run_tests.sh roll_features
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
func run() -> void:
|
||||
_test_combine()
|
||||
_test_no_repeats()
|
||||
await _test_choose()
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
extends TestBase
|
||||
## Headless checks for the data model and roller.
|
||||
## Run: godot --headless --path . -s res://tests/test_roller.gd
|
||||
## Run: tools/run_tests.sh roller
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
func run() -> void:
|
||||
var board := SampleBoard.create()
|
||||
var rng := RandomNumberGenerator.new()
|
||||
rng.seed = 12345
|
||||
|
|
@ -27,13 +27,13 @@ func _init() -> void:
|
|||
|
||||
# Range weighting: 01–30 should come up about 30% of the time.
|
||||
var counts := {}
|
||||
for i in 20000:
|
||||
for i in 4000:
|
||||
var n := Roller.roll(board, "wilderness", rng)
|
||||
var text: String = (n["entry"] as TableEntry).text
|
||||
counts[text] = counts.get(text, 0) + 1
|
||||
var share := float(counts.get("Travelers on the road", 0)) / 20000.0
|
||||
var share := float(counts.get("Travelers on the road", 0)) / 4000.0
|
||||
_check(absf(share - 0.30) < 0.02, "01–30 rolls about 30%% of the time (got %.3f)" % share)
|
||||
var rare := float(counts.get("An odd find", 0)) / 20000.0
|
||||
var rare := float(counts.get("An odd find", 0)) / 4000.0
|
||||
_check(absf(rare - 0.05) < 0.01, "96–00 rolls about 5%% of the time (got %.3f)" % rare)
|
||||
|
||||
# Chains follow pipes.
|
||||
|
|
@ -66,16 +66,6 @@ func _init() -> void:
|
|||
stops += 1
|
||||
_check(stops > 50 and stops < 150, "rolls into a gap stop with a message (%d/200)" % stops)
|
||||
|
||||
# A self-pipe stops at the action limit (docs/LOGIC.md §7) instead of looping forever.
|
||||
var loop := RollTable.new("loop", "Repeat")
|
||||
var again := TableEntry.new("e1", "Again")
|
||||
again.pipes.append("loop")
|
||||
loop.entries.append(again)
|
||||
var b3 := TowerBoard.new()
|
||||
b3.tables.append(loop)
|
||||
var steps := Roller.flatten(Roller.roll(b3, "loop", rng), [])
|
||||
_check(steps.size() == Roller.MAX_ACTIONS + 1 and str(steps[steps.size() - 1]["text"]) == Roller.limit_text(), "self-thread stops at the action limit (%d steps)" % steps.size())
|
||||
|
||||
# JSON round trip keeps everything.
|
||||
var copy := TowerBoard.new()
|
||||
_check(copy.load_json(board.to_json()), "spread JSON loads back")
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@ extends TestBase
|
|||
## and §3b): when / otherwise selection, the snapshot rule, expression errors,
|
||||
## first-match routing, "No case matched", the file format, lint_pipes() and a
|
||||
## small board where a router replaces a chain-variable workaround.
|
||||
## Run: godot --headless --path . -s res://tests/test_router.gd
|
||||
## Run: tools/run_tests.sh router
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
func run() -> void:
|
||||
_test_when_otherwise()
|
||||
_test_snapshot()
|
||||
_test_errors()
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
extends TestBase
|
||||
## Headless checks for the app-shell logic: table settings, collections, import.
|
||||
## Run: godot --headless --path . -s res://tests/test_shell.gd
|
||||
## Run: tools/run_tests.sh shell
|
||||
|
||||
const ROOT := "user://test_shell_tmp"
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
func run() -> void:
|
||||
_wipe(ROOT)
|
||||
_test_settings()
|
||||
_test_ranges()
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
extends TestBase
|
||||
## Keeps the simulator (BoardTester, and its CLI tools/simulate_board.gd) working: runs it on a small inline board with
|
||||
## a choice, a loop, a check, a bad effect, an unreachable table and a sheet.
|
||||
## Run: godot --headless --path . -s res://tests/test_simulate.gd
|
||||
## Run: tools/run_tests.sh simulate
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
func run() -> void:
|
||||
var b := _board()
|
||||
var r: Dictionary = await BoardTester.simulate(b, "start", {"runs": 60, "seed": 3, "track": ["gold", "@name"]})
|
||||
_eq(r["runs"], 60, "60 runs")
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
extends TestBase
|
||||
extends AppTestBase
|
||||
## Small UI items: backwards ranges warn and block rolling (no auto-swap), the
|
||||
## inspector's thread lists, replacing a template, the tray chip's bold source
|
||||
## name, and the export menu's diagram formats.
|
||||
## Run: godot --headless --path . -s res://tests/test_small_ui.gd -- --sample
|
||||
## Run: tools/run_tests.sh small_ui
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
func run() -> void:
|
||||
if not await start_main():
|
||||
return
|
||||
await _test_backwards_range()
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
extends TestBase
|
||||
extends AppTestBase
|
||||
## Spellchecking in Build (Spellcheck, SpellWords, SpellUnderline), with a
|
||||
## stand-in checker so the test needs no native add-on: which words are
|
||||
## checked, underlines on card and inspector fields, suggestions replacing a
|
||||
## word, the spread's own dictionary (saved with it) and Ignore.
|
||||
## Run: godot --headless --path . -s res://tests/test_spellcheck.gd -- --sample
|
||||
## Run: tools/run_tests.sh spellcheck
|
||||
|
||||
|
||||
## Knows a few words; suggests from a fixed table.
|
||||
|
|
@ -18,11 +18,11 @@ class FakeChecker:
|
|||
return PackedStringArray({"tinkerr": ["tinker", "tinkers"], "wrok": ["work"]}.get(word.to_lower(), []))
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
func run() -> void:
|
||||
_test_words()
|
||||
Spellcheck.use_backend(FakeChecker.new())
|
||||
_test_checking()
|
||||
if not await start_main():
|
||||
if not await start_main(false):
|
||||
return
|
||||
main.set_mode(Main.Mode.BUILD)
|
||||
main.data.load_dict({"format_version": 2, "id": "spell-test", "name": "Spell test", "tables": [
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
extends TestBase
|
||||
extends AppTestBase
|
||||
## Headless checks for spread folders (core/spread_folders.gd) and the recent
|
||||
## spreads list (core/recent_spreads.gd), and the spread switcher's menu built
|
||||
## from them (on a temporary library, never the saved one).
|
||||
## Run: godot --headless --path . -s res://tests/test_spread_folders.gd -- --sample
|
||||
## Run: tools/run_tests.sh spread_folders
|
||||
|
||||
const ROOT := "user://test_spread_folders_tmp"
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
func run() -> void:
|
||||
_wipe(ROOT)
|
||||
_test_paths()
|
||||
_test_listing()
|
||||
|
|
|
|||
|
|
@ -2,10 +2,10 @@ extends TestBase
|
|||
## Rolling a card from another spread: [[Treasure::Loot]] rolls Loot in the
|
||||
## Treasure spread (its own references resolve there), changes this spread's
|
||||
## values, and a missing spread or card shows the missing marker.
|
||||
## Run: godot --headless --path . -s res://tests/test_spread_links.gd
|
||||
## Run: tools/run_tests.sh spread_links
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
func run() -> void:
|
||||
var treasure := TowerBoard.new()
|
||||
treasure.id = "treasure"
|
||||
treasure.name = "Treasure"
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
extends TestBase
|
||||
## Headless checks for collections, LibraryStore and StateStore.
|
||||
## Run: godot --headless --path . -s res://tests/test_storage.gd
|
||||
## Run: tools/run_tests.sh storage
|
||||
|
||||
const ROOT := "user://test_storage_tmp"
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
func run() -> void:
|
||||
_wipe(ROOT)
|
||||
_test_versions()
|
||||
_test_library()
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
extends TestBase
|
||||
extends AppTestBase
|
||||
## Templates: saving (placeholder detection, relative positions, pipes kept or
|
||||
## recorded by name), inserting (substitution, fresh ids, internal pipes kept,
|
||||
## outside pipes relinked or reported), the library and the built-in
|
||||
## templates, and the app's save, list and insert.
|
||||
## Run: godot --headless --path . -s res://tests/test_templates.gd -- --sample
|
||||
## Run: tools/run_tests.sh templates
|
||||
|
||||
const TMP_ROOT := "user://test_templates_tmp"
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
func run() -> void:
|
||||
if not require_sample():
|
||||
return
|
||||
_test_make()
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
extends TestBase
|
||||
## Headless checks for RollContext, TextExpander and Formatter.
|
||||
## Run: godot --headless --path . -s res://tests/test_text.gd
|
||||
## Run: tools/run_tests.sh text
|
||||
|
||||
const TABLES := {
|
||||
"names": "Names",
|
||||
|
|
@ -21,7 +21,7 @@ var _ctx: RollContext
|
|||
var _rolls: Dictionary = {}
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
func run() -> void:
|
||||
_test_expander()
|
||||
_test_formatter()
|
||||
_test_format_menu()
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
extends TestBase
|
||||
extends AppTestBase
|
||||
## Theme sets: applying built-ins sets Style tokens and fills, saving and
|
||||
## deleting a user set, and the Theme dialog building its editors.
|
||||
## Run: godot --headless --path . -s res://tests/test_theme.gd -- --sample
|
||||
## Run: tools/run_tests.sh theme
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
func run() -> void:
|
||||
if not require_sample():
|
||||
return
|
||||
ThemeStore.DIR = OS.get_temp_dir().path_join("tt_theme_test_%d/" % OS.get_process_id())
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
extends TestBase
|
||||
extends AppTestBase
|
||||
## Theme files: every built-in theme's pictures, sounds and fonts load; frame
|
||||
## sets, thread strips, the backdrop and the recoloured mascot build; a copy of
|
||||
## a built-in keeps its file paths; the sound board follows the volume.
|
||||
## Run: godot --headless --path . -s res://tests/test_theme_assets.gd -- --sample
|
||||
## Run: tools/run_tests.sh theme_assets
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
func run() -> void:
|
||||
if not require_sample():
|
||||
return
|
||||
ThemeStore.DIR = OS.get_temp_dir().path_join("tt_theme_assets_%d/" % OS.get_process_id())
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
extends TestBase
|
||||
extends AppTestBase
|
||||
## The top bar's menus (View ▾, the zoom control, Board ▾ with Pack, Help ▾),
|
||||
## striped result rows, the Build card's ⋯ menu and the row × that shows on
|
||||
## hover or selection, and the Help window's topics and links.
|
||||
## Run: godot --headless --path . -s res://tests/test_top_bar.gd -- --sample
|
||||
## Run: tools/run_tests.sh top_bar
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
func run() -> void:
|
||||
if not await start_main():
|
||||
return
|
||||
main.set_anchors_and_offsets_preset(Control.PRESET_TOP_LEFT)
|
||||
|
|
@ -115,8 +115,6 @@ func _test_card_menu() -> void:
|
|||
main.undo_redo.undo()
|
||||
await _frames()
|
||||
_check(main.data.get_table("loot") != null, "and undo brings it back")
|
||||
main.set_mode(Main.Mode.PLAY)
|
||||
await _frames()
|
||||
|
||||
|
||||
func _test_help() -> void:
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
extends TestBase
|
||||
extends AppTestBase
|
||||
## Cards with columns on the spread and in the inspector: the header and the
|
||||
## cells, the lit cells after a roll, inline cell editing, and the inspector's
|
||||
## Columns section (add, rename, move, remove, roll mode, one phrase, save as,
|
||||
## only if) with the result's cell fields and roll twice and combine, all undoable.
|
||||
## Run: godot --headless --path . -s res://tests/test_ui_columns.gd -- --sample
|
||||
## Run: tools/run_tests.sh ui_columns
|
||||
|
||||
var insp: Inspector
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
if not await start_main():
|
||||
func run() -> void:
|
||||
if not await start_main(false):
|
||||
return
|
||||
main.set_anchors_and_offsets_preset(Control.PRESET_TOP_LEFT)
|
||||
main.size = Vector2(1440, 900)
|
||||
|
|
|
|||
|
|
@ -1,17 +1,17 @@
|
|||
extends TestBase
|
||||
extends AppTestBase
|
||||
## Scale values in the UI (Scales): making one (+ Card, the inspector's steps
|
||||
## and starting step, switching type), showing one (the card's value and row
|
||||
## of steps, the Variables tab), the effect and condition rows for a scale,
|
||||
## and the help topic.
|
||||
## Run: godot --headless --path . -s res://tests/test_ui_scales.gd -- --sample
|
||||
## Run: tools/run_tests.sh ui_scales
|
||||
|
||||
const CLIMATE := ["Supercold", "Cold", "Temperate", "Hot", "Superhot"]
|
||||
|
||||
var insp: Inspector
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
if not await start_main():
|
||||
func run() -> void:
|
||||
if not await start_main(false):
|
||||
return
|
||||
main.set_anchors_and_offsets_preset(Control.PRESET_TOP_LEFT)
|
||||
main.size = Vector2(1440, 900)
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
extends TestBase
|
||||
extends AppTestBase
|
||||
## The thread inspector's "Roll it with … instead" field and "Roll again if
|
||||
## it comes up" list: shown for a card with numbered ranges, edits land on the
|
||||
## result, undo puts them back.
|
||||
## Run: godot --headless --path . -s res://tests/test_ui_threads.gd -- --sample
|
||||
## Run: tools/run_tests.sh ui_threads
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
func run() -> void:
|
||||
if not await start_main():
|
||||
return
|
||||
await _test_ranged_target()
|
||||
|
|
@ -35,8 +35,7 @@ func _test_ports_under_cards() -> void:
|
|||
## Build mode: each card has a port on its bottom edge; a thread laid from it
|
||||
## is a card thread, drawn from there, listed on the card and undoable.
|
||||
func _test_card_thread_port() -> void:
|
||||
main.set_mode(Main.Mode.BUILD)
|
||||
await _frames(10)
|
||||
await _frames(40)
|
||||
var road := main.data.get_table("road")
|
||||
var card := main.card_for("road")
|
||||
main.board.set_zoom(1.0)
|
||||
|
|
@ -61,8 +60,6 @@ func _test_card_thread_port() -> void:
|
|||
main.undo_redo.undo()
|
||||
await _frames(2)
|
||||
_check(main.data.get_table("road").outlet.pipes.is_empty(), "undo takes it away")
|
||||
main.set_mode(Main.Mode.PLAY)
|
||||
await _frames()
|
||||
|
||||
|
||||
func _find_text(n: Node, prefix: String) -> bool:
|
||||
|
|
|
|||
|
|
@ -1,18 +1,18 @@
|
|||
extends TestBase
|
||||
extends AppTestBase
|
||||
## Undo and redo of Build edits (EditHistory and Main's "Undo and redo"):
|
||||
## every kind of edit, coalescing, redo being cleared, the cap, per-collection
|
||||
## histories, labels, view and lit state, the toast's Undo, lazily built cards,
|
||||
## the shortcuts and buttons, and the snapshot cost on a big board.
|
||||
## Run: godot --headless --path . -s res://tests/test_undo.gd -- --sample
|
||||
## Run: tools/run_tests.sh undo
|
||||
## [--big-board=<collection.json>] times a real board instead of a made-up
|
||||
## 800-card one.
|
||||
## 320-card one.
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
func run() -> void:
|
||||
if not require_sample():
|
||||
return
|
||||
_test_history_unit()
|
||||
if not await start_main():
|
||||
if not await start_main(false):
|
||||
return
|
||||
main.set_anchors_and_offsets_preset(Control.PRESET_TOP_LEFT)
|
||||
main.size = Vector2(1440, 900)
|
||||
|
|
@ -171,7 +171,7 @@ func _test_card_fields() -> void:
|
|||
main.mark_dirty()
|
||||
await _frames()
|
||||
_check(_steps() == n0 + 1 and _label() == "Edit Loot", "a weight is a step: %s" % _label())
|
||||
await create_timer(EditHistory.COALESCE_SECS + 0.1).timeout
|
||||
_pass_coalesce_window()
|
||||
_t("a").entries[0].effects = "@hp -= 1"
|
||||
main.mark_dirty()
|
||||
await _frames()
|
||||
|
|
@ -242,7 +242,7 @@ func _test_pipes() -> void:
|
|||
main.undo_redo.undo()
|
||||
_check(_t("a").entries[0].pipes == ["b"], "undo lays it again")
|
||||
var e := _t("a").entries[0]
|
||||
await create_timer(EditHistory.COALESCE_SECS + 0.1).timeout
|
||||
_pass_coalesce_window()
|
||||
var n0 := _steps()
|
||||
e.set_pipe_count("b", 3)
|
||||
main.mark_dirty()
|
||||
|
|
@ -251,15 +251,15 @@ func _test_pipes() -> void:
|
|||
main.mark_dirty()
|
||||
await _frames()
|
||||
_check(_steps() == n0 + 1 and _label() == "Edit thread Loot → Gems", "nudging a thread's count twice is one step: %s" % _label())
|
||||
await create_timer(EditHistory.COALESCE_SECS + 0.1).timeout
|
||||
_pass_coalesce_window()
|
||||
e.set_pipe_save("b", "gem")
|
||||
main.mark_dirty()
|
||||
await _frames()
|
||||
await create_timer(EditHistory.COALESCE_SECS + 0.1).timeout
|
||||
_pass_coalesce_window()
|
||||
e.set_pipe_when("b", "@hp > 2")
|
||||
main.mark_dirty()
|
||||
await _frames()
|
||||
await create_timer(EditHistory.COALESCE_SECS + 0.1).timeout
|
||||
_pass_coalesce_window()
|
||||
e.set_pipe_when("b", "")
|
||||
e.set_pipe_otherwise("b", true)
|
||||
main.mark_dirty()
|
||||
|
|
@ -561,7 +561,7 @@ func _test_big_board() -> void:
|
|||
if path != "" and FileAccess.file_exists(path):
|
||||
d = JSON.parse_string(FileAccess.get_file_as_string(path))
|
||||
else:
|
||||
d = _synthetic_board(800)
|
||||
d = _synthetic_board(320)
|
||||
await _load(d)
|
||||
var t := main.data.tables[main.data.tables.size() / 2]
|
||||
var u := main.data.tables[main.data.tables.size() / 3]
|
||||
|
|
@ -628,3 +628,9 @@ func _synthetic_board(n: int) -> Dictionary:
|
|||
members.append("t%d" % i)
|
||||
groups.append({"id": "g%d" % k, "name": "Group %d" % k, "x": 0, "y": k * 400, "w": 12000, "h": 380, "members": members, "collapsed": true})
|
||||
return {"format_version": 2, "id": "big", "name": "Big", "tables": tables, "groups": groups}
|
||||
|
||||
|
||||
## Ages the newest step past the merge window, instead of really waiting.
|
||||
func _pass_coalesce_window() -> void:
|
||||
if main.undo_redo.edits.can_undo():
|
||||
main.undo_redo.edits.undo_stack.back()["time"] -= EditHistory.COALESCE_SECS + 0.1
|
||||
|
|
|
|||
|
|
@ -1,42 +1,38 @@
|
|||
class_name TestBase
|
||||
extends SceneTree
|
||||
## Shared boilerplate for the headless suites: the --sample guard, loading the
|
||||
## app, frame waiting, the check helpers and the PASS/FAIL summary the runner
|
||||
## (tools/run_tests.sh) looks for. A suite extends this and calls
|
||||
## `if not await start_main(): return` first when it needs the app.
|
||||
extends Node
|
||||
## Shared boilerplate for the headless suites: the --sample guard, frame
|
||||
## waiting and the check helpers. tests/run_suites.gd runs several suites in one
|
||||
## Godot process: it adds the suite to the tree, calls run() and waits for
|
||||
## finish(). Suites that need the app extend AppTestBase.
|
||||
## Never mention Main or other UI classes here: every suite would then compile
|
||||
## the whole app (about 1 s each).
|
||||
|
||||
var _failures := 0
|
||||
var main: Main
|
||||
var failures := 0
|
||||
var done := false
|
||||
|
||||
# The tree's own names, so suites read like a SceneTree script.
|
||||
var root: Window:
|
||||
get: return get_tree().root
|
||||
var process_frame: Signal:
|
||||
get: return get_tree().process_frame
|
||||
|
||||
|
||||
## Returns false (after quitting with 2) unless the suite was started with
|
||||
## `-- --sample`, so a test can't touch saved data.
|
||||
## The suite's checks; overridden by each suite, ends with finish().
|
||||
func run() -> void:
|
||||
pass
|
||||
|
||||
|
||||
## False (and the suite fails) unless started with `-- --sample`, so a test
|
||||
## can't touch saved data.
|
||||
func require_sample() -> bool:
|
||||
if OS.get_cmdline_user_args().has("--sample"):
|
||||
return true
|
||||
print("Run with -- --sample so the test can't touch saved data.")
|
||||
quit(2)
|
||||
abort("Run with -- --sample so the test can't touch saved data.")
|
||||
return false
|
||||
|
||||
|
||||
## Hook: suites that need a customised Main override this.
|
||||
func _create_main() -> Main:
|
||||
return load("res://ui/main.tscn").instantiate()
|
||||
|
||||
|
||||
## Guard, then loads the app under root and waits for it. Returns false (after
|
||||
## quitting) if the guard fails or the app would save.
|
||||
func start_main() -> bool:
|
||||
if not require_sample():
|
||||
return false
|
||||
main = _create_main()
|
||||
root.add_child(main)
|
||||
await _frames(5)
|
||||
if main._saving_enabled:
|
||||
print("Saving is enabled; refusing to run.")
|
||||
quit(2)
|
||||
return false
|
||||
return true
|
||||
func create_timer(secs: float) -> SceneTreeTimer:
|
||||
return get_tree().create_timer(secs)
|
||||
|
||||
|
||||
func _frames(n: int = 2) -> void:
|
||||
|
|
@ -46,7 +42,7 @@ func _frames(n: int = 2) -> void:
|
|||
|
||||
func _check(ok: bool, what: String) -> void:
|
||||
if not ok:
|
||||
_failures += 1
|
||||
failures += 1
|
||||
print("FAIL ", what)
|
||||
|
||||
|
||||
|
|
@ -57,10 +53,19 @@ func _eq(got: Variant, want: Variant, what: String) -> void:
|
|||
_check(same, "%s\n got: %s\n want: %s" % [what, str(got), str(want)])
|
||||
|
||||
|
||||
## Prints the summary line the runner greps for, then quits.
|
||||
func finish() -> void:
|
||||
print("%s: %d failure(s)" % ["PASS" if _failures == 0 else "FAIL", _failures])
|
||||
quit(1 if _failures else 0)
|
||||
done = true
|
||||
|
||||
|
||||
## Fails and ends the suite before its checks.
|
||||
func abort(why: String) -> void:
|
||||
_check(false, why)
|
||||
finish()
|
||||
|
||||
|
||||
## Puts back what the suite changed for the next one in this process.
|
||||
func clean_up() -> void:
|
||||
pass
|
||||
|
||||
|
||||
## Deletes a folder and everything in it (for temporary test folders).
|
||||
|
|
|
|||
|
|
@ -1,45 +1,118 @@
|
|||
#!/usr/bin/env bash
|
||||
# Runs every headless suite in parallel and prints one line per suite.
|
||||
# A suite fails if it doesn't print "PASS: 0 failure(s)" or if its output has
|
||||
# a SCRIPT ERROR (a crashed test function can still print PASS).
|
||||
# Runs the headless suites in a few parallel Godot processes, inside a fixed time budget.
|
||||
#
|
||||
# The budget is a hard limit on the whole run. At the deadline, running suites
|
||||
# are stopped and the rest don't start; those are listed as NOT RUN. Only the
|
||||
# user changes BUDGET_SECS. Suites run longest first (by their last time), which
|
||||
# fills the workers best; one that was never timed runs first.
|
||||
#
|
||||
# A suite fails on a failed check, a SCRIPT ERROR or a Godot crash.
|
||||
#
|
||||
# Usage: tools/run_tests.sh [name-filter] e.g. tools/run_tests.sh inspector
|
||||
# Exit codes: 0 all passed, 1 a suite failed, 2 over budget, nothing failed.
|
||||
# Failing suites print their first 8 error lines; passing output is discarded.
|
||||
set -u
|
||||
cd "$(dirname "$0")/.."
|
||||
readonly BUDGET_SECS=15
|
||||
cd "$(dirname "$0")/.." || exit 1
|
||||
GODOT="${GODOT:-$HOME/apps/Godot_v4.7.2-stable_linux.x86_64}"
|
||||
TIMES=.godot/test_times # git-ignored: "<milliseconds> <suite>"
|
||||
CLASSES=.godot/global_script_class_cache.cfg
|
||||
start_ms=$(date +%s%3N)
|
||||
now_ms() { echo $(( $(date +%s%3N) - start_ms )); }
|
||||
# 1 s is kept back for stopping suites and printing the report.
|
||||
left_ms() { echo $(( BUDGET_SECS * 1000 - 1000 - $(now_ms) )); }
|
||||
# Runs a command at low priority; it is killed at the deadline.
|
||||
in_budget() {
|
||||
local left; left=$(left_ms)
|
||||
(( left < 100 )) && return 124
|
||||
nice -n 10 timeout -s KILL "$(( left / 1000 )).$(printf %03d $(( left % 1000 )))" "$@"
|
||||
}
|
||||
|
||||
OUT="$(mktemp -d)"
|
||||
trap 'rm -rf "$OUT"' EXIT
|
||||
suites=(tests/test_*${1:-}*.gd)
|
||||
# Register any new class_name scripts first (cheap when nothing changed).
|
||||
"$GODOT" --headless --path . --import >/dev/null 2>&1
|
||||
for t in "${suites[@]}"; do
|
||||
n="$(basename "$t" .gd)"
|
||||
( timeout 300 "$GODOT" --headless --path . -s "res://$t" -- --sample >"$OUT/$n.log" 2>&1 ) &
|
||||
while (( $(jobs -rp | wc -l) >= ${JOBS:-8} )); do wait -n; done
|
||||
|
||||
# Register class_name scripts, only when a script was added or changed its list.
|
||||
# Compares names, not dates, so ordinary edits don't cost an import.
|
||||
declared="$(grep -rhoE --include='*.gd' --exclude-dir=.godot --exclude-dir=.claude '^class_name +[A-Za-z0-9_]+' . | awk '{print $2}' | sort)"
|
||||
known="$(grep -oE '"class": &"[^"]+"' "$CLASSES" 2>/dev/null | cut -d'"' -f4 | sort)"
|
||||
if [[ "$declared" != "$known" ]]; then
|
||||
in_budget "$GODOT" --headless --path . --import >/dev/null 2>&1
|
||||
fi
|
||||
|
||||
shopt -s nullglob
|
||||
declare -A last_ms
|
||||
while read -r ms n; do last_ms[$n]=$ms; done < <(cat "$TIMES" 2>/dev/null)
|
||||
mapfile -t suites < <(for t in tests/test_*"${1:-}"*.gd; do
|
||||
n="$(basename "$t" .gd)"; echo "${last_ms[$n]:-99999} $n"
|
||||
done | sort -rn | cut -d' ' -f2)
|
||||
(( ${#suites[@]} )) || { echo "No suite matches '${1:-}'"; exit 1; }
|
||||
|
||||
# A few Godot workers share the list (tests/run_suites.gd). --fixed-fps makes
|
||||
# timers and animations use simulated time, not real waiting.
|
||||
mkdir "$OUT/claims"
|
||||
SUITES="$(IFS=,; echo "${suites[*]}")"
|
||||
export SUITES CLAIMS="$OUT/claims"
|
||||
jobs_wanted=${JOBS:-6}
|
||||
(( jobs_wanted > ${#suites[@]} )) && jobs_wanted=${#suites[@]}
|
||||
for (( w = 0; w < jobs_wanted; w++ )); do
|
||||
in_budget "$GODOT" --headless --fixed-fps 60 --path . -s res://tests/run_suites.gd -- --sample >"$OUT/worker$w" 2>&1 &
|
||||
done
|
||||
wait
|
||||
# Cut the workers' output into one log per suite; "DONE" gives its time.
|
||||
awk -v out="$OUT" '
|
||||
/^SUITE test_/ { suite = $2; log_file = out "/" suite ".log"; printf "" >log_file; next }
|
||||
/^DONE test_/ { print $3 >(out "/" $2 ".ms"); print $4 >(out "/" $2 ".failures"); suite = ""; next }
|
||||
suite != "" { print >log_file }
|
||||
' "$OUT"/worker*
|
||||
|
||||
fail=0
|
||||
not_run=()
|
||||
stopped=()
|
||||
declare -A first_err
|
||||
for t in "${suites[@]}"; do
|
||||
n="$(basename "$t" .gd)"
|
||||
for n in "${suites[@]}"; do
|
||||
log="$OUT/$n.log"
|
||||
if grep -q "PASS: 0 failure(s)" "$log" && ! grep -q "SCRIPT ERROR" "$log"; then
|
||||
echo "ok $n"
|
||||
crashed=0
|
||||
if [[ -e "$OUT/$n.ms" ]]; then
|
||||
last_ms[$n]=$(<"$OUT/$n.ms")
|
||||
if [[ $(<"$OUT/$n.failures") == 0 ]] && ! grep -q "SCRIPT ERROR" "$log"; then
|
||||
echo "ok $n"
|
||||
continue
|
||||
fi
|
||||
elif [[ -e "$log" ]] && grep -q "handle_crash" "$log"; then
|
||||
crashed=1
|
||||
else
|
||||
not_run+=("$n")
|
||||
# Started but stopped at the deadline: it may be what ate the budget.
|
||||
[[ -e "$log" ]] && stopped+=("$n")
|
||||
continue
|
||||
fi
|
||||
fail=1
|
||||
e="$(grep -m1 -E "SCRIPT ERROR|^ *FAIL [^:]" "$log")"
|
||||
# A shared compile error fails many suites the same way: report it once.
|
||||
if [[ "$e" == *"SCRIPT ERROR"* ]]; then
|
||||
if (( ! crashed )) && [[ "$e" == *"SCRIPT ERROR"* ]]; then
|
||||
first_err["$e"]+="$n "
|
||||
else
|
||||
echo "FAIL $n"
|
||||
grep -E "FAIL|SCRIPT ERROR|ERROR" "$log" | head -8
|
||||
(( crashed )) && echo " Godot crashed"
|
||||
grep -E "FAIL|SCRIPT ERROR|ERROR|^ +\[[0-9]+\] .*res://" "$log" | head -8
|
||||
fi
|
||||
done
|
||||
for e in "${!first_err[@]}"; do
|
||||
echo "FAIL ${first_err[$e]}"
|
||||
echo " $e"
|
||||
done
|
||||
(( fail )) && echo "SOME SUITES FAILED" || echo "ALL ${#suites[@]} SUITES PASSED"
|
||||
exit $fail
|
||||
for n in "${!last_ms[@]}"; do
|
||||
[[ -e "tests/$n.gd" ]] && echo "${last_ms[$n]} $n"
|
||||
done | sort -n >"$TIMES"
|
||||
|
||||
took="$(awk -v ms="$(now_ms)" 'BEGIN { printf "%.1f", ms / 1000 }')s of ${BUDGET_SECS}s"
|
||||
if (( ${#not_run[@]} )); then
|
||||
echo "NOT RUN (${#not_run[@]}): ${not_run[*]}"
|
||||
(( ${#stopped[@]} )) && echo "Stopped while running: ${stopped[*]}"
|
||||
echo "Slowest: $(sort -rn "$TIMES" | head -5 | awk '{ printf "%s %.1fs ", $2, $1 / 1000 }')"
|
||||
fi
|
||||
if (( fail )); then echo "SOME SUITES FAILED ($took)"; exit 1; fi
|
||||
if (( ${#not_run[@]} )); then
|
||||
echo "OVER BUDGET: $(( ${#suites[@]} - ${#not_run[@]} )) of ${#suites[@]} suites passed ($took)"; exit 2
|
||||
fi
|
||||
echo "ALL ${#suites[@]} SUITES PASSED ($took)"
|
||||
|
|
|
|||
|
|
@ -148,6 +148,9 @@ func _ready() -> void:
|
|||
WelcomeDialog.maybe_show(self)
|
||||
|
||||
func _exit_tree() -> void:
|
||||
# A roll still animating must not go on after this scene is freed (a theme
|
||||
# change mid-roll reloads it).
|
||||
rolling._token += 1
|
||||
_save_now()
|
||||
|
||||
# ---------- Cards ----------
|
||||
|
|
|
|||
Loading…
Reference in a new issue