Skip to content

Commit 4c33636

Browse files
committed
Basic GDUnit conversion
1 parent a222268 commit 4c33636

File tree

767 files changed

+28255
-17638
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

767 files changed

+28255
-17638
lines changed

.github/workflows/test_linux.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,5 @@ jobs:
5656
cd harness/tests/
5757
chmod +x bin/godot.*
5858
jlink --add-modules java.base,java.logging --output jvm/jre-amd64-linux
59-
./gradlew runGutTests
59+
./gradlew runGDTests
6060
timeout-minutes: 30

.github/workflows/test_linux_exports.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,5 +85,5 @@ jobs:
8585
- name: Run Tests
8686
run: |
8787
cd harness/tests/
88-
./gradlew runExportedGutTests
88+
./gradlew runExportedGDTests
8989
timeout-minutes: 30

.github/workflows/test_macos.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,5 @@ jobs:
5656
cd harness/tests/
5757
chmod +x bin/godot.*
5858
jlink --add-modules java.base,java.logging --output jvm/jre-arm64-macos
59-
./gradlew runGutTests
59+
./gradlew runGDTests
6060
timeout-minutes: 30

.github/workflows/test_macos_exports.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,5 +93,5 @@ jobs:
9393
- name: Run Tests
9494
run: |
9595
cd harness/tests/
96-
./gradlew runExportedGutTests
96+
./gradlew runExportedGDTests
9797
timeout-minutes: 30

.github/workflows/test_windows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,5 @@ jobs:
5555
run: |
5656
cd harness/tests/
5757
jlink --add-modules java.base,java.logging --output jvm/jre-amd64-windows
58-
./gradlew runGutTests
58+
./gradlew runGDTests
5959
timeout-minutes: 30

.github/workflows/test_windows_exports.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,5 +84,5 @@ jobs:
8484
- name: Run Tests
8585
run: |
8686
cd harness/tests/
87-
./gradlew runExportedGutTests
87+
./gradlew runExportedGDTests
8888
timeout-minutes: 30

harness/tests/.gut_editor_config.json

Lines changed: 0 additions & 45 deletions
This file was deleted.

harness/tests/.gut_editor_shortcuts.cfg

Lines changed: 0 additions & 17 deletions
This file was deleted.

harness/tests/.gutconfig.json

Lines changed: 0 additions & 16 deletions
This file was deleted.

harness/tests/Spatial.tscn

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ resource_test = SubResource("NavigationMesh_1ex3u")
1919
jvm_id = 319061373
2020
nav_meshes = Array[NavigationMesh]([SubResource("NavigationMesh_q3pqa")])
2121
nullable_array = Array[NavigationMesh]([SubResource("NavigationMesh_hn8kg"), null])
22-
nav_meshes_dictionary = {
22+
nav_meshes_dictionary = Dictionary[String, NavigationMesh]({
2323
"AwesomeNavmesh": SubResource("NavigationMesh_87cay")
24-
}
25-
nullable_dictionary = {
24+
})
25+
nullable_dictionary = Dictionary[String, NavigationMesh]({
2626
"notnull": SubResource("NavigationMesh_b12lh"),
2727
"null": null
28-
}
28+
})
2929

3030
[node name="Camera" type="Camera3D" parent="."]
3131
transform = Transform3D(1, 0, 0, 0, 0.974354, 0.225019, 0, -0.225019, 0.974354, 0, 1.2131, 2.47241)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"included":{"res://test":[]},"server_port":31002,"skipped":{},"version":"1.0"}
Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
The MIT License (MIT)
2-
=====================
1+
MIT License
32

4-
Copyright (c) 2018 Tom "Butch" Wesley
3+
Copyright (c) 2023 Mike Schulze
54

65
Permission is hereby granted, free of charge, to any person obtaining a copy
76
of this software and associated documentation files (the "Software"), to deal
@@ -10,13 +9,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
109
copies of the Software, and to permit persons to whom the Software is
1110
furnished to do so, subject to the following conditions:
1211

13-
The above copyright notice and this permission notice shall be included in
14-
all copies or substantial portions of the Software.
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
1514

1615
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1716
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1817
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1918
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2019
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22-
THE SOFTWARE.
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
#!/usr/bin/env -S godot -s
2+
extends SceneTree
3+
4+
enum {
5+
INIT,
6+
PROCESSING,
7+
EXIT
8+
}
9+
10+
const RETURN_SUCCESS = 0
11+
const RETURN_ERROR = 100
12+
const RETURN_WARNING = 101
13+
14+
var _console := CmdConsole.new()
15+
var _cmd_options: = CmdOptions.new([
16+
CmdOption.new(
17+
"-scp, --src_class_path",
18+
"-scp <source_path>",
19+
"The full class path of the source file.",
20+
TYPE_STRING
21+
),
22+
CmdOption.new(
23+
"-scl, --src_class_line",
24+
"-scl <line_number>",
25+
"The selected line number to generate test case.",
26+
TYPE_INT
27+
)
28+
])
29+
30+
var _status := INIT
31+
var _source_file :String = ""
32+
var _source_line :int = -1
33+
34+
35+
func _init() -> void:
36+
var cmd_parser := CmdArgumentParser.new(_cmd_options, "GdUnitBuildTool.gd")
37+
var result := cmd_parser.parse(OS.get_cmdline_args())
38+
if result.is_error():
39+
show_options()
40+
exit(RETURN_ERROR, result.error_message());
41+
return
42+
43+
var cmd_options :Array[CmdCommand] = result.value()
44+
for cmd in cmd_options:
45+
if cmd.name() == '-scp':
46+
_source_file = cmd.arguments()[0]
47+
_source_file = ProjectSettings.localize_path(ProjectSettings.localize_path(_source_file))
48+
if cmd.name() == '-scl':
49+
_source_line = int(cmd.arguments()[0])
50+
# verify required arguments
51+
if _source_file == "":
52+
exit(RETURN_ERROR, "missing required argument -scp <source>")
53+
return
54+
if _source_line == -1:
55+
exit(RETURN_ERROR, "missing required argument -scl <number>")
56+
return
57+
_status = PROCESSING
58+
59+
60+
func _idle(_delta :float) -> void:
61+
if _status == PROCESSING:
62+
var script := ResourceLoader.load(_source_file) as Script
63+
if script == null:
64+
exit(RETURN_ERROR, "Can't load source file %s!" % _source_file)
65+
var result := GdUnitTestSuiteBuilder.create(script, _source_line)
66+
if result.is_error():
67+
print_json_error(result.error_message())
68+
exit(RETURN_ERROR, result.error_message())
69+
return
70+
_console.prints_color("Added testcase: %s" % result.value(), Color.CORNFLOWER_BLUE)
71+
print_json_result(result.value() as Dictionary)
72+
exit(RETURN_SUCCESS)
73+
74+
75+
func exit(code :int, message :String = "") -> void:
76+
_status = EXIT
77+
if code == RETURN_ERROR:
78+
if not message.is_empty():
79+
_console.prints_error(message)
80+
_console.prints_error("Abnormal exit with %d" % code)
81+
else:
82+
_console.prints_color("Exit code: %d" % RETURN_SUCCESS, Color.DARK_SALMON)
83+
quit(code)
84+
85+
86+
func print_json_result(result :Dictionary) -> void:
87+
# convert back to system path
88+
var path := ProjectSettings.globalize_path(result["path"] as String)
89+
var json := 'JSON_RESULT:{"TestCases" : [{"line":%d, "path": "%s"}]}' % [result["line"], path]
90+
prints(json)
91+
92+
93+
func print_json_error(error :String) -> void:
94+
prints('JSON_RESULT:{"Error" : "%s"}' % error)
95+
96+
97+
func show_options() -> void:
98+
_console.prints_color(" Usage:", Color.DARK_SALMON)
99+
_console.prints_color(" build -scp <source_path> -scl <line_number>", Color.DARK_SALMON)
100+
_console.prints_color("-- Options ---------------------------------------------------------------------------------------",
101+
Color.DARK_SALMON).new_line()
102+
for option in _cmd_options.default_options():
103+
descripe_option(option)
104+
105+
106+
func descripe_option(cmd_option :CmdOption) -> void:
107+
_console.print_color(" %-40s" % str(cmd_option.commands()), Color.CORNFLOWER_BLUE)
108+
_console.prints_color(cmd_option.description(), Color.LIGHT_GREEN)
109+
if not cmd_option.help().is_empty():
110+
_console.prints_color("%-4s %s" % ["", cmd_option.help()], Color.DARK_TURQUOISE)
111+
_console.new_line()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
uid://dsgbf01bo6e4f

0 commit comments

Comments
 (0)