From 17637e9622c197d71240728b103ee9838d3536b7 Mon Sep 17 00:00:00 2001 From: Butch Wesley Date: Mon, 17 Jan 2022 01:36:18 -0500 Subject: [PATCH 1/8] hook settings, hide orphans, file and dir controls --- addons/gut/gui/GutBottomPanel.tscn | 2 +- addons/gut/gui/Settings.tscn | 7 ++ addons/gut/gui/gut_config_gui.gd | 121 ++++++++++++++++++++++++----- test/unit/test_doubler.gd | 2 + 4 files changed, 112 insertions(+), 20 deletions(-) create mode 100644 addons/gut/gui/Settings.tscn diff --git a/addons/gut/gui/GutBottomPanel.tscn b/addons/gut/gui/GutBottomPanel.tscn index f72ce3c6..4ec9633b 100644 --- a/addons/gut/gui/GutBottomPanel.tscn +++ b/addons/gut/gui/GutBottomPanel.tscn @@ -249,7 +249,7 @@ size_flags_vertical = 3 [node name="Settings" type="VBoxContainer" parent="layout/RSplit/sc"] margin_right = 388.0 -margin_bottom = 586.0 +margin_bottom = 688.0 size_flags_horizontal = 3 size_flags_vertical = 3 diff --git a/addons/gut/gui/Settings.tscn b/addons/gut/gui/Settings.tscn new file mode 100644 index 00000000..819a56e1 --- /dev/null +++ b/addons/gut/gui/Settings.tscn @@ -0,0 +1,7 @@ +[gd_scene format=2] + +[node name="Settings" type="VBoxContainer"] +margin_right = 388.0 +margin_bottom = 586.0 +size_flags_horizontal = 3 +size_flags_vertical = 3 diff --git a/addons/gut/gui/gut_config_gui.gd b/addons/gut/gui/gut_config_gui.gd index 545f1e3d..eb36e597 100644 --- a/addons/gut/gui/gut_config_gui.gd +++ b/addons/gut/gui/gut_config_gui.gd @@ -13,23 +13,71 @@ func _init(cont): _base_control = HBoxContainer.new() _base_control.size_flags_horizontal = _base_control.SIZE_EXPAND_FILL _base_control.mouse_filter = _base_control.MOUSE_FILTER_PASS - + var lbl = Label.new() lbl.size_flags_horizontal = lbl.SIZE_EXPAND_FILL lbl.mouse_filter = lbl.MOUSE_FILTER_STOP _base_control.add_child(lbl) + +class DirectoryCtrl: + extends HBoxContainer + + var text = '' setget set_text, get_text + var _txt_path = LineEdit.new() + var _btn_dir = Button.new() + var _dialog = FileDialog.new() + + func _init(): + _btn_dir.text = '...' + _btn_dir.connect('pressed', self, '_on_dir_button_pressed') + + _txt_path.size_flags_horizontal = _txt_path.SIZE_EXPAND_FILL + + _dialog.mode = _dialog.MODE_OPEN_DIR + _dialog.resizable = true + _dialog.connect("dir_selected", self, '_on_selected') + _dialog.connect("file_selected", self, '_on_selected') + _dialog.rect_size = Vector2(1000, 700) + + func _on_selected(path): + set_text(path) + + func _on_dir_button_pressed(): + _dialog.current_dir = _txt_path.text + _dialog.popup_centered() + + + func _ready(): + add_child(_txt_path) + add_child(_btn_dir) + add_child(_dialog) + + func get_text(): + return text + + func set_text(t): + text = t + _txt_path.text = text + + +class FileCtrl: + extends DirectoryCtrl + + func _init(): + _dialog.mode = _dialog.MODE_OPEN_FILE + # ------------------ # Private # ------------------ func _new_row(key, disp_text, value_ctrl, hint): var ctrl = _base_control.duplicate() var lbl = ctrl.get_node("Label") - + lbl.hint_tooltip = hint lbl.text = disp_text _base_container.add_child(ctrl) - + _cfg_ctrls[key] = value_ctrl ctrl.add_child(value_ctrl) @@ -39,11 +87,11 @@ func _new_row(key, disp_text, value_ctrl, hint): func _add_title(text): var row = _base_control.duplicate() var lbl = row.get_node('Label') - + lbl.text = text lbl.align = Label.ALIGN_CENTER _base_container.add_child(row) - + row.connect('draw', self, '_on_title_cell_draw', [row]) @@ -52,7 +100,7 @@ func _add_number(key, value, disp_text, v_min, v_max, hint=''): value_ctrl.value = value value_ctrl.min_value = v_min value_ctrl.max_value = v_max - + var ctrl = _new_row(key, disp_text, value_ctrl, hint) @@ -64,7 +112,7 @@ func _add_select(key, value, values, disp_text, hint=''): if(value == values[i]): select_idx = i value_ctrl.selected = select_idx - + var ctrl = _new_row(key, disp_text, value_ctrl, hint) @@ -72,14 +120,29 @@ func _add_value(key, value, disp_text, hint=''): var value_ctrl = LineEdit.new() value_ctrl.size_flags_horizontal = value_ctrl.SIZE_EXPAND_FILL value_ctrl.text = value - + var ctrl = _new_row(key, disp_text, value_ctrl, hint) func _add_boolean(key, value, disp_text, hint=''): var value_ctrl = CheckBox.new() value_ctrl.pressed = value - + + var ctrl = _new_row(key, disp_text, value_ctrl, hint) + +func _add_directory(key, value, disp_text, hint=''): + var value_ctrl = DirectoryCtrl.new() + value_ctrl.size_flags_horizontal = value_ctrl.SIZE_EXPAND_FILL + value_ctrl.text = value + + var ctrl = _new_row(key, disp_text, value_ctrl, hint) + + +func _add_file(key, value, disp_text, hint=''): + var value_ctrl = FileCtrl.new() + value_ctrl.size_flags_horizontal = value_ctrl.SIZE_EXPAND_FILL + value_ctrl.text = value + var ctrl = _new_row(key, disp_text, value_ctrl, hint) @@ -88,11 +151,12 @@ func _add_boolean(key, value, disp_text, hint=''): # ------------------ func _on_ctrl_value_changed(which): pass - - + + func _on_title_cell_draw(which): which.draw_rect(Rect2(Vector2(0, 0), which.rect_size), Color(0, 0, 0, .15)) + # ------------------ # Public # ------------------ @@ -100,7 +164,7 @@ func get_config_issues(): var to_return = [] var has_directory = false var dir = Directory.new() - + for i in range(DIRS_TO_LIST): var key = str('directory_', i) var path = _cfg_ctrls[key].text @@ -108,13 +172,13 @@ func get_config_issues(): has_directory = true if(!dir.dir_exists(path)): to_return.append(str('Test directory ', path, ' does not exist.')) - + if(!has_directory): to_return.append('You do not have any directories set.') - + if(_cfg_ctrls['prefix'].text == ''): to_return.append("You must set a Script prefix or GUT won't find any scripts") - + return to_return @@ -122,8 +186,9 @@ func set_options(options): _add_title("Settings") _add_number("log_level", options.log_level, "Log Level", 0, 3, "Detail level for log messages.") - _add_boolean('ignore_pause', options.ignore_pause, 'Ignore Pause', + _add_boolean('ignore_pause', options.ignore_pause, 'Ignore Pause', "Ignore calls to pause_before_teardown") + _add_boolean('hide_orphans', options.hide_orphans, 'Do not show Orphans', 'Hide orpahn output.') _add_boolean('should_exit', options.should_exit, 'Exit on Finish', "Exit when tests finished.") _add_boolean('should_exit_on_success', options.should_exit_on_success, 'Exit on Success', @@ -133,27 +198,36 @@ func set_options(options): _add_number('opacity', options.opacity, 'Opacity', 0, 100, "The opacity of GUT when tests are running.") + _add_title("XML Output") _add_value("junit_xml_file", options.junit_xml_file, "Output Path", "Path and filename where GUT should create the JUnit XML file.") _add_boolean("junit_xml_timestamp", options.junit_xml_timestamp, "Include timestamp", "Include a timestamp in the filename so that each run gets its own xml file.") + _add_title('Font') _add_select('font_name', options.font_name, _avail_fonts, 'Font', "The name of the font to use when running tests and in the output panel to the left.") _add_number('font_size', options.font_size, 'Font Size', 5, 100, "The font size to use when running tests and in the output panel to the left.") + _add_title('Directories') - _add_boolean('include_subdirs', options.include_subdirs, 'Include Subdirs', + _add_boolean('include_subdirs', options.include_subdirs, 'Include Subdirs', "Include subdirectories of the directories configured below.") for i in range(DIRS_TO_LIST): var value = '' if(options.dirs.size() > i): value = options.dirs[i] - _add_value(str('directory_', i), value, str('Directory ', i)) + _add_directory(str('directory_', i), value, str('Directory ', i)) + + + _add_title('Hooks') + _add_file('pre_run_script', options.pre_run_script, 'pre-run hook', 'This script will be run by GUT before any tests are run.') + _add_file('post_run_script', options.post_run_script, 'post-run hook', 'This script will be run by GUT after all tests are run.') + _add_title('Misc') _add_value('prefix', options.prefix, 'Script Prefix', @@ -164,20 +238,25 @@ func set_options(options): func get_options(base_opts): var to_return = base_opts.duplicate() + # Settings to_return.log_level = _cfg_ctrls.log_level.value to_return.ignore_pause = _cfg_ctrls.ignore_pause.pressed + to_return.hide_orphans = _cfg_ctrls.hide_orphans.pressed to_return.should_exit = _cfg_ctrls.should_exit.pressed to_return.should_exit_on_success = _cfg_ctrls.should_exit_on_success.pressed to_return.should_maximize = _cfg_ctrls.should_maximize.pressed to_return.opacity = _cfg_ctrls.opacity.value + # XML Output to_return.junit_xml_file = _cfg_ctrls.junit_xml_file.text to_return.junit_xml_timestamp = _cfg_ctrls.junit_xml_timestamp.pressed + # Font to_return.font_name = _cfg_ctrls.font_name.get_item_text( _cfg_ctrls.font_name.selected) to_return.font_size = _cfg_ctrls.font_size.value + # Directories to_return.include_subdirs = _cfg_ctrls.include_subdirs.pressed var dirs = [] for i in range(DIRS_TO_LIST): @@ -187,7 +266,11 @@ func get_options(base_opts): dirs.append(val) to_return.dirs = dirs - to_return.prefix = _cfg_ctrls.prefix.text + # Hooks + to_return.pre_run_script = _cfg_ctrls.pre_run_script.text + to_return.post_run_script = _cfg_ctrls.post_run_script.text + # Misc + to_return.prefix = _cfg_ctrls.prefix.text return to_return diff --git a/test/unit/test_doubler.gd b/test/unit/test_doubler.gd index dd899908..686ac271 100644 --- a/test/unit/test_doubler.gd +++ b/test/unit/test_doubler.gd @@ -443,11 +443,13 @@ class TestPartialDoubles: assert_eq(inst.return_hello(), null) pause_before_teardown() + func test_init_is_not_stubbed_to_call_super(): var inst = doubler.partial_double(DOUBLE_ME_PATH).new() var text = get_instance_source(inst) assert_false(text.match("*__gut_should_call_super('_init'*"), 'should not call super _init') + func test_can_partial_and_normal_double_in_same_test(): var double = doubler.double(DOUBLE_ME_PATH).new() var p_double = doubler.partial_double(DOUBLE_ME_PATH).new() From 24ee7db15af05a058abfaad838c6d52ade9fc84f Mon Sep 17 00:00:00 2001 From: Butch Wesley Date: Mon, 17 Jan 2022 14:08:39 -0500 Subject: [PATCH 2/8] output panel font and font name. Some tweaks --- .gut_editor_config.json | 12 ++-- addons/gut/gui/GutBottomPanel.gd | 10 ++-- addons/gut/gui/GutBottomPanel.tscn | 60 ++++++++++++++------ addons/gut/gui/gut_config_gui.gd | 89 ++++++++++++++++++------------ addons/gut/gut_config.gd | 8 +++ 5 files changed, 118 insertions(+), 61 deletions(-) diff --git a/.gut_editor_config.json b/.gut_editor_config.json index 2e80faab..1b222798 100644 --- a/.gut_editor_config.json +++ b/.gut_editor_config.json @@ -9,14 +9,14 @@ "double_strategy": "partial", "font_color": "ffcccccc", "font_name": "CourierPrime", - "font_size": 30, + "font_size": 15, "hide_orphans": false, "ignore_pause": true, "include_subdirs": false, - "inner_class": null, + "inner_class": "TestAddingCallsWithParameters", "junit_xml_file": "", "junit_xml_timestamp": false, - "log_level": 1, + "log_level": 0, "opacity": 100, "post_run_script": "", "pre_run_script": "", @@ -30,5 +30,9 @@ "tests": [ ], - "unit_test_name": null + "unit_test_name": null, + "panel_options": { + "font_name": "CourierPrime", + "font_size": 30 + } } \ No newline at end of file diff --git a/addons/gut/gui/GutBottomPanel.gd b/addons/gut/gui/GutBottomPanel.gd index 28ee8f32..966b8ef8 100644 --- a/addons/gut/gui/GutBottomPanel.gd +++ b/addons/gut/gui/GutBottomPanel.gd @@ -35,14 +35,14 @@ onready var _ctrls = { func _init(): - _gut_config.load_options(RUNNER_JSON_PATH) + _gut_config.load_panel_options(RUNNER_JSON_PATH) func _ready(): _gut_config_gui = GutConfigGui.new(_ctrls.settings) _gut_config_gui.set_options(_gut_config.options) - _set_all_fonts_in_ftl(_ctrls.output, _gut_config.options.font_name) - _set_font_size_for_rtl(_ctrls.output, _gut_config.options.font_size) + _set_all_fonts_in_ftl(_ctrls.output, _gut_config.options.panel_options.font_name) + _set_font_size_for_rtl(_ctrls.output, _gut_config.options.panel_options.font_size) func _process(delta): @@ -136,8 +136,8 @@ func _run_tests(): write_file(RESULT_FILE, 'Run in progress') _gut_config.options = _gut_config_gui.get_options(_gut_config.options) - _set_all_fonts_in_ftl(_ctrls.output, _gut_config.options.font_name) - _set_font_size_for_rtl(_ctrls.output, _gut_config.options.font_size) + _set_all_fonts_in_ftl(_ctrls.output, _gut_config.options.panel_options.font_name) + _set_font_size_for_rtl(_ctrls.output, _gut_config.options.panel_options.font_size) var w_result = _gut_config.write_options(RUNNER_JSON_PATH) if(w_result != OK): diff --git a/addons/gut/gui/GutBottomPanel.tscn b/addons/gut/gui/GutBottomPanel.tscn index 4ec9633b..df31633a 100644 --- a/addons/gut/gui/GutBottomPanel.tscn +++ b/addons/gut/gui/GutBottomPanel.tscn @@ -15,28 +15,28 @@ shortcut = SubResource( 8 ) [sub_resource type="StyleBoxEmpty" id=5] [sub_resource type="DynamicFontData" id=10] -font_path = "res://addons/gut/fonts/CourierPrime-BoldItalic.ttf" +font_path = "res://addons/gut/fonts/LobsterTwo-BoldItalic.ttf" [sub_resource type="DynamicFont" id=11] size = 30 font_data = SubResource( 10 ) [sub_resource type="DynamicFontData" id=12] -font_path = "res://addons/gut/fonts/CourierPrime-Italic.ttf" +font_path = "res://addons/gut/fonts/LobsterTwo-Italic.ttf" [sub_resource type="DynamicFont" id=13] size = 30 font_data = SubResource( 12 ) [sub_resource type="DynamicFontData" id=14] -font_path = "res://addons/gut/fonts/CourierPrime-Bold.ttf" +font_path = "res://addons/gut/fonts/LobsterTwo-Bold.ttf" [sub_resource type="DynamicFont" id=15] size = 30 font_data = SubResource( 14 ) [sub_resource type="DynamicFontData" id=16] -font_path = "res://addons/gut/fonts/CourierPrime-Regular.ttf" +font_path = "res://addons/gut/fonts/LobsterTwo-Regular.ttf" [sub_resource type="DynamicFont" id=17] size = 30 @@ -164,50 +164,74 @@ margin_right = 30.0 margin_bottom = 35.0 rect_min_size = Vector2( 30, 30 ) -[node name="lblPassing" type="Label" parent="layout/RSplit/CResults/ControlBar"] +[node name="Sep1" type="ColorRect" parent="layout/RSplit/CResults/ControlBar"] margin_left = 34.0 +margin_right = 36.0 +margin_bottom = 35.0 +rect_min_size = Vector2( 2, 0 ) + +[node name="lblPassing" type="Label" parent="layout/RSplit/CResults/ControlBar"] +margin_left = 40.0 margin_top = 10.0 -margin_right = 82.0 +margin_right = 88.0 margin_bottom = 24.0 text = "Passing" [node name="lblPassingValue" type="Label" parent="layout/RSplit/CResults/ControlBar"] -margin_left = 86.0 +margin_left = 92.0 margin_top = 10.0 -margin_right = 101.0 +margin_right = 107.0 margin_bottom = 24.0 text = "---" +[node name="Sep2" type="ColorRect" parent="layout/RSplit/CResults/ControlBar"] +margin_left = 111.0 +margin_right = 113.0 +margin_bottom = 35.0 +rect_min_size = Vector2( 2, 0 ) + [node name="lblFailing" type="Label" parent="layout/RSplit/CResults/ControlBar"] -margin_left = 105.0 +margin_left = 117.0 margin_top = 10.0 -margin_right = 146.0 +margin_right = 158.0 margin_bottom = 24.0 text = "Failing" [node name="lblFailingValue" type="Label" parent="layout/RSplit/CResults/ControlBar"] -margin_left = 150.0 +margin_left = 162.0 margin_top = 10.0 -margin_right = 165.0 +margin_right = 177.0 margin_bottom = 24.0 text = "---" +[node name="Sep3" type="ColorRect" parent="layout/RSplit/CResults/ControlBar"] +margin_left = 181.0 +margin_right = 183.0 +margin_bottom = 35.0 +rect_min_size = Vector2( 2, 0 ) + [node name="lblPending" type="Label" parent="layout/RSplit/CResults/ControlBar"] -margin_left = 169.0 +margin_left = 187.0 margin_top = 10.0 -margin_right = 220.0 +margin_right = 238.0 margin_bottom = 24.0 text = "Pending" [node name="lblPendingValue" type="Label" parent="layout/RSplit/CResults/ControlBar"] -margin_left = 224.0 +margin_left = 242.0 margin_top = 10.0 -margin_right = 239.0 +margin_right = 257.0 margin_bottom = 24.0 text = "---" +[node name="Sep4" type="ColorRect" parent="layout/RSplit/CResults/ControlBar"] +margin_left = 261.0 +margin_right = 263.0 +margin_bottom = 35.0 +rect_min_size = Vector2( 2, 0 ) + [node name="CenterContainer" type="CenterContainer" parent="layout/RSplit/CResults/ControlBar"] -margin_left = 243.0 +margin_left = 267.0 margin_right = 488.0 margin_bottom = 35.0 size_flags_horizontal = 3 @@ -249,7 +273,7 @@ size_flags_vertical = 3 [node name="Settings" type="VBoxContainer" parent="layout/RSplit/sc"] margin_right = 388.0 -margin_bottom = 688.0 +margin_bottom = 758.0 size_flags_horizontal = 3 size_flags_vertical = 3 diff --git a/addons/gut/gui/gut_config_gui.gd b/addons/gut/gui/gut_config_gui.gd index eb36e597..7bb6f36a 100644 --- a/addons/gut/gui/gut_config_gui.gd +++ b/addons/gut/gui/gut_config_gui.gd @@ -1,25 +1,5 @@ -var _base_container = null -var _base_control = null -const DIRS_TO_LIST = 6 -var _cfg_ctrls = {} -var _avail_fonts = ['AnonymousPro', 'CourierPrime', 'LobsterTwo', 'Default'] - - -signal settings_changed - -func _init(cont): - _base_container = cont - - _base_control = HBoxContainer.new() - _base_control.size_flags_horizontal = _base_control.SIZE_EXPAND_FILL - _base_control.mouse_filter = _base_control.MOUSE_FILTER_PASS - - var lbl = Label.new() - lbl.size_flags_horizontal = lbl.SIZE_EXPAND_FILL - lbl.mouse_filter = lbl.MOUSE_FILTER_STOP - _base_control.add_child(lbl) - - +# ------------------------------------------------------------------------------ +# ------------------------------------------------------------------------------ class DirectoryCtrl: extends HBoxContainer @@ -60,13 +40,42 @@ class DirectoryCtrl: text = t _txt_path.text = text - +# ------------------------------------------------------------------------------ +# ------------------------------------------------------------------------------ class FileCtrl: extends DirectoryCtrl func _init(): _dialog.mode = _dialog.MODE_OPEN_FILE + +# ------------------------------------------------------------------------------ +# ------------------------------------------------------------------------------ +var _base_container = null +var _base_control = null +const DIRS_TO_LIST = 6 +var _cfg_ctrls = {} +var _avail_fonts = ['AnonymousPro', 'CourierPrime', 'LobsterTwo', 'Default'] + + +signal settings_changed + +func _init(cont): + _base_container = cont + + _base_control = HBoxContainer.new() + _base_control.size_flags_horizontal = _base_control.SIZE_EXPAND_FILL + _base_control.mouse_filter = _base_control.MOUSE_FILTER_PASS + + # I don't remember what this is all about at all. Could be + # garbage. Decided to spend more time typing this message + # than figuring it out. + var lbl = Label.new() + lbl.size_flags_horizontal = lbl.SIZE_EXPAND_FILL + lbl.mouse_filter = lbl.MOUSE_FILTER_STOP + _base_control.add_child(lbl) + + # ------------------ # Private # ------------------ @@ -188,15 +197,12 @@ func set_options(options): "Detail level for log messages.") _add_boolean('ignore_pause', options.ignore_pause, 'Ignore Pause', "Ignore calls to pause_before_teardown") - _add_boolean('hide_orphans', options.hide_orphans, 'Do not show Orphans', 'Hide orpahn output.') + _add_boolean('hide_orphans', options.hide_orphans, 'Hide Orphans', + 'Do not display orphan counts in output.') _add_boolean('should_exit', options.should_exit, 'Exit on Finish', "Exit when tests finished.") _add_boolean('should_exit_on_success', options.should_exit_on_success, 'Exit on Success', - "Exit if there are no failures. Does nothing if 'Exit on Finish' is set.") - _add_boolean('should_maximize', options.should_maximize, 'Maximize', - "Maximize GUT when tests are being run.") - _add_number('opacity', options.opacity, 'Opacity', 0, 100, - "The opacity of GUT when tests are running.") + "Exit if there are no failures. Does nothing if 'Exit on Finish' is enabled.") _add_title("XML Output") @@ -205,12 +211,22 @@ func set_options(options): _add_boolean("junit_xml_timestamp", options.junit_xml_timestamp, "Include timestamp", "Include a timestamp in the filename so that each run gets its own xml file.") + _add_title("Output") + _add_select('output_font_name', options.panel_options.font_name, _avail_fonts, 'Font', + "The name of the font to use when running tests and in the output panel to the left.") + _add_number('output_font_size', options.panel_options.font_size, 'Font Size', 5, 100, + "The font size to use when running tests and in the output panel to the left.") + - _add_title('Font') + _add_title('Runner Appearance') _add_select('font_name', options.font_name, _avail_fonts, 'Font', "The name of the font to use when running tests and in the output panel to the left.") _add_number('font_size', options.font_size, 'Font Size', 5, 100, "The font size to use when running tests and in the output panel to the left.") + _add_boolean('should_maximize', options.should_maximize, 'Maximize', + "Maximize GUT when tests are being run.") + _add_number('opacity', options.opacity, 'Opacity', 0, 100, + "The opacity of GUT when tests are running.") _add_title('Directories') @@ -234,7 +250,6 @@ func set_options(options): "The filename prefix for all test scripts.") - func get_options(base_opts): var to_return = base_opts.duplicate() @@ -244,17 +259,23 @@ func get_options(base_opts): to_return.hide_orphans = _cfg_ctrls.hide_orphans.pressed to_return.should_exit = _cfg_ctrls.should_exit.pressed to_return.should_exit_on_success = _cfg_ctrls.should_exit_on_success.pressed - to_return.should_maximize = _cfg_ctrls.should_maximize.pressed - to_return.opacity = _cfg_ctrls.opacity.value # XML Output to_return.junit_xml_file = _cfg_ctrls.junit_xml_file.text to_return.junit_xml_timestamp = _cfg_ctrls.junit_xml_timestamp.pressed - # Font + #Output + to_return.panel_options.font_name = _cfg_ctrls.output_font_name.get_item_text( + _cfg_ctrls.output_font_name.selected) + to_return.panel_options.font_size = _cfg_ctrls.output_font_size.value + + # Runner Appearance to_return.font_name = _cfg_ctrls.font_name.get_item_text( _cfg_ctrls.font_name.selected) to_return.font_size = _cfg_ctrls.font_size.value + to_return.should_maximize = _cfg_ctrls.should_maximize.pressed + to_return.opacity = _cfg_ctrls.opacity.value + # Directories to_return.include_subdirs = _cfg_ctrls.include_subdirs.pressed diff --git a/addons/gut/gut_config.gd b/addons/gut/gut_config.gd index 1aa784d3..1988ac06 100644 --- a/addons/gut/gut_config.gd +++ b/addons/gut/gut_config.gd @@ -40,6 +40,11 @@ var default_options = { unit_test_name = '', } +var default_panel_options = { + font_name = 'CourierPrime', + font_size = 30 +} + var options = default_options.duplicate() @@ -155,6 +160,9 @@ func config_gut(gut): func load_options(path): return _load_options_from_config_file(path, options) +func load_panel_options(path): + options['panel_options'] = default_panel_options.duplicate() + return _load_options_from_config_file(path, options) func load_options_no_defaults(path): options = _null_copy(default_options) From adb1ddc035f83fa4f4f12e2c6ad4dda096ff529b Mon Sep 17 00:00:00 2001 From: Butch Wesley Date: Mon, 17 Jan 2022 14:29:33 -0500 Subject: [PATCH 3/8] background color and font color --- .gut_editor_config.json | 8 ++++---- addons/gut/gui/gut_config_gui.gd | 10 ++++++++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/.gut_editor_config.json b/.gut_editor_config.json index 1b222798..57942e2b 100644 --- a/.gut_editor_config.json +++ b/.gut_editor_config.json @@ -1,5 +1,5 @@ { - "background_color": "ff262626", + "background_color": "ff343434", "config_file": "res://.gutconfig.json", "dirs": [ "res://test/unit", @@ -7,13 +7,13 @@ ], "disable_colors": false, "double_strategy": "partial", - "font_color": "ffcccccc", + "font_color": "ffc1bfce", "font_name": "CourierPrime", "font_size": 15, "hide_orphans": false, "ignore_pause": true, "include_subdirs": false, - "inner_class": "TestAddingCallsWithParameters", + "inner_class": "TestGetCallCount", "junit_xml_file": "", "junit_xml_timestamp": false, "log_level": 0, @@ -22,7 +22,7 @@ "pre_run_script": "", "prefix": "test_", "selected": "test_spy.gd", - "should_exit": true, + "should_exit": false, "should_exit_on_success": false, "should_maximize": false, "show_help": false, diff --git a/addons/gut/gui/gut_config_gui.gd b/addons/gut/gui/gut_config_gui.gd index 7bb6f36a..22c17ed4 100644 --- a/addons/gut/gui/gut_config_gui.gd +++ b/addons/gut/gui/gut_config_gui.gd @@ -155,6 +155,12 @@ func _add_file(key, value, disp_text, hint=''): var ctrl = _new_row(key, disp_text, value_ctrl, hint) +func _add_color(key, value, disp_text, hint=''): + var value_ctrl = ColorPickerButton.new() + value_ctrl.size_flags_horizontal = value_ctrl.SIZE_EXPAND_FILL + value_ctrl.color = value + + var ctrl = _new_row(key, disp_text, value_ctrl, hint) # ------------------ # Events # ------------------ @@ -227,6 +233,8 @@ func set_options(options): "Maximize GUT when tests are being run.") _add_number('opacity', options.opacity, 'Opacity', 0, 100, "The opacity of GUT when tests are running.") + _add_color('background_color', options.background_color, 'Background Color') + _add_color('font_color', options.font_color, 'Font Color') _add_title('Directories') @@ -275,6 +283,8 @@ func get_options(base_opts): to_return.font_size = _cfg_ctrls.font_size.value to_return.should_maximize = _cfg_ctrls.should_maximize.pressed to_return.opacity = _cfg_ctrls.opacity.value + to_return.background_color = _cfg_ctrls.background_color.color.to_html() + to_return.font_color = _cfg_ctrls.font_color.color.to_html() # Directories From 5b39627bc8a940c6e7da5af77b1d7f418522e004 Mon Sep 17 00:00:00 2001 From: Butch Wesley Date: Mon, 17 Jan 2022 15:03:24 -0500 Subject: [PATCH 4/8] CHANGES.md, fix issue with directory/file ctrl. add GutHookScript class name. Add error to default `run` method of hook script --- .gut_editor_config.json | 6 +++--- CHANGES.md | 5 ++++- addons/gut/gui/gut_config_gui.gd | 6 +++--- addons/gut/gut.gd | 2 +- addons/gut/hook_script.gd | 4 +++- project.godot | 6 ++++++ 6 files changed, 20 insertions(+), 9 deletions(-) diff --git a/.gut_editor_config.json b/.gut_editor_config.json index 57942e2b..16b941f4 100644 --- a/.gut_editor_config.json +++ b/.gut_editor_config.json @@ -13,12 +13,12 @@ "hide_orphans": false, "ignore_pause": true, "include_subdirs": false, - "inner_class": "TestGetCallCount", + "inner_class": "TestSpy", "junit_xml_file": "", "junit_xml_timestamp": false, "log_level": 0, "opacity": 100, - "post_run_script": "", + "post_run_script": "res://scripts/global.gd", "pre_run_script": "", "prefix": "test_", "selected": "test_spy.gd", @@ -30,7 +30,7 @@ "tests": [ ], - "unit_test_name": null, + "unit_test_name": "test_can_add_call_to_method_on_instance", "panel_options": { "font_name": "CourierPrime", "font_size": 30 diff --git a/CHANGES.md b/CHANGES.md index 38efdefb..99e328dc 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -31,7 +31,10 @@ func test_foo(): ``` * In-Editor GUT Panel improvements * Smart buttons to run tests based on cursor location. -* __Issue 215__ You can now use `extends GutTest` instead of `extends 'res://addons/gut/test.gd'` when creating test scripts. That's 45% less text! + * Added more settings (hook scripts, font color, background color, panel font settings, directory and file dialog buttons where appropriate, hide orphans) +* Added some `class_name` clauses to files: + * __Issue 215__ You can now use `extends GutTest` instead of `extends 'res://addons/gut/test.gd'` when creating test scripts. That's 45% less text! + * When making a hook script, you can use `extends GutHookScript` instead of using the path. * __Issue 310__ The summary output now lists the number of passing/failing tests as well as passing/failing assert counts. ## Bug Fixes diff --git a/addons/gut/gui/gut_config_gui.gd b/addons/gut/gui/gut_config_gui.gd index 22c17ed4..27685a72 100644 --- a/addons/gut/gui/gut_config_gui.gd +++ b/addons/gut/gui/gut_config_gui.gd @@ -34,7 +34,7 @@ class DirectoryCtrl: add_child(_dialog) func get_text(): - return text + return _txt_path.text func set_text(t): text = t @@ -249,8 +249,8 @@ func set_options(options): _add_title('Hooks') - _add_file('pre_run_script', options.pre_run_script, 'pre-run hook', 'This script will be run by GUT before any tests are run.') - _add_file('post_run_script', options.post_run_script, 'post-run hook', 'This script will be run by GUT after all tests are run.') + _add_file('pre_run_script', options.pre_run_script, 'Pre-Run Hook', 'This script will be run by GUT before any tests are run.') + _add_file('post_run_script', options.post_run_script, 'Post-Run Hook', 'This script will be run by GUT after all tests are run.') _add_title('Misc') diff --git a/addons/gut/gut.gd b/addons/gut/gut.gd index 021893a8..c2410f46 100644 --- a/addons/gut/gut.gd +++ b/addons/gut/gut.gd @@ -426,7 +426,7 @@ func _validate_hook_script(path): result.valid = true else: result.valid = false - _lgr.error('The hook script [' + path + '] does not extend res://addons/gut/hook_script.gd') + _lgr.error('The hook script [' + path + '] does not extend GutHookScript') else: result.valid = false _lgr.error('The hook script [' + path + '] does not exist.') diff --git a/addons/gut/hook_script.gd b/addons/gut/hook_script.gd index 049a6558..2efc3b1e 100644 --- a/addons/gut/hook_script.gd +++ b/addons/gut/hook_script.gd @@ -1,3 +1,4 @@ +class_name GutHookScript # ------------------------------------------------------------------------------ # This script is the base for custom scripts to be used in pre and post # run hooks. @@ -19,7 +20,8 @@ var _should_abort = false # Virtual method that will be called by GUT after instantiating # this script. func run(): - pass + gut.get_logger().error("Run method not overloaded. Create a 'run()' method in your hook script to run your code.") + # Set the exit code when running from the command line. If not set then the # default exit code will be returned (0 when no tests fail, 1 when any tests diff --git a/project.godot b/project.godot index f104fbbd..f0589bf3 100644 --- a/project.godot +++ b/project.godot @@ -9,12 +9,18 @@ config_version=4 _global_script_classes=[ { +"base": "Reference", +"class": "GutHookScript", +"language": "GDScript", +"path": "res://addons/gut/hook_script.gd" +}, { "base": "Node", "class": "GutTest", "language": "GDScript", "path": "res://addons/gut/test.gd" } ] _global_script_class_icons={ +"GutHookScript": "", "GutTest": "" } From 206f8eed61e99ffa2fd156c2c81aa0854944c66c Mon Sep 17 00:00:00 2001 From: Butch Wesley Date: Mon, 17 Jan 2022 16:35:20 -0500 Subject: [PATCH 5/8] conditionally show warnings, errors, orphans --- .gut_editor_config.json | 13 +- CHANGES.md | 1 + addons/gut/gui/GutBottomPanel.gd | 23 ++- addons/gut/gui/GutBottomPanel.tscn | 158 ++++++++++++++---- addons/gut/result_exporter.gd | 23 +-- .../panel_demo_scripts/test_totals_testing.gd | 28 ++++ .../test_has_error_and_warning.gd | 9 + test/unit/test_result_exporter.gd | 11 ++ 8 files changed, 212 insertions(+), 54 deletions(-) create mode 100644 test/panel_demo_scripts/test_totals_testing.gd create mode 100644 test/resources/exporter_test_files/test_has_error_and_warning.gd diff --git a/.gut_editor_config.json b/.gut_editor_config.json index 16b941f4..1559b88b 100644 --- a/.gut_editor_config.json +++ b/.gut_editor_config.json @@ -3,7 +3,8 @@ "config_file": "res://.gutconfig.json", "dirs": [ "res://test/unit", - "res://test/integration" + "res://test/integration", + "res://test/panel_demo_scripts" ], "disable_colors": false, "double_strategy": "partial", @@ -13,16 +14,16 @@ "hide_orphans": false, "ignore_pause": true, "include_subdirs": false, - "inner_class": "TestSpy", + "inner_class": null, "junit_xml_file": "", "junit_xml_timestamp": false, "log_level": 0, "opacity": 100, - "post_run_script": "res://scripts/global.gd", + "post_run_script": "", "pre_run_script": "", "prefix": "test_", - "selected": "test_spy.gd", - "should_exit": false, + "selected": "test_print.gd", + "should_exit": true, "should_exit_on_success": false, "should_maximize": false, "show_help": false, @@ -30,7 +31,7 @@ "tests": [ ], - "unit_test_name": "test_can_add_call_to_method_on_instance", + "unit_test_name": null, "panel_options": { "font_name": "CourierPrime", "font_size": 30 diff --git a/CHANGES.md b/CHANGES.md index 99e328dc..d80065f3 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -32,6 +32,7 @@ func test_foo(): * In-Editor GUT Panel improvements * Smart buttons to run tests based on cursor location. * Added more settings (hook scripts, font color, background color, panel font settings, directory and file dialog buttons where appropriate, hide orphans) + * Display counts for errors, warnings, orphans (only displayed when present). * Added some `class_name` clauses to files: * __Issue 215__ You can now use `extends GutTest` instead of `extends 'res://addons/gut/test.gd'` when creating test scripts. That's 45% less text! * When making a hook script, you can use `extends GutHookScript` instead of using the path. diff --git a/addons/gut/gui/GutBottomPanel.gd b/addons/gut/gui/GutBottomPanel.gd index 966b8ef8..f4d29f10 100644 --- a/addons/gut/gui/GutBottomPanel.gd +++ b/addons/gut/gui/GutBottomPanel.gd @@ -26,9 +26,12 @@ onready var _ctrls = { shortcut_dialog = $BottomPanelShortcuts, light = $layout/RSplit/CResults/ControlBar/Light, results = { - passing = $layout/RSplit/CResults/ControlBar/lblPassingValue, - failing = $layout/RSplit/CResults/ControlBar/lblFailingValue, - pending = $layout/RSplit/CResults/ControlBar/lblPendingValue + passing = $layout/RSplit/CResults/ControlBar/Passing/value, + failing = $layout/RSplit/CResults/ControlBar/Failing/value, + pending = $layout/RSplit/CResults/ControlBar/Pending/value, + errors = $layout/RSplit/CResults/ControlBar/Errors/value, + warnings = $layout/RSplit/CResults/ControlBar/Warnings/value, + orphans = $layout/RSplit/CResults/ControlBar/Orphans/value }, run_at_cursor = $layout/ControlBar/RunAtCursor } @@ -235,8 +238,22 @@ func load_result_output(): return var summary_json = results.result['test_scripts']['props'] _ctrls.results.passing.text = str(summary_json.passing) + _ctrls.results.passing.get_parent().visible = true + _ctrls.results.failing.text = str(summary_json.failures) + _ctrls.results.failing.get_parent().visible = true + _ctrls.results.pending.text = str(summary_json.pending) + _ctrls.results.pending.get_parent().visible = _ctrls.results.pending.text != '0' + + _ctrls.results.errors.text = str(summary_json.errors) + _ctrls.results.errors.get_parent().visible = _ctrls.results.errors.text != '0' + + _ctrls.results.warnings.text = str(summary_json.warnings) + _ctrls.results.warnings.get_parent().visible = _ctrls.results.warnings.text != '0' + + _ctrls.results.orphans.text = str(summary_json.orphans) + _ctrls.results.orphans.get_parent().visible = _ctrls.results.orphans.text != '0' if(summary_json.tests == 0): _light_color = Color(1, 0, 0, .75) diff --git a/addons/gut/gui/GutBottomPanel.tscn b/addons/gut/gui/GutBottomPanel.tscn index df31633a..6ffd891d 100644 --- a/addons/gut/gui/GutBottomPanel.tscn +++ b/addons/gut/gui/GutBottomPanel.tscn @@ -15,28 +15,28 @@ shortcut = SubResource( 8 ) [sub_resource type="StyleBoxEmpty" id=5] [sub_resource type="DynamicFontData" id=10] -font_path = "res://addons/gut/fonts/LobsterTwo-BoldItalic.ttf" +font_path = "res://addons/gut/fonts/CourierPrime-BoldItalic.ttf" [sub_resource type="DynamicFont" id=11] size = 30 font_data = SubResource( 10 ) [sub_resource type="DynamicFontData" id=12] -font_path = "res://addons/gut/fonts/LobsterTwo-Italic.ttf" +font_path = "res://addons/gut/fonts/CourierPrime-Italic.ttf" [sub_resource type="DynamicFont" id=13] size = 30 font_data = SubResource( 12 ) [sub_resource type="DynamicFontData" id=14] -font_path = "res://addons/gut/fonts/LobsterTwo-Bold.ttf" +font_path = "res://addons/gut/fonts/CourierPrime-Bold.ttf" [sub_resource type="DynamicFont" id=15] size = 30 font_data = SubResource( 14 ) [sub_resource type="DynamicFontData" id=16] -font_path = "res://addons/gut/fonts/LobsterTwo-Regular.ttf" +font_path = "res://addons/gut/fonts/CourierPrime-Regular.ttf" [sub_resource type="DynamicFont" id=17] size = 30 @@ -164,74 +164,162 @@ margin_right = 30.0 margin_bottom = 35.0 rect_min_size = Vector2( 30, 30 ) -[node name="Sep1" type="ColorRect" parent="layout/RSplit/CResults/ControlBar"] +[node name="Passing" type="HBoxContainer" parent="layout/RSplit/CResults/ControlBar"] +visible = false margin_left = 34.0 -margin_right = 36.0 +margin_right = 107.0 +margin_bottom = 35.0 + +[node name="Sep" type="ColorRect" parent="layout/RSplit/CResults/ControlBar/Passing"] +margin_right = 2.0 margin_bottom = 35.0 rect_min_size = Vector2( 2, 0 ) -[node name="lblPassing" type="Label" parent="layout/RSplit/CResults/ControlBar"] -margin_left = 40.0 +[node name="label" type="Label" parent="layout/RSplit/CResults/ControlBar/Passing"] +margin_left = 6.0 margin_top = 10.0 -margin_right = 88.0 +margin_right = 54.0 margin_bottom = 24.0 text = "Passing" -[node name="lblPassingValue" type="Label" parent="layout/RSplit/CResults/ControlBar"] -margin_left = 92.0 +[node name="value" type="Label" parent="layout/RSplit/CResults/ControlBar/Passing"] +margin_left = 58.0 margin_top = 10.0 -margin_right = 107.0 +margin_right = 73.0 margin_bottom = 24.0 text = "---" -[node name="Sep2" type="ColorRect" parent="layout/RSplit/CResults/ControlBar"] -margin_left = 111.0 -margin_right = 113.0 +[node name="Failing" type="HBoxContainer" parent="layout/RSplit/CResults/ControlBar"] +visible = false +margin_left = 34.0 +margin_right = 100.0 +margin_bottom = 35.0 + +[node name="Sep" type="ColorRect" parent="layout/RSplit/CResults/ControlBar/Failing"] +margin_right = 2.0 margin_bottom = 35.0 rect_min_size = Vector2( 2, 0 ) -[node name="lblFailing" type="Label" parent="layout/RSplit/CResults/ControlBar"] -margin_left = 117.0 +[node name="label" type="Label" parent="layout/RSplit/CResults/ControlBar/Failing"] +margin_left = 6.0 margin_top = 10.0 -margin_right = 158.0 +margin_right = 47.0 margin_bottom = 24.0 text = "Failing" -[node name="lblFailingValue" type="Label" parent="layout/RSplit/CResults/ControlBar"] -margin_left = 162.0 +[node name="value" type="Label" parent="layout/RSplit/CResults/ControlBar/Failing"] +margin_left = 51.0 margin_top = 10.0 -margin_right = 177.0 +margin_right = 66.0 margin_bottom = 24.0 text = "---" -[node name="Sep3" type="ColorRect" parent="layout/RSplit/CResults/ControlBar"] -margin_left = 181.0 -margin_right = 183.0 +[node name="Pending" type="HBoxContainer" parent="layout/RSplit/CResults/ControlBar"] +visible = false +margin_left = 34.0 +margin_right = 110.0 +margin_bottom = 35.0 + +[node name="Sep" type="ColorRect" parent="layout/RSplit/CResults/ControlBar/Pending"] +margin_right = 2.0 margin_bottom = 35.0 rect_min_size = Vector2( 2, 0 ) -[node name="lblPending" type="Label" parent="layout/RSplit/CResults/ControlBar"] -margin_left = 187.0 +[node name="label" type="Label" parent="layout/RSplit/CResults/ControlBar/Pending"] +margin_left = 6.0 margin_top = 10.0 -margin_right = 238.0 +margin_right = 57.0 margin_bottom = 24.0 text = "Pending" -[node name="lblPendingValue" type="Label" parent="layout/RSplit/CResults/ControlBar"] -margin_left = 242.0 +[node name="value" type="Label" parent="layout/RSplit/CResults/ControlBar/Pending"] +margin_left = 61.0 margin_top = 10.0 -margin_right = 257.0 +margin_right = 76.0 margin_bottom = 24.0 text = "---" -[node name="Sep4" type="ColorRect" parent="layout/RSplit/CResults/ControlBar"] -margin_left = 261.0 -margin_right = 263.0 +[node name="Orphans" type="HBoxContainer" parent="layout/RSplit/CResults/ControlBar"] +visible = false +margin_left = 34.0 +margin_right = 110.0 +margin_bottom = 35.0 + +[node name="Sep" type="ColorRect" parent="layout/RSplit/CResults/ControlBar/Orphans"] +margin_right = 2.0 margin_bottom = 35.0 rect_min_size = Vector2( 2, 0 ) +[node name="label" type="Label" parent="layout/RSplit/CResults/ControlBar/Orphans"] +margin_left = 6.0 +margin_top = 10.0 +margin_right = 57.0 +margin_bottom = 24.0 +text = "Orphans" + +[node name="value" type="Label" parent="layout/RSplit/CResults/ControlBar/Orphans"] +margin_left = 61.0 +margin_top = 10.0 +margin_right = 76.0 +margin_bottom = 24.0 +text = "---" + +[node name="Errors" type="HBoxContainer" parent="layout/RSplit/CResults/ControlBar"] +visible = false +margin_left = 34.0 +margin_right = 96.0 +margin_bottom = 35.0 + +[node name="Sep" type="ColorRect" parent="layout/RSplit/CResults/ControlBar/Errors"] +margin_right = 2.0 +margin_bottom = 35.0 +rect_min_size = Vector2( 2, 0 ) + +[node name="label" type="Label" parent="layout/RSplit/CResults/ControlBar/Errors"] +margin_left = 6.0 +margin_top = 10.0 +margin_right = 43.0 +margin_bottom = 24.0 +hint_tooltip = "The number of GUT errors generated. This does not include engine errors." +text = "Errors" + +[node name="value" type="Label" parent="layout/RSplit/CResults/ControlBar/Errors"] +margin_left = 47.0 +margin_top = 10.0 +margin_right = 62.0 +margin_bottom = 24.0 +text = "---" + +[node name="Warnings" type="HBoxContainer" parent="layout/RSplit/CResults/ControlBar"] +visible = false +margin_left = 34.0 +margin_right = 118.0 +margin_bottom = 35.0 + +[node name="Sep" type="ColorRect" parent="layout/RSplit/CResults/ControlBar/Warnings"] +margin_right = 2.0 +margin_bottom = 35.0 +rect_min_size = Vector2( 2, 0 ) + +[node name="label" type="Label" parent="layout/RSplit/CResults/ControlBar/Warnings"] +margin_left = 6.0 +margin_top = 10.0 +margin_right = 65.0 +margin_bottom = 24.0 +text = "Warnings" +__meta__ = { +"_editor_description_": "The number of GUT Warnings generated. This does not include engine warnings." +} + +[node name="value" type="Label" parent="layout/RSplit/CResults/ControlBar/Warnings"] +margin_left = 69.0 +margin_top = 10.0 +margin_right = 84.0 +margin_bottom = 24.0 +text = "---" + [node name="CenterContainer" type="CenterContainer" parent="layout/RSplit/CResults/ControlBar"] -margin_left = 267.0 +margin_left = 34.0 margin_right = 488.0 margin_bottom = 35.0 size_flags_horizontal = 3 @@ -273,7 +361,7 @@ size_flags_vertical = 3 [node name="Settings" type="VBoxContainer" parent="layout/RSplit/sc"] margin_right = 388.0 -margin_bottom = 758.0 +margin_bottom = 806.0 size_flags_horizontal = 3 size_flags_vertical = 3 diff --git a/addons/gut/result_exporter.gd b/addons/gut/result_exporter.gd index 4bba2afa..3a529ed4 100644 --- a/addons/gut/result_exporter.gd +++ b/addons/gut/result_exporter.gd @@ -15,7 +15,7 @@ func _export_tests(summary_script): "passing":tests[key].pass_texts, "failing":tests[key].fail_texts, "pending":tests[key].pending_texts, - "orphans":tests[key].orphans + "orphans":tests[key].orphans, } return to_return @@ -48,13 +48,15 @@ func _make_results_dict(): "passing":0, "tests":0, "time":0, - "orphans":0 + "orphans":0, + "errors":0, + "warnings":0 }, "scripts":[] } } return result - + # TODO # time @@ -62,24 +64,25 @@ func _make_results_dict(): func get_results_dictionary(gut, include_scripts=true): var summary = gut.get_summary() var scripts = [] - - + if(include_scripts): scripts = _export_scripts(summary) - - var result = _make_results_dict() + + var result = _make_results_dict() if(summary != null): var totals = summary.get_totals() var props = result.test_scripts.props props.pending = totals.pending props.failures = totals.failing - props.passing = totals.passing + props.passing = totals.passing_tests props.tests = totals.tests + props.errors = gut.get_logger().get_errors().size() + props.warnings = gut.get_logger().get_warnings().size() props.time = gut.get_gui().elapsed_time_as_str().replace('s', '') - props.orpahns = gut.get_orphan_counter().get_counter('total') + props.orphans = gut.get_orphan_counter().get_counter('total') result.test_scripts.scripts = scripts - + return result diff --git a/test/panel_demo_scripts/test_totals_testing.gd b/test/panel_demo_scripts/test_totals_testing.gd new file mode 100644 index 00000000..183a0481 --- /dev/null +++ b/test/panel_demo_scripts/test_totals_testing.gd @@ -0,0 +1,28 @@ +extends GutTest + +func test_passing_test(): + pass_test('did it!') + +func test_failing_test(): + fail_test('did not do it!') + +func test_generates_error(): + gut.get_logger().error('This is a manual error') + pass_test('passing') + +func test_generates_warning(): + gut.get_logger().warn("This is a manual warning") + +func test_multiple_passing_asserts(): + assert_eq(1, 1) + assert_eq(2, 2) + assert_eq('a', 'a') + +func test_makes_orphan(): + var orphan = Node2D.new() + assert_true(true) + +func test_pending(): + pending("this is pending") + + diff --git a/test/resources/exporter_test_files/test_has_error_and_warning.gd b/test/resources/exporter_test_files/test_has_error_and_warning.gd new file mode 100644 index 00000000..25920d37 --- /dev/null +++ b/test/resources/exporter_test_files/test_has_error_and_warning.gd @@ -0,0 +1,9 @@ +extends GutTest + +func test_manual_error(): + gut.get_logger().error("This is a manual error") + pass_test('we did it') + +func test_manual_warning(): + gut.get_logger().warn("This is a manual warning") + pass_test('we did it') \ No newline at end of file diff --git a/test/unit/test_result_exporter.gd b/test/unit/test_result_exporter.gd index 5621061f..a3e63041 100644 --- a/test/unit/test_result_exporter.gd +++ b/test/unit/test_result_exporter.gd @@ -60,6 +60,9 @@ func test_test_script_props_has_props(): assert_has(result, 'pending') assert_has(result, 'failures') assert_has(result, 'tests') + assert_has(result, 'errors') + assert_has(result, 'warnings') + assert_has(result, 'orphans') func test_test_script_props_have_values_for_one_script(): run_scripts(_test_gut, 'test_simple.gd') @@ -69,6 +72,14 @@ func test_test_script_props_have_values_for_one_script(): assert_eq(result['failures'], 4, 'failures') assert_eq(result['tests'], 8, 'tests') +func test_warnings_and_errors_populated(): + run_scripts(_test_gut, 'test_has_error_and_warning.gd') + var re = ResultExporter.new() + var result = re.get_results_dictionary(_test_gut).test_scripts.props + + assert_eq(result['errors'], 1, 'errors') + assert_eq(result['warnings'], 1, 'warnings') + func test_test_scripts_contains_script(): _test_gut.test_scripts() var re = ResultExporter.new() From 6e7b692ed41fd8ee5f1b4d85d7cecd3657968fae Mon Sep 17 00:00:00 2001 From: Butch Wesley Date: Mon, 17 Jan 2022 16:39:51 -0500 Subject: [PATCH 6/8] do not show orphans when orphans hidden --- .gut_editor_config.json | 2 +- addons/gut/gui/GutBottomPanel.gd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gut_editor_config.json b/.gut_editor_config.json index 1559b88b..2fc11273 100644 --- a/.gut_editor_config.json +++ b/.gut_editor_config.json @@ -22,7 +22,7 @@ "post_run_script": "", "pre_run_script": "", "prefix": "test_", - "selected": "test_print.gd", + "selected": "test_totals_testing.gd", "should_exit": true, "should_exit_on_success": false, "should_maximize": false, diff --git a/addons/gut/gui/GutBottomPanel.gd b/addons/gut/gui/GutBottomPanel.gd index f4d29f10..2f08e814 100644 --- a/addons/gut/gui/GutBottomPanel.gd +++ b/addons/gut/gui/GutBottomPanel.gd @@ -253,7 +253,7 @@ func load_result_output(): _ctrls.results.warnings.get_parent().visible = _ctrls.results.warnings.text != '0' _ctrls.results.orphans.text = str(summary_json.orphans) - _ctrls.results.orphans.get_parent().visible = _ctrls.results.orphans.text != '0' + _ctrls.results.orphans.get_parent().visible = _ctrls.results.orphans.text != '0' and !_gut_config.options.hide_orphans if(summary_json.tests == 0): _light_color = Color(1, 0, 0, .75) From 623a64aefe349376f212a9c148582648a87e118f Mon Sep 17 00:00:00 2001 From: Butch Wesley Date: Mon, 17 Jan 2022 17:04:45 -0500 Subject: [PATCH 7/8] log levels explained in mouse over --- .gut_editor_config.json | 4 ++-- addons/gut/gui/gut_config_gui.gd | 6 +++++- test/panel_demo_scripts/test_totals_testing.gd | 4 ++++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.gut_editor_config.json b/.gut_editor_config.json index 2fc11273..93ea0cb2 100644 --- a/.gut_editor_config.json +++ b/.gut_editor_config.json @@ -17,7 +17,7 @@ "inner_class": null, "junit_xml_file": "", "junit_xml_timestamp": false, - "log_level": 0, + "log_level": 1, "opacity": 100, "post_run_script": "", "pre_run_script": "", @@ -31,7 +31,7 @@ "tests": [ ], - "unit_test_name": null, + "unit_test_name": "test_makes_an_info", "panel_options": { "font_name": "CourierPrime", "font_size": 30 diff --git a/addons/gut/gui/gut_config_gui.gd b/addons/gut/gui/gut_config_gui.gd index 27685a72..bc71057a 100644 --- a/addons/gut/gui/gut_config_gui.gd +++ b/addons/gut/gui/gut_config_gui.gd @@ -200,7 +200,11 @@ func get_config_issues(): func set_options(options): _add_title("Settings") _add_number("log_level", options.log_level, "Log Level", 0, 3, - "Detail level for log messages.") + "Detail level for log messages.\n" + \ + "\t0: Errors and failures only.\n" + \ + "\t1: Adds all test names + warnings + info\n" + \ + "\t2: Shows all asserts\n" + \ + "\t3: Adds more stuff probably, maybe not.") _add_boolean('ignore_pause', options.ignore_pause, 'Ignore Pause', "Ignore calls to pause_before_teardown") _add_boolean('hide_orphans', options.hide_orphans, 'Hide Orphans', diff --git a/test/panel_demo_scripts/test_totals_testing.gd b/test/panel_demo_scripts/test_totals_testing.gd index 183a0481..1e0895ec 100644 --- a/test/panel_demo_scripts/test_totals_testing.gd +++ b/test/panel_demo_scripts/test_totals_testing.gd @@ -22,6 +22,10 @@ func test_makes_orphan(): var orphan = Node2D.new() assert_true(true) +func test_makes_an_info(): + gut.get_logger().info("here is some info") + pass_test('info pass!') + func test_pending(): pending("this is pending") From 75ddd37782774bb66ab54fbd1c32b44aac6a903d Mon Sep 17 00:00:00 2001 From: Butch Wesley Date: Mon, 17 Jan 2022 17:11:51 -0500 Subject: [PATCH 8/8] disable colors setting --- .gut_editor_config.json | 4 ++-- CHANGES.md | 2 +- addons/gut/gui/gut_config_gui.gd | 5 ++++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.gut_editor_config.json b/.gut_editor_config.json index 93ea0cb2..da201e51 100644 --- a/.gut_editor_config.json +++ b/.gut_editor_config.json @@ -23,7 +23,7 @@ "pre_run_script": "", "prefix": "test_", "selected": "test_totals_testing.gd", - "should_exit": true, + "should_exit": false, "should_exit_on_success": false, "should_maximize": false, "show_help": false, @@ -31,7 +31,7 @@ "tests": [ ], - "unit_test_name": "test_makes_an_info", + "unit_test_name": null, "panel_options": { "font_name": "CourierPrime", "font_size": 30 diff --git a/CHANGES.md b/CHANGES.md index d80065f3..a59cfecf 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -31,7 +31,7 @@ func test_foo(): ``` * In-Editor GUT Panel improvements * Smart buttons to run tests based on cursor location. - * Added more settings (hook scripts, font color, background color, panel font settings, directory and file dialog buttons where appropriate, hide orphans) + * Added more settings (hook scripts, font color, background color, panel font settings, directory and file dialog buttons where appropriate, hide orphans, disable colors) * Display counts for errors, warnings, orphans (only displayed when present). * Added some `class_name` clauses to files: * __Issue 215__ You can now use `extends GutTest` instead of `extends 'res://addons/gut/test.gd'` when creating test scripts. That's 45% less text! diff --git a/addons/gut/gui/gut_config_gui.gd b/addons/gut/gui/gut_config_gui.gd index bc71057a..63e387a6 100644 --- a/addons/gut/gui/gut_config_gui.gd +++ b/addons/gut/gui/gut_config_gui.gd @@ -221,7 +221,7 @@ func set_options(options): _add_boolean("junit_xml_timestamp", options.junit_xml_timestamp, "Include timestamp", "Include a timestamp in the filename so that each run gets its own xml file.") - _add_title("Output") + _add_title("Panel Output") _add_select('output_font_name', options.panel_options.font_name, _avail_fonts, 'Font', "The name of the font to use when running tests and in the output panel to the left.") _add_number('output_font_size', options.panel_options.font_size, 'Font Size', 5, 100, @@ -239,6 +239,8 @@ func set_options(options): "The opacity of GUT when tests are running.") _add_color('background_color', options.background_color, 'Background Color') _add_color('font_color', options.font_color, 'Font Color') + _add_boolean('disable_colors', options.disable_colors, 'Disable Formatting', + 'Disable formatting and colors used in the Runner. Does not affect panel output.') _add_title('Directories') @@ -289,6 +291,7 @@ func get_options(base_opts): to_return.opacity = _cfg_ctrls.opacity.value to_return.background_color = _cfg_ctrls.background_color.color.to_html() to_return.font_color = _cfg_ctrls.font_color.color.to_html() + to_return.disable_colors = _cfg_ctrls.disable_colors.pressed # Directories