8
8
from ..common import GODOT_SERVER , write_project_settings , write_file
9
9
10
10
11
- OK_DATA_DIR = "../valid-gd-scripts"
11
+ OK_DATA_DIRS = [
12
+ "../valid-gd-scripts" ,
13
+ "../formatter/input-output-pairs" ,
14
+ ]
12
15
NOK_DATA_DIR = "../invalid-gd-scripts"
13
- BUGS_DATA_DIR = "../potential-godot-bugs"
14
16
15
17
16
18
def pytest_generate_tests (metafunc ):
17
19
this_directory = os .path .dirname (os .path .abspath (__file__ ))
18
20
if "gdscript_ok_path" in metafunc .fixturenames :
19
- directory_tests = os .path .join (this_directory , OK_DATA_DIR )
20
- metafunc .parametrize (
21
- "gdscript_ok_path" ,
22
- [os .path .join (directory_tests , f ) for f in os .listdir (directory_tests )],
23
- )
21
+ tests = []
22
+ for ok_data_dir in OK_DATA_DIRS :
23
+ directory_tests = os .path .join (this_directory , ok_data_dir )
24
+ tests += [
25
+ os .path .join (directory_tests , f ) for f in os .listdir (directory_tests )
26
+ ]
27
+ metafunc .parametrize ("gdscript_ok_path" , tests )
24
28
if "gdscript_nok_path" in metafunc .fixturenames :
25
29
directory_tests = os .path .join (this_directory , NOK_DATA_DIR )
26
30
metafunc .parametrize (
27
31
"gdscript_nok_path" ,
28
32
[os .path .join (directory_tests , f ) for f in os .listdir (directory_tests )],
29
33
)
30
- if "gdscript_bug_path" in metafunc .fixturenames :
31
- directory_tests = os .path .join (this_directory , BUGS_DATA_DIR )
32
- metafunc .parametrize (
33
- "gdscript_bug_path" ,
34
- [os .path .join (directory_tests , f ) for f in os .listdir (directory_tests )],
35
- )
36
34
37
35
36
+ @pytest .mark .parser
38
37
def test_parsing_success (gdscript_ok_path ):
39
38
with open (gdscript_ok_path , "r" , encoding = "utf-8" ) as handle :
40
39
code = handle .read ()
41
40
parser .parse (code ) # just checking if not throwing
42
41
43
42
44
- @pytest .mark .skipif (shutil .which (GODOT_SERVER ) is None , reason = "requires godot server" )
45
- @pytest .mark .godot_check_only
46
- def test_godot_check_only_success (gdscript_ok_path , tmp_path ):
47
- write_project_settings (tmp_path )
48
- write_file (tmp_path , "dummy.gd" , "class X:\n \t pass" )
49
- with subprocess .Popen (
50
- [
51
- GODOT_SERVER ,
52
- "--headless" ,
53
- "--check-only" ,
54
- "-s" ,
55
- gdscript_ok_path ,
56
- "--path" ,
57
- tmp_path ,
58
- ],
59
- ) as process :
60
- process .wait ()
61
- assert process .returncode == 0
62
-
63
-
43
+ @pytest .mark .parser
64
44
def test_parsing_failure (gdscript_nok_path ):
65
45
with open (gdscript_nok_path , "r" , encoding = "utf-8" ) as handle :
66
46
code = handle .read ()
@@ -69,23 +49,3 @@ def test_parsing_failure(gdscript_nok_path):
69
49
except : # pylint: disable=bare-except
70
50
return
71
51
assert True , "shall fail"
72
-
73
-
74
- @pytest .mark .skipif (shutil .which (GODOT_SERVER ) is None , reason = "requires godot server" )
75
- @pytest .mark .godot_check_only
76
- def test_godot_check_only_failure (gdscript_nok_path ):
77
- with subprocess .Popen (
78
- [GODOT_SERVER , "--headless" , "--check-only" , "-s" , gdscript_nok_path ],
79
- ) as process :
80
- process .wait ()
81
- assert process .returncode != 0
82
-
83
-
84
- @pytest .mark .skipif (shutil .which (GODOT_SERVER ) is None , reason = "requires godot server" )
85
- @pytest .mark .godot_check_only
86
- def test_godot_check_only_potential_bugs (gdscript_bug_path ):
87
- with subprocess .Popen (
88
- [GODOT_SERVER , "--headless" , "--check-only" , "-s" , gdscript_bug_path ],
89
- ) as process :
90
- process .wait ()
91
- assert process .returncode != 0
0 commit comments