Skip to content

Commit 7b08bb7

Browse files
committed
Update gut
1 parent 528a917 commit 7b08bb7

File tree

221 files changed

+10329
-4589
lines changed

Some content is hidden

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

221 files changed

+10329
-4589
lines changed

harness/tests/.gutconfig.json

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,36 @@
1-
{
2-
"dirs":["res://test/unit/"],
3-
"double_strategy":"partial",
4-
"ignore_pause":false,
5-
"include_subdirs":true,
6-
"inner_class":"",
7-
"log_level":3,
8-
"opacity":100,
9-
"prefix":"test_",
10-
"selected":"",
11-
"should_exit":true,
12-
"should_maximize":true,
13-
"suffix":".gd",
14-
"tests":[],
15-
"unit_test_name":""
1+
{
2+
"background_color": "262626ff",
3+
"compact_mode": false,
4+
"configured_dirs": [
5+
"res://test/unit"
6+
],
7+
"dirs": [
8+
"res://test/unit"
9+
],
10+
"disable_colors": false,
11+
"double_strategy": 1,
12+
"failure_error_types": [
13+
"gut"
14+
],
15+
"font_color": "ccccccff",
16+
"font_name": "CourierPrime",
17+
"font_size": 16.0,
18+
"gut_on_top": true,
19+
"hide_orphans": false,
20+
"ignore_pause": false,
21+
"include_subdirs": false,
22+
"junit_xml_file": "user://gut_report.xml",
23+
"junit_xml_timestamp": false,
24+
"log_level": 1.0,
25+
"no_error_tracking": false,
26+
"opacity": 100.0,
27+
"paint_after": 0.1,
28+
"post_run_script": "",
29+
"pre_run_script": "",
30+
"prefix": "test_",
31+
"should_exit": false,
32+
"should_exit_on_success": false,
33+
"should_maximize": false,
34+
"suffix": ".gd",
35+
"wait_log_delay": 0.5
1636
}

harness/tests/addons/gut/GutScene.gd

Lines changed: 62 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -8,120 +8,125 @@ extends Node2D
88
@onready var _compact_gui = $Compact
99

1010
var gut = null :
11-
set(val):
12-
gut = val
13-
_set_gut(val)
11+
set(val):
12+
gut = val
13+
_set_gut(val)
1414

1515

1616
func _ready():
17-
_normal_gui.switch_modes.connect(use_compact_mode.bind(true))
18-
_compact_gui.switch_modes.connect(use_compact_mode.bind(false))
17+
_normal_gui.switch_modes.connect(use_compact_mode.bind(true))
18+
_compact_gui.switch_modes.connect(use_compact_mode.bind(false))
1919

20-
_normal_gui.set_title("GUT")
21-
_compact_gui.set_title("GUT")
20+
_normal_gui.set_title("GUT")
21+
_compact_gui.set_title("GUT")
2222

23-
_normal_gui.align_right()
24-
_compact_gui.to_bottom_right()
23+
_normal_gui.align_right()
24+
_compact_gui.to_bottom_right()
2525

26-
use_compact_mode(false)
26+
use_compact_mode(false)
2727

28-
if(get_parent() == get_tree().root):
29-
_test_running_setup()
28+
if(get_parent() == get_tree().root):
29+
_test_running_setup()
3030

3131
func _test_running_setup():
32-
set_font_size(100)
33-
_normal_gui.get_textbox().text = "hello world, how are you doing?"
32+
set_font_size(100)
33+
_normal_gui.get_textbox().text = "hello world, how are you doing?"
3434

3535
# ------------------------
3636
# Private
3737
# ------------------------
3838
func _set_gut(val):
39-
if(_normal_gui.get_gut() == val):
40-
return
41-
_normal_gui.set_gut(val)
42-
_compact_gui.set_gut(val)
39+
if(_normal_gui.get_gut() == val):
40+
return
41+
_normal_gui.set_gut(val)
42+
_compact_gui.set_gut(val)
4343

44-
val.start_run.connect(_on_gut_start_run)
45-
val.end_run.connect(_on_gut_end_run)
46-
val.start_pause_before_teardown.connect(_on_gut_pause)
47-
val.end_pause_before_teardown.connect(_on_pause_end)
44+
val.start_run.connect(_on_gut_start_run)
45+
val.end_run.connect(_on_gut_end_run)
46+
val.start_pause_before_teardown.connect(_on_gut_pause)
47+
val.end_pause_before_teardown.connect(_on_pause_end)
4848

4949
func _set_both_titles(text):
50-
_normal_gui.set_title(text)
51-
_compact_gui.set_title(text)
50+
_normal_gui.set_title(text)
51+
_compact_gui.set_title(text)
5252

5353

5454
# ------------------------
5555
# Events
5656
# ------------------------
5757
func _on_gut_start_run():
58-
_set_both_titles('Running')
58+
_set_both_titles('Running')
5959

6060
func _on_gut_end_run():
61-
_set_both_titles('Finished')
61+
_set_both_titles('Finished')
6262

6363
func _on_gut_pause():
64-
_set_both_titles('-- Paused --')
64+
_set_both_titles('-- Paused --')
6565

6666
func _on_pause_end():
67-
_set_both_titles('Running')
67+
_set_both_titles('Running')
6868

6969

7070
# ------------------------
7171
# Public
7272
# ------------------------
7373
func get_textbox():
74-
return _normal_gui.get_textbox()
74+
return _normal_gui.get_textbox()
7575

7676

7777
func set_font_size(new_size):
78-
var rtl = _normal_gui.get_textbox()
78+
var rtl = _normal_gui.get_textbox()
7979

80-
rtl.set('theme_override_font_sizes/bold_italics_font_size', new_size)
81-
rtl.set('theme_override_font_sizes/bold_font_size', new_size)
82-
rtl.set('theme_override_font_sizes/italics_font_size', new_size)
83-
rtl.set('theme_override_font_sizes/normal_font_size', new_size)
80+
rtl.set('theme_override_font_sizes/bold_italics_font_size', new_size)
81+
rtl.set('theme_override_font_sizes/bold_font_size', new_size)
82+
rtl.set('theme_override_font_sizes/italics_font_size', new_size)
83+
rtl.set('theme_override_font_sizes/normal_font_size', new_size)
8484

8585

8686
func set_font(font_name):
87-
_set_all_fonts_in_rtl(_normal_gui.get_textbox(), font_name)
87+
_set_all_fonts_in_rtl(_normal_gui.get_textbox(), font_name)
8888

8989

9090
func _set_font(rtl, font_name, custom_name):
91-
if(font_name == null):
92-
rtl.remove_theme_font_override(custom_name)
93-
else:
94-
var dyn_font = FontFile.new()
95-
dyn_font.load_dynamic_font('res://addons/gut/fonts/' + font_name + '.ttf')
96-
rtl.add_theme_font_override(custom_name, dyn_font)
91+
if(font_name == null):
92+
rtl.remove_theme_font_override(custom_name)
93+
else:
94+
var font_path = 'res://addons/gut/fonts/' + font_name + '.ttf'
95+
if(FileAccess.file_exists(font_path)):
96+
var dyn_font = FontFile.new()
97+
dyn_font.load_dynamic_font('res://addons/gut/fonts/' + font_name + '.ttf')
98+
rtl.add_theme_font_override(custom_name, dyn_font)
9799

98100

99101
func _set_all_fonts_in_rtl(rtl, base_name):
100-
if(base_name == 'Default'):
101-
_set_font(rtl, null, 'normal_font')
102-
_set_font(rtl, null, 'bold_font')
103-
_set_font(rtl, null, 'italics_font')
104-
_set_font(rtl, null, 'bold_italics_font')
105-
else:
106-
_set_font(rtl, base_name + '-Regular', 'normal_font')
107-
_set_font(rtl, base_name + '-Bold', 'bold_font')
108-
_set_font(rtl, base_name + '-Italic', 'italics_font')
109-
_set_font(rtl, base_name + '-BoldItalic', 'bold_italics_font')
102+
if(base_name == 'Default'):
103+
_set_font(rtl, null, 'normal_font')
104+
_set_font(rtl, null, 'bold_font')
105+
_set_font(rtl, null, 'italics_font')
106+
_set_font(rtl, null, 'bold_italics_font')
107+
else:
108+
_set_font(rtl, base_name + '-Regular', 'normal_font')
109+
_set_font(rtl, base_name + '-Bold', 'bold_font')
110+
_set_font(rtl, base_name + '-Italic', 'italics_font')
111+
_set_font(rtl, base_name + '-BoldItalic', 'bold_italics_font')
110112

111113

112114
func set_default_font_color(color):
113-
_normal_gui.get_textbox().set('custom_colors/default_color', color)
115+
_normal_gui.get_textbox().set('custom_colors/default_color', color)
114116

115117

116118
func set_background_color(color):
117-
_normal_gui.set_bg_color(color)
119+
_normal_gui.set_bg_color(color)
118120

119121

120122
func use_compact_mode(should=true):
121-
_compact_gui.visible = should
122-
_normal_gui.visible = !should
123+
_compact_gui.visible = should
124+
_normal_gui.visible = !should
123125

124126

125127
func set_opacity(val):
126-
_normal_gui.modulate.a = val
127-
_compact_gui.modulate.a = val
128+
_normal_gui.modulate.a = val
129+
_compact_gui.modulate.a = val
130+
131+
func set_title(text):
132+
_set_both_titles(text)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
uid://cvnx8i73rnlmr
1+
uid://bw7tukh738kw1

harness/tests/addons/gut/GutScene.tscn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[gd_scene load_steps=4 format=3 uid="uid://m28heqtswbuq"]
22

3-
[ext_resource type="Script" path="res://addons/gut/GutScene.gd" id="1_b4m8y"]
3+
[ext_resource type="Script" uid="uid://bw7tukh738kw1" path="res://addons/gut/GutScene.gd" id="1_b4m8y"]
44
[ext_resource type="PackedScene" uid="uid://duxblir3vu8x7" path="res://addons/gut/gui/NormalGui.tscn" id="2_j6ywb"]
55
[ext_resource type="PackedScene" uid="uid://cnqqdfsn80ise" path="res://addons/gut/gui/MinGui.tscn" id="3_3glw1"]
66

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
uid://dtlcgeswwnm0u
1+
uid://x51wilphva3d

harness/tests/addons/gut/UserFileViewer.tscn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[gd_scene load_steps=2 format=3 uid="uid://bsm7wtt1gie4v"]
22

3-
[ext_resource type="Script" path="res://addons/gut/UserFileViewer.gd" id="1"]
3+
[ext_resource type="Script" uid="uid://x51wilphva3d" path="res://addons/gut/UserFileViewer.gd" id="1"]
44

55
[node name="UserFileViewer" type="Window"]
66
exclusive = true

harness/tests/addons/gut/autofree.gd

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# The MIT License (MIT)
66
# =====================
77
#
8-
# Copyright (c) 2020 Tom "Butch" Wesley
8+
# Copyright (c) 2025 Tom "Butch" Wesley
99
#
1010
# Permission is hereby granted, free of charge, to any person obtaining a copy
1111
# of this software and associated documentation files (the "Software"), to deal
@@ -30,30 +30,57 @@
3030
# ##############################################################################
3131
var _to_free = []
3232
var _to_queue_free = []
33+
var _ref_counted_doubles = []
34+
var _all_instance_ids = []
35+
36+
37+
func _add_instance_id(thing):
38+
if(thing.has_method("get_instance_id")):
39+
_all_instance_ids.append(thing.get_instance_id())
40+
3341

3442
func add_free(thing):
3543
if(typeof(thing) == TYPE_OBJECT):
44+
_add_instance_id(thing)
3645
if(!thing is RefCounted):
3746
_to_free.append(thing)
47+
elif(GutUtils.is_double(thing)):
48+
_ref_counted_doubles.append(thing)
49+
3850

3951
func add_queue_free(thing):
40-
_to_queue_free.append(thing)
52+
if(typeof(thing) == TYPE_OBJECT):
53+
_add_instance_id(thing)
54+
_to_queue_free.append(thing)
55+
4156

4257
func get_queue_free_count():
4358
return _to_queue_free.size()
4459

60+
4561
func get_free_count():
4662
return _to_free.size()
4763

64+
4865
func free_all():
49-
for i in range(_to_free.size()):
50-
if(is_instance_valid(_to_free[i])):
51-
_to_free[i].free()
66+
for node in _to_free:
67+
if(is_instance_valid(node)):
68+
if(GutUtils.is_double(node)):
69+
node.__gutdbl_done()
70+
node.free()
5271
_to_free.clear()
5372

5473
for i in range(_to_queue_free.size()):
5574
if(is_instance_valid(_to_queue_free[i])):
5675
_to_queue_free[i].queue_free()
5776
_to_queue_free.clear()
5877

78+
for ref_dbl in _ref_counted_doubles:
79+
ref_dbl.__gutdbl_done()
80+
_ref_counted_doubles.clear()
81+
82+
_all_instance_ids.clear()
83+
5984

85+
func has_instance_id(id):
86+
return _all_instance_ids.has(id)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
uid://eex8rpla40vc
1+
uid://bxjfriqxgwe0r

0 commit comments

Comments
 (0)