godot-gdscript-headless-testing
Fungsinya
Skill ini menunjukkan cara menjalankan tes GDScript Godot di terminal tanpa membuka jendela editor. Skill ini ditujukan untuk tim yang menginginkan pemeriksaan otomatis atas kode Godot mereka.
Kapan dipakai
- βSaat proyek Godot memerlukan tes unit yang berjalan tanpa membuka editor.
- βSaat Anda menyiapkan job CI yang harus gagal jika sebuah tes GDScript gagal.
- βSaat perintah Godot headless macet, membuka jendela, atau lulus padahal tes gagal.
Link skill
https://github.com/gamedev-skills/awesome-gamedev-agent-skills/blob/main/skills/godot/godot-gdscript-headless-testing/SKILL.mdSalin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.
Cara pakai
Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.
Pesan siap tempel
Untuk Claude Code, Codex, atau Cursor: jalankan di folder proyek, lalu skill langsung terpasang.
Unduh SKILL.md lalu taruh di folder skill agen Anda.
Contoh permintaan ke AI
βSiapkan tes untuk logika game Godot saya yang berjalan otomatis setiap ada perubahan, tanpa membuka editor.β
5 skill baru setiap minggu. 1 menit baca.
Cara kerjanya
Skill memandu agent untuk menjalankan Godot dalam mode headless dengan skrip runner tes yang mengembalikan kode error saat gagal, sehingga sistem otomatis dapat mendeteksi masalah.
Konten teknis (SKILL.md asli)
Teks asli dari pembuat, dalam bahasa Inggris, langsung dari GitHub.
Godot GDScript headless testing (4.x)
Run GDScript tests from the command line, without the editor GUI, and get a real process exit code CI can act on. Targets Godot 4.7 headless CLI.
When to use
- Use when a Godot project has no testing addon installed and needs a fast way to verify GDScript logic (pure functions, resource loading, autoload state) from a terminal or CI pipeline.
- Use when wiring a CI job that must fail the build when a
.gdtest fails. - Use when debugging why a
godot --headlessinvocation hangs, opens a window, or exits 0 despite failing assertions.
When not to use: GDScript syntax or language features themselves β
godot-gdscript; export/build pipeline and platform templates β godot-export
(its own --headless use case, producing a binary, not running tests).
Workflow
- Confirm the binary resolves headless. Godot 4.x ships
--headlessbuilt in (no export template needed); rungodot --headless --versionand confirm it prints a version string, not a GUI window. - On a fresh checkout, import before running tests.
.godot/is normally not committed, so a clean checkout has no import cache:class_nametypes fail to resolve (Identifier "X" not declared in the current scope) and imported assets fail to load (No loader found for resource: res://...). Rungodot --headless --path <project_dir> --importonce first, in CI and locally. - Write the runner as a
SceneTreescript, not aNodescene. ASceneTreescript's_initialize()runs once before any frame β enough for pure-logic tests and no.tscnrequired to launch. - Track pass/fail counts yourself and call
quit(<code>)explicitly. Do not use bareassert()to fail a test. Godot does not turn the process exit code non-zero onpush_error()by itself β the runner must count failures and callquit(1). Worse, a failedassert()inside_initialize()(official/debug build) printsSCRIPT ERROR: Assertion failedand stops execution beforequit()runs, so the process never exits and CI hangs until its own timeout. Use anassert_eq()-style helper that records the failure and keeps going. - Invoke with
godot --headless --path <project_dir> --script res://<runner>.gdand read the process exit code, not just stdout, from the shell or CI step.--scriptaccepts both ares://-relative path and an absolute filesystem path (e.g. a runner outside the project folder); either works. - Redirect stdout and stderr to files when scripting the invocation from a
wrapper shell (PowerShell, some CI runners).
push_error()output goes to stderr and can be dropped or reordered when only stdout is captured live. - Add a step timeout in CI. Even with the
assert()pitfall avoided, anawaitthat never resolves (Pattern #2) hangs the runner forever; atimeout-minuteson the CI step is a backstop CI-side, not a substitute for backing everyawaitwith a timeout node.
Patterns
1. Minimal SceneTree test runner with a real exit code
# res://test_runner.gd β run with:
# godot --headless --path . --script res://test_runner.gd
extends SceneTree
var passed := 0
var failed := 0
func _initialize() -> void:
test_add()
print("Results: %d passed, %d failed" % [passed, failed])
quit(1 if failed > 0 else 0) # non-zero exit fails the CI step
func assert_eq(actual, expected, label: String) -> void:
if actual == expected:
passed += 1
else:
failed += 1
push_error("FAIL %s: expected %s, got %s" % [label, expected, actual])
func test_add() -> void:
assert_eq(2 + 2, 4, "test_add")
Verified against Godot 4.7.2: godot --headless --path . --script res://test_runner.gd prints Results: N passed, M failed to stdout, routes
push_error lines to stderr, and returns process exit code 0 when
failed == 0, 1 otherwise.
2. Testing something that needs a frame, a timer, or a signal
extends SceneTree
var passed := 0
var failed := 0
func _initialize() -> void:
await run_tests()
print("Results: %d passed, %d failed" % [passed, failed])
quit(1 if failed > 0 else 0) # track and report failures here too
func assert_eq(actual, expected, label: String) -> void:
if actual == expected:
passed += 1
else:
failed += 1
push_error("FAIL %s: expected %s, got %s" % [label, expected, actual])
Pertanyaan umum
Apakah saya memerlukan editor Godot untuk menjalankan tes ini?
Tidak. Tes berjalan dari terminal dalam mode headless, sehingga tidak diperlukan jendela editor.
Mengapa checkout baru kadang gagal?
Cache impor biasanya tidak disimpan dalam version control, sehingga skill menjelaskan menjalankan langkah impor terlebih dahulu.
Apakah ini bisa dipakai di pipeline CI?
Ya. Runner keluar dengan kode error saat gagal, yang memungkinkan sistem CI menghentikan build.
Detail
Deskripsi asli dari pembuat
Run GDScript test suites from the command line with `godot --headless`, using a SceneTree/MainLoop runner script that exits non-zero on failure so CI can gate merges. Use when a Godot project needs unit tests without opening the editor, when wiring a CI job (GitHub Actions or similar) that must fail the build on a failing `.gd` test, or when a `godot --headless` invocation hangs, opens a window, or exits 0 despite failed assertions.
Popularitas
- Bintang GitHub
- 6.6k
- Peringkat
- #13822
- Lisensi
- Apache-2.0
- Diperbarui
- 28/10/2026
Komentar
- β¦
Skill lain dari repositori ini
router
6.6kMembantu agent Anda memilih skill pengembangan game yang tepat untuk setiap permintaan dengan mendeteksi engine Anda dan jenis tugas yang Anda perlukan.
ai-behavior-trees-utility-ai
6.6kMembantu agent Anda membangun behavior tree dan sistem utility AI untuk musuh dan karakter game yang memilih aksi berdasarkan prioritas dan skor.
audio-design
6.6kMengajari agent Anda cara mixing audio game: bus, volume dalam desibel, ducking di bawah dialog, musik adaptif, dan variasi efek suara.
camera-systems
6.6kMembantu agent Anda membangun kamera game yang mengikuti dengan halus, tetap berada di dalam level, dan dapat mengorbit atau melihat sekeliling dalam 3D.
Skill serupa
diffs
394kMemungkinkan agent Anda menghasilkan diff perubahan yang nyata dan dapat dibagikan sebagai tautan viewer atau file gambar, bukan ringkasan yang ditulis manual.
coding-agent
394kMembantu agent Anda menyerahkan pekerjaan pemrograman besar ke Codex, Claude Code, atau OpenCode di latar belakang, lalu memeriksa kemajuannya.
gh-issues
394kMembantu agent Anda menemukan issue GitHub, memilih yang dikerjakan, dan membuka pull request perbaikan, termasuk tindak lanjut komentar tinjauan.