Skip to content

Commit 0b73f1c

Browse files
committed
feat(gdscript): update GUT and exit with appropriate code
/spend 2h
1 parent 7074250 commit 0b73f1c

File tree

8 files changed

+21
-90
lines changed

8 files changed

+21
-90
lines changed

samples/client/petstore/gdscript/.gutconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"pre_run_script": null,
2424
"prefix": null,
2525
"selected": null,
26-
"should_exit": null,
26+
"should_exit": true,
2727
"should_exit_on_success": null,
2828
"should_maximize": null,
2929
"suffix": null,

samples/client/petstore/gdscript/addons/gut/gui/GutSceneTheme.tres

Lines changed: 4 additions & 4 deletions
Large diffs are not rendered by default.

samples/client/petstore/gdscript/addons/gut/gut_cmdln.gd

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,10 @@ func extract_command_line_options(from, to):
210210

211211

212212
func _print_gutconfigs(values):
213-
var header = """Here is a sample of a full super.gutconfig.json file.
213+
var header = """Here is a sample of a full .gutconfig.json file.
214214
You do not need to specify all values in your own file. The values supplied in
215215
this sample are what would be used if you ran gut w/o the -gprint_gutconfig_sample
216-
option (option priority: command-line, super.gutconfig, default)."""
216+
option (option priority: command-line, .gutconfig, default)."""
217217
print("\n", header.replace("\n", ' '), "\n\n")
218218
var resolved = values
219219

@@ -258,7 +258,7 @@ func _run_gut():
258258
elif(o.get_value('-gpo')):
259259
print('All command line options and where they are specified. ' +
260260
'The "final" value shows which value will actually be used ' +
261-
'based on order of precedence (default < super.gutconfig < cmd line).' + "\n")
261+
'based on order of precedence (default < .gutconfig < cmd line).' + "\n")
262262
print(opt_resolver.to_s_verbose())
263263
quit()
264264
elif(o.get_value('-gprint_gutconfig_sample')):
@@ -285,26 +285,22 @@ func _on_tests_finished(should_exit, should_exit_on_success):
285285
if(_final_opts.dirs.size() == 0):
286286
if(_tester.get_summary().get_totals().scripts == 0):
287287
var lgr = _tester.logger
288-
lgr.error('No directories configured. Add directories with options or a super.gutconfig.json file. Use the -gh option for more information.')
288+
lgr.error('No directories configured. Add directories with options or a .gutconfig.json file. Use the -gh option for more information.')
289289

290+
var exit_code = 0
290291
if(_tester.get_fail_count()):
291-
set_exit_code(1)
292+
exit_code = 1
292293

293294
# Overwrite the exit code with the post_script
294295
var post_inst = _tester.get_post_run_script_instance()
295296
if(post_inst != null and post_inst.get_exit_code() != null):
296-
set_exit_code(post_inst.get_exit_code())
297+
exit_code = post_inst.get_exit_code()
297298

298299
if(should_exit or (should_exit_on_success and _tester.get_fail_count() == 0)):
299-
quit()
300+
quit(exit_code)
300301
else:
301302
print("Tests finished, exit manually")
302303

303-
func set_exit_code(val):
304-
pass
305-
# OS.exit_code doesn't exist anymore, but when we find a solution it just
306-
# goes here.
307-
308304

309305
# ------------------------------------------------------------------------------
310306
# MAIN
@@ -313,7 +309,6 @@ func _init():
313309
if(!_utils.is_version_ok()):
314310
print("\n\n", _utils.get_version_text())
315311
push_error(_utils.get_bad_version_text())
316-
set_exit_code(1)
317-
quit()
312+
quit(1)
318313
else:
319314
_run_gut()

samples/client/petstore/gdscript/addons/gut/utils.gd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,4 +482,4 @@ func get_scene_script_object(scene):
482482

483483
node_idx += 1
484484

485-
return to_return
485+
return to_return

samples/client/petstore/gdscript/demo/Logger.gd

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

samples/client/petstore/gdscript/demo/main.gd

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
extends Control
22

3+
# This is the main (and only) scene of this project.
4+
# It runs GUT, whose tests are defined in `test/`.
5+
# This project is meant to be run in headless mode:
6+
# godot --debug --headless --path samples/client/petstore/gdscript --script addons/gut/gut_cmdln.gd
7+
38
signal test_ended
49

510
@onready var run_tests_button := $HBoxContainer/VBoxContainer/RunTestsButton
6-
#@onready var log_text_edit := $HBoxContainer/LogDump
7-
811

912
var gut
1013

samples/client/petstore/gdscript/demo/main.tscn

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
1-
[gd_scene load_steps=3 format=3 uid="uid://dyht2e7myo04l"]
1+
[gd_scene load_steps=2 format=3 uid="uid://dyht2e7myo04l"]
22

33
[ext_resource type="Script" path="res://demo/main.gd" id="1_sbv1b"]
44

5-
[sub_resource type="CodeHighlighter" id="CodeHighlighter_mtjt2"]
6-
number_color = Color(0, 0.843137, 0.341176, 1)
7-
symbol_color = Color(1, 1, 1, 1)
8-
function_color = Color(0.929412, 0.929412, 0.929412, 1)
9-
member_variable_color = Color(0.764706, 0.764706, 0.764706, 1)
10-
115
[node name="Main" type="Control"]
126
layout_mode = 3
137
anchors_preset = 15
@@ -39,16 +33,5 @@ layout_mode = 2
3933
size_flags_vertical = 3
4034
text = " Exit "
4135

42-
[node name="LogDump" type="TextEdit" parent="HBoxContainer"]
43-
visible = false
44-
layout_mode = 2
45-
size_flags_horizontal = 3
46-
editable = false
47-
virtual_keyboard_enabled = false
48-
middle_mouse_paste_enabled = false
49-
wrap_mode = 1
50-
syntax_highlighter = SubResource("CodeHighlighter_mtjt2")
51-
scroll_past_end_of_file = true
52-
5336
[connection signal="pressed" from="HBoxContainer/VBoxContainer/RunTestsButton" to="." method="_on_run_tests_button_pressed"]
5437
[connection signal="pressed" from="HBoxContainer/VBoxContainer/ExitButton" to="." method="_on_exit_button_pressed"]

samples/client/petstore/gdscript/project.godot

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ run/main_scene="res://demo/main.tscn"
1616
config/features=PackedStringArray("4.0", "Forward Plus")
1717
config/icon="res://icon.svg"
1818

19-
[autoload]
20-
21-
Logger="*res://demo/Logger.gd"
22-
2319
[debug]
2420

2521
file_logging/enable_file_logging=true

0 commit comments

Comments
 (0)