Skip to content

Commit fbfe386

Browse files
committed
Align tests to Godot 4 RC 1
1 parent 7acfa14 commit fbfe386

15 files changed

+69
-22
lines changed

tests/common.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
11
import os
22

33

4-
def write_file(tmp_dir, file_name, code):
5-
file_path = os.path.join(tmp_dir, file_name)
4+
def write_file(a_dir, file_name, code):
5+
file_path = os.path.join(a_dir, file_name)
66
with open(file_path, "w", encoding="utf-8") as handle:
77
handle.write(code)
88
return file_path
9+
10+
11+
def write_project_settings(a_dir):
12+
write_file(
13+
a_dir,
14+
"project.godot",
15+
"""[debug]
16+
gdscript/warnings/inference_on_variant=1
17+
gdscript/warnings/native_method_override=1
18+
gdscript/warnings/get_node_default_without_onready=1
19+
gdscript/warnings/onready_with_export=1
20+
""",
21+
)

tests/formatter/input-output-pairs/complex-extends-statements.in.gd

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
extends "res://tests/formatter/input-output-pairs/nested-classes.in.gd"
1+
extends "res://dummy.gd"
22

33
class C:
4-
extends "res://tests/formatter/input-output-pairs/nested-classes.in.gd".X
4+
extends "res://dummy.gd".X
55

6-
class D extends "res://tests/formatter/input-output-pairs/nested-classes.in.gd".X:
6+
class D extends "res://dummy.gd".X:
77
pass
88

9-
class E extends "res://tests/formatter/input-output-pairs/nested-classes.in.gd":
9+
class E extends "res://dummy.gd":
1010
pass
1111

1212
class F extends E:

tests/formatter/input-output-pairs/complex-extends-statements.out.gd

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
extends "res://tests/formatter/input-output-pairs/nested-classes.in.gd"
1+
extends "res://dummy.gd"
22

33

44
class C:
5-
extends "res://tests/formatter/input-output-pairs/nested-classes.in.gd".X
5+
extends "res://dummy.gd".X
66

77

88
class D:
9-
extends "res://tests/formatter/input-output-pairs/nested-classes.in.gd".X
9+
extends "res://dummy.gd".X
1010
pass
1111

1212

1313
class E:
14-
extends "res://tests/formatter/input-output-pairs/nested-classes.in.gd"
14+
extends "res://dummy.gd"
1515
pass
1616

1717

tests/formatter/input-output-pairs/multiline-annotations.in.gd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
extends Node
12
class_name Aclassname
23

34
@export_enum("AaaaaaaaaaaBbbbbbbbbCcccccccDddddddEeeeeeFfffffffffGgggggggggHhhhhhhhhhhhhhhhhhhhhhhhhh") var c

tests/formatter/input-output-pairs/multiline-annotations.out.gd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
extends Node
12
class_name Aclassname
23

34
@export_enum(

tests/formatter/input-output-pairs/simple-annotations-w-comments.in.gd

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
@tool # inline a
12
# a
3+
extends Node
24
# b
3-
@tool # inline a
45
# c
56

67
var a
@@ -19,6 +20,7 @@ var c: int = 50
1920
# i
2021

2122
class Foo:
23+
extends Node
2224
# j
2325
@onready var d # inline e
2426
# k

tests/formatter/input-output-pairs/simple-annotations-w-comments.out.gd

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
@tool # inline a
12
# a
3+
extends Node
24
# b
3-
@tool # inline a
45
# c
56

67
var a
@@ -20,6 +21,7 @@ var c: int = 50
2021

2122

2223
class Foo:
24+
extends Node
2325
# j
2426
@onready var d # inline e
2527
# k

tests/formatter/input-output-pairs/simple-annotations.in.gd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@tool
2+
extends Node
23

34
var x
45

@@ -16,5 +17,6 @@ var ranged_var_3: int = 50
1617
@onready var ranged_var_4: int = 50
1718

1819
class Foo:
20+
extends Node
1921
@onready var asd
2022
@onready var asd2

tests/formatter/input-output-pairs/simple-annotations.out.gd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@tool
2+
extends Node
23

34
var x
45

@@ -14,5 +15,6 @@ var ranged_var_2_veryyyyyyy_loooong_naaaaaaaaaaaaaaaaaaaaaaaame: int = 50
1415

1516

1617
class Foo:
18+
extends Node
1719
@onready var asd
1820
@onready var asd2

tests/formatter/test_scripts_validity.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,18 @@
44

55
import pytest
66

7+
from ..common import write_project_settings, write_file
8+
79

810
DATA_DIR = "./input-output-pairs"
911
GODOT_SERVER = "godot4"
1012
EXCEPTIONS = set(
1113
[
12-
# TODO: check (problems with latest Godot 4)
14+
# cases where Godot does more than just parsing
1315
"simple-inline-lambdas.in.gd",
1416
"simple-inline-lambdas.out.gd",
1517
"inline-lambdas-w-comments.in.gd",
1618
"inline-lambdas-w-comments.out.gd",
17-
# complex expressions where Godot does more than just parsing
1819
"long-inline-lambdas.in.gd",
1920
"long-inline-lambdas.out.gd",
2021
"type-cast-corner-case-expressions.in.gd",
@@ -39,12 +40,22 @@ def pytest_generate_tests(metafunc):
3940

4041
@pytest.mark.skipif(shutil.which(GODOT_SERVER) is None, reason="requires godot server")
4142
@pytest.mark.godot_check_only
42-
def test_script_is_valid(gdscript_path):
43+
def test_script_is_valid(gdscript_path, tmp_path):
44+
write_project_settings(tmp_path)
45+
write_file(tmp_path, "dummy.gd", "class X:\n\tpass")
4346
this_directory = os.path.dirname(os.path.abspath(__file__))
4447
directory_tests = os.path.join(this_directory, DATA_DIR)
4548
gdscript_full_path = os.path.join(directory_tests, gdscript_path)
4649
with subprocess.Popen(
47-
[GODOT_SERVER, "--headless", "--check-only", "-s", gdscript_full_path],
50+
[
51+
GODOT_SERVER,
52+
"--headless",
53+
"--check-only",
54+
"-s",
55+
gdscript_full_path,
56+
"--path",
57+
tmp_path,
58+
],
4859
) as process:
4960
process.wait()
5061
assert process.returncode == 0

0 commit comments

Comments
 (0)