Skip to content

Commit 1be971e

Browse files
mhoff12358Bromeon
andcommitted
Emit warning when running itest in non-headless mode
Co-authored-by: Jan Haller <bromeon@gmail.com>
1 parent abc2a14 commit 1be971e

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

itest/godot/TestRunner.gd

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,19 @@
22
# License, v. 2.0. If a copy of the MPL was not distributed with this
33
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
44

5+
@tool # To ensure that itest is not run from the editor; see below.
6+
57
extends Node
68
class_name GDScriptTestRunner
79

810
func _ready():
11+
# Check that tests are invoked from the command line. Loading the editor may break some parts (e.g. generated test code).
12+
# Both checks are needed (it's possible to invoke `godot -e --headless`).
13+
if Engine.is_editor_hint() || DisplayServer.get_name() != 'headless':
14+
push_error("Integration tests must be run in headless mode (without editor).")
15+
get_tree().quit(2)
16+
return
17+
918
# Ensure physics is initialized, for tests that require it.
1019
await get_tree().physics_frame
1120

0 commit comments

Comments
 (0)