5.3 KiB
5.3 KiB
name, description
| name | description |
|---|---|
| godot-cli-test-runner | Run Godot CLI commands for this project with emphasis on headless test execution, script runs, scene runs, and export/debug operations. Use when the user asks to run Godot tests or commands (for example “Godot 跑测试”, “执行 Godot 命令”, “检查 Godot 参数”), troubleshoot CLI failures, or request reusable terminal/CI command templates. |
Godot CLI Test Runner
Overview
Use deterministic Godot CLI workflows for Windows terminal and CI-style execution. Prefer --headless, explicit --path, and --log-file for reproducible diagnostics.
Quick Decision
- Parse-only check script syntax:
--headless --path . --script <file> --check-only. - If test logic depends on autoload singletons (for example
SceneManager,LocationManager,EventSystem), do not use direct--scriptas primary validation; use scene/project context first. - For isolated script tests without autoload dependencies, run
--headless --path . --script <file>. - Export build by using
--export-release/--export-debugwith an existing preset. - Diagnose CLI behavior by adding
--verboseand always writing--log-file.
Workflow
1. Resolve executable and project path
- Prefer
godotfrom PATH. - If not available, use explicit exe path (for this machine typically
D:\technology\biancheng\Godot\Godot_v4.5.1-stable_win64_console.exeorD:\technology\biancheng\Godot\Godot_v4.5.1-stable_win64.exe). - Run from repository root and always pass
--path .unless intentionally targeting another project.
2. Preflight checks
- Confirm engine version:
godot --version. - Confirm options when needed:
godot --help. - Confirm project exists: ensure
project.godotis present under--path. - Read
project.godot[autoload]and check whether the target test script references those singleton names. - Prepare a log output path (for example
.godot/test_xxx.log) and pass--log-file.
3. Execute task type
- Autoload-dependent validation (preferred when script references global singleton names):
godot --headless --path . --scene res://scenes/MainScene.tscn --quit-after 120 --log-file .godot/smoke_main.log - Scene-specific validation:
godot --headless --path . --scene res://scenes/Maps/square.tscn --quit-after 90 --log-file .godot/smoke_square.log - Script test (only for isolated logic or known SceneTree tests):
godot --headless --path . --script tests/unit/test_xxx.gd --log-file .godot/test_xxx.log - Script syntax only:
godot --headless --path . --script tests/unit/test_xxx.gd --check-only --log-file .godot/check_xxx.log - Export:
godot --headless --path . --export-release "Web" web_assets/index.html --log-file .godot/export_web_release.log
4. Capture and report results
- Report exit code, key stdout/stderr lines, and failed command.
- For failures, include one retry variant (for example add
--verbose, switch explicit exe path, or switch from--scriptto--scenecontext). - Keep output concise and actionable.
- If
--scriptfails with missing singleton identifiers, mark it as context mismatch first, not business regression.
Command Templates
Windows (explicit exe)
& "D:\technology\biancheng\Godot\Godot_v4.5.1-stable_win64_console.exe" --headless --path . --log-file .godot\test_websocket_close_code.log --script tests/unit/test_websocket_close_code.gd
Generic (PATH)
godot --headless --path . --log-file .godot/test_websocket_close_code.log --script tests/unit/test_websocket_close_code.gd
With extra app args
godot --headless --path . --log-file .godot/test_runner.log --script tests/unit/test_runner.gd -- --case websocket --timeout 30
Minimal Runnable Examples
Run from repository root (--path .).
- Run one scene-level smoke test (autoload-safe):
godot --headless --path . --scene res://scenes/MainScene.tscn --quit-after 120 --log-file .godot/smoke_main.log
- Run one test script (isolated logic):
godot --headless --path . --script tests/unit/test_websocket_close_code.gd --log-file .godot/test_websocket_close_code.log
- Run one scene:
godot --headless --path . --scene res://scenes/SomeScene.tscn --quit-after 90 --log-file .godot/smoke_scene.log
- Parse script only (syntax check):
godot --headless --path . --script tests/unit/test_websocket_close_code.gd --check-only --log-file .godot/check_websocket.log
If godot is not in PATH, replace godot with explicit exe call:
& "D:\technology\biancheng\Godot\Godot_v4.5.1-stable_win64.exe" <same arguments>
Option Summary Reference
Use references/godot-cli-commands.md for categorized option summary and quick recipes based on godot --help output.
Guardrails
- Prefer non-interactive commands.
- Prefer
--headlessfor tests and scripts. - For this environment, include
--log-filefor reproducible logs and to avoid console build logging issues. - Avoid assuming GUT addon exists; check
addons/gut/gut_cmdline.gdbefore using GUT command. - Use
--check-onlywhen user requests parse/syntax validation only. - For long-running runs, include
--quit-afterwhen appropriate. - Do not classify missing autoload singleton errors in
--scriptmode as product regressions until scene/project-context validation is also run.