@@ -37,6 +37,39 @@ cleanup() {
3737set -euo pipefail
3838trap cleanup EXIT
3939
40+ godotAwait () {
41+ if [[ $godotPid -ne 0 ]]; then
42+ echo " [Bash] Error: godotAwait called while Godot (PID $godotPid ) is still running."
43+ exit 1
44+ fi
45+
46+ $GODOT4_BIN -e --headless --path $rel &
47+ godotPid=$!
48+ echo " [Bash] Wait for Godot ready (PID $godotPid )..."
49+
50+ $GODOT4_BIN --headless --no-header --script ReloadOrchestrator.gd -- await
51+ }
52+
53+ godotNotify () {
54+ if [[ $godotPid -eq 0 ]]; then
55+ echo " [Bash] Error: godotNotify called but Godot is not running."
56+ exit 1
57+ fi
58+
59+ $GODOT4_BIN --headless --no-header --script ReloadOrchestrator.gd -- notify
60+
61+ echo " [Bash] Wait for Godot exit..."
62+ local status=0
63+ wait $godotPid
64+ status=$?
65+ echo " [Bash] Godot (PID $godotPid ) has completed with status $status ."
66+ godotPid=0
67+
68+ if [[ $status -ne 0 ]]; then
69+ exit $status
70+ fi
71+ }
72+
4073echo " [Bash] Start hot-reload integration test..."
4174
4275# Restore un-reloaded file (for local testing).
@@ -54,22 +87,25 @@ cargo build -p hot-reload $cargoArgs
5487# Wait briefly so artifacts are present on file system.
5588sleep 0.5
5689
57- $GODOT4_BIN -e --headless --path $rel &
58- godotPid= $!
59- echo " [Bash] Wait for Godot ready (PID $godotPid )... "
90+ # ----------------------------------------------------------------
91+ # Test Case 1: Update Rust source and compile to trigger reload.
92+ # ----------------------------------------------------------------
6093
61- $GODOT4_BIN --headless --no-header --script ReloadOrchestrator.gd -- await
62- $GODOT4_BIN --headless --no-header --script ReloadOrchestrator.gd -- replace
94+ echo " [Bash] Scenario 1: Reload after updating Rust source..."
6395
96+ godotAwait
97+ $GODOT4_BIN --headless --no-header --script ReloadOrchestrator.gd -- replace
6498# Compile updated Rust source.
6599cargo build -p hot-reload $cargoArgs
100+ godotNotify
66101
67- $GODOT4_BIN --headless --no-header --script ReloadOrchestrator.gd -- notify
68-
69- echo " [Bash] Wait for Godot exit..."
70- wait $godotPid
71- status=$?
72- echo " [Bash] Godot (PID $godotPid ) has completed with status $status ."
73-
102+ # ----------------------------------------------------------------
103+ # Test Case 2: Touch the .gdextension file to trigger reload.
104+ # ----------------------------------------------------------------
74105
106+ echo " [Bash] Scenario 2: Reload after touching rust.gdextension..."
75107
108+ godotAwait
109+ # Update timestamp to trigger reload.
110+ touch " $rel /rust.gdextension"
111+ godotNotify
0 commit comments