Skip to content

Commit 3e28201

Browse files
authored
Merge pull request #412 from mhoff12358/mhoff12358/editor_itest_warning
Add a warning when running itest through the editor.
2 parents d6a24cd + 1be971e commit 3e28201

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)