Skip to content

Commit

Permalink
deps: update gdunit
Browse files Browse the repository at this point in the history
  • Loading branch information
russmatney committed Jun 22, 2024
1 parent 05f9236 commit fa781a3
Show file tree
Hide file tree
Showing 43 changed files with 288 additions and 180 deletions.
2 changes: 1 addition & 1 deletion addons/gdUnit4/plugin.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
name="gdUnit4"
description="Unit Testing Framework for Godot Scripts"
author="Mike Schulze"
version="4.3.2"
version="4.3.3"
script="plugin.gd"
18 changes: 6 additions & 12 deletions addons/gdUnit4/plugin.gd
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
@tool
extends EditorPlugin

const GdUnitTools := preload("res://addons/gdUnit4/src/core/GdUnitTools.gd")
const GdUnitTestDiscoverGuard := preload("res://addons/gdUnit4/src/core/discovery/GdUnitTestDiscoverGuard.gd")
const GdUnitTools := preload ("res://addons/gdUnit4/src/core/GdUnitTools.gd")
const GdUnitTestDiscoverGuard := preload ("res://addons/gdUnit4/src/core/discovery/GdUnitTestDiscoverGuard.gd")


var _gd_inspector :Node
var _server_node :Node
var _gd_console :Node
var _guard: GdUnitTestDiscoverGuard

Expand All @@ -25,11 +24,9 @@ func _enter_tree() -> void:
# install the GdUnit Console
_gd_console = load("res://addons/gdUnit4/src/ui/GdUnitConsole.tscn").instantiate()
add_control_to_bottom_panel(_gd_console, "gdUnitConsole")
_server_node = load("res://addons/gdUnit4/src/network/GdUnitServer.tscn").instantiate()
Engine.get_main_loop().root.add_child.call_deferred(_server_node)
prints("Loading GdUnit4 Plugin success")
if GdUnitSettings.is_update_notification_enabled():
var update_tool :Node = load("res://addons/gdUnit4/src/update/GdUnitUpdateNotify.tscn").instantiate()
var update_tool: Node = load("res://addons/gdUnit4/src/update/GdUnitUpdateNotify.tscn").instantiate()
Engine.get_main_loop().root.add_child.call_deferred(update_tool)
if GdUnit4CSharpApiLoader.is_mono_supported():
prints("GdUnit4Net version '%s' loaded." % GdUnit4CSharpApiLoader.version())
Expand All @@ -43,14 +40,11 @@ func _exit_tree() -> void:
return
if is_instance_valid(_gd_inspector):
remove_control_from_docks(_gd_inspector)
GodotVersionFixures.free_fix(_gd_inspector)
_gd_inspector.free()
if is_instance_valid(_gd_console):
remove_control_from_bottom_panel(_gd_console)
_gd_console.free()
if is_instance_valid(_server_node):
Engine.get_main_loop().root.remove_child.call_deferred(_server_node)
_server_node.queue_free()
GdUnitTools.dispose_all.call_deferred()
GdUnitTools.dispose_all(true)
prints("Unload GdUnit4 Plugin success")


Expand All @@ -60,6 +54,6 @@ func check_running_in_test_env() -> bool:
return DisplayServer.get_name() == "headless" or args.has("--selftest") or args.has("--add") or args.has("-a") or args.has("--quit-after") or args.has("--import")


func _on_resource_saved(resource :Resource) -> void:
func _on_resource_saved(resource: Resource) -> void:
if resource is Script:
_guard.discover(resource)
11 changes: 11 additions & 0 deletions addons/gdUnit4/src/GdUnitArrayAssert.gd
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,14 @@ func extractv(
extractor8 :GdUnitValueExtractor = null,
extractor9 :GdUnitValueExtractor = null) -> GdUnitArrayAssert:
return self



@warning_ignore("unused_parameter")
func override_failure_message(message :String) -> GdUnitArrayAssert:
return self


@warning_ignore("unused_parameter")
func append_failure_message(message :String) -> GdUnitArrayAssert:
return self
8 changes: 8 additions & 0 deletions addons/gdUnit4/src/GdUnitAssert.gd
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,11 @@ func test_fail():
@warning_ignore("untyped_declaration")
func override_failure_message(message :String):
return self


## Appends a custom message to the failure message.
## This can be used to add additional infromations to the generated failure message.
@warning_ignore("unused_parameter")
@warning_ignore("untyped_declaration")
func append_failure_message(message :String):
return self
6 changes: 6 additions & 0 deletions addons/gdUnit4/src/GdUnitFailureAssert.gd
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,9 @@ func has_message(expected: String) -> GdUnitFailureAssert:
@warning_ignore("unused_parameter")
func starts_with_message(expected: String) -> GdUnitFailureAssert:
return self


## Verifies that the failure message contains the expected message.
@warning_ignore("unused_parameter")
func contains_message(expected: String) -> GdUnitFailureAssert:
return self
2 changes: 1 addition & 1 deletion addons/gdUnit4/src/GdUnitTestSuite.gd
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
## [/codeblock]
## @tutorial: https://mikeschulze.github.io/gdUnit4/faq/test-suite/

@icon("res://addons/gdUnit4/src/ui/assets/TestSuite.svg")
@icon("res://addons/gdUnit4/src/ui/settings/logo.png")
class_name GdUnitTestSuite
extends Node

Expand Down
10 changes: 10 additions & 0 deletions addons/gdUnit4/src/asserts/GdAssertMessages.gd
Original file line number Diff line number Diff line change
Expand Up @@ -613,3 +613,13 @@ static func format_invalid(value :String) -> String:

static func humanized(value :String) -> String:
return value.replace("_", " ")


static func build_failure_message(failure :String, additional_failure_message: String, custom_failure_message: String) -> String:
var message := failure if custom_failure_message.is_empty() else custom_failure_message
if additional_failure_message.is_empty():
return message
return """
%s
[color=LIME_GREEN][b]Additional info:[/b][/color]
%s""".dedent().trim_prefix("\n") % [message, additional_failure_message]
7 changes: 6 additions & 1 deletion addons/gdUnit4/src/asserts/GdUnitArrayAssertImpl.gd
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,19 @@ func report_error(error :String) -> GdUnitArrayAssert:


func failure_message() -> String:
return _base._current_error_message
return _base.failure_message()


func override_failure_message(message :String) -> GdUnitArrayAssert:
_base.override_failure_message(message)
return self


func append_failure_message(message :String) -> GdUnitArrayAssert:
_base.append_failure_message(message)
return self


func _validate_value_type(value :Variant) -> bool:
return value == null or GdArrayTools.is_array_type(value)

Expand Down
19 changes: 14 additions & 5 deletions addons/gdUnit4/src/asserts/GdUnitAssertImpl.gd
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ extends GdUnitAssert


var _current :Variant
var _current_error_message :String = ""
var _current_failure_message :String = ""
var _custom_failure_message :String = ""
var _additional_failure_message: String = ""


func _init(current :Variant) -> void:
Expand All @@ -13,8 +14,11 @@ func _init(current :Variant) -> void:
GdAssertReports.reset_last_error_line_number()





func failure_message() -> String:
return _current_error_message
return _current_failure_message


func current_value() -> Variant:
Expand All @@ -26,11 +30,11 @@ func report_success() -> GdUnitAssert:
return self


func report_error(error_message :String, failure_line_number: int = -1) -> GdUnitAssert:
func report_error(failure :String, failure_line_number: int = -1) -> GdUnitAssert:
var line_number := failure_line_number if failure_line_number != -1 else GdUnitAssertions.get_line_number()
GdAssertReports.set_last_error_line_number(line_number)
_current_error_message = error_message if _custom_failure_message.is_empty() else _custom_failure_message
GdAssertReports.report_error(_current_error_message, line_number)
_current_failure_message = GdAssertMessages.build_failure_message(failure, _additional_failure_message, _custom_failure_message)
GdAssertReports.report_error(_current_failure_message, line_number)
Engine.set_meta("GD_TEST_FAILURE", true)
return self

Expand All @@ -44,6 +48,11 @@ func override_failure_message(message :String) -> GdUnitAssert:
return self


func append_failure_message(message :String) -> GdUnitAssert:
_additional_failure_message = message
return self


func is_equal(expected :Variant) -> GdUnitAssert:
var current :Variant = current_value()
if not GdObjects.equals(current, expected):
Expand Down
7 changes: 6 additions & 1 deletion addons/gdUnit4/src/asserts/GdUnitBoolAssertImpl.gd
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,19 @@ func report_error(error :String) -> GdUnitBoolAssert:


func failure_message() -> String:
return _base._current_error_message
return _base.failure_message()


func override_failure_message(message :String) -> GdUnitBoolAssert:
_base.override_failure_message(message)
return self


func append_failure_message(message :String) -> GdUnitBoolAssert:
_base.append_failure_message(message)
return self


# Verifies that the current value is null.
func is_null() -> GdUnitBoolAssert:
_base.is_null()
Expand Down
7 changes: 6 additions & 1 deletion addons/gdUnit4/src/asserts/GdUnitDictionaryAssertImpl.gd
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,19 @@ func report_error(error :String) -> GdUnitDictionaryAssert:


func failure_message() -> String:
return _base._current_error_message
return _base.failure_message()


func override_failure_message(message :String) -> GdUnitDictionaryAssert:
_base.override_failure_message(message)
return self


func append_failure_message(message :String) -> GdUnitDictionaryAssert:
_base.append_failure_message(message)
return self


func current_value() -> Variant:
return _base.current_value()

Expand Down
10 changes: 10 additions & 0 deletions addons/gdUnit4/src/asserts/GdUnitFailureAssertImpl.gd
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,16 @@ func has_message(expected :String) -> GdUnitFailureAssert:
return self


func contains_message(expected :String) -> GdUnitFailureAssert:
var expected_error := GdUnitTools.normalize_text(expected)
var current_error := GdUnitTools.normalize_text(GdUnitTools.richtext_normalize(_failure_message))
if not current_error.contains(expected_error):
var diffs := GdDiffTool.string_diff(current_error, expected_error)
var current := GdAssertMessages.colored_array_div(diffs[1])
_report_error(GdAssertMessages.error_not_same_error(current, expected_error))
return self


func starts_with_message(expected :String) -> GdUnitFailureAssert:
var expected_error := GdUnitTools.normalize_text(expected)
var current_error := GdUnitTools.normalize_text(GdUnitTools.richtext_normalize(_failure_message))
Expand Down
7 changes: 6 additions & 1 deletion addons/gdUnit4/src/asserts/GdUnitFileAssertImpl.gd
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,19 @@ func report_error(error :String) -> GdUnitFileAssert:


func failure_message() -> String:
return _base._current_error_message
return _base.failure_message()


func override_failure_message(message :String) -> GdUnitFileAssert:
_base.override_failure_message(message)
return self


func append_failure_message(message :String) -> GdUnitFileAssert:
_base.append_failure_message(message)
return self


func is_equal(expected :Variant) -> GdUnitFileAssert:
_base.is_equal(expected)
return self
Expand Down
7 changes: 6 additions & 1 deletion addons/gdUnit4/src/asserts/GdUnitFloatAssertImpl.gd
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,19 @@ func report_error(error :String) -> GdUnitFloatAssert:


func failure_message() -> String:
return _base._current_error_message
return _base.failure_message()


func override_failure_message(message :String) -> GdUnitFloatAssert:
_base.override_failure_message(message)
return self


func append_failure_message(message :String) -> GdUnitFloatAssert:
_base.append_failure_message(message)
return self


func is_null() -> GdUnitFloatAssert:
_base.is_null()
return self
Expand Down
16 changes: 11 additions & 5 deletions addons/gdUnit4/src/asserts/GdUnitFuncAssertImpl.gd
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ const DEFAULT_TIMEOUT := 2000


var _current_value_provider :ValueProvider
var _current_error_message :String = ""
var _current_failure_message :String = ""
var _custom_failure_message :String = ""
var _additional_failure_message: String = ""
var _line_number := -1
var _timeout := DEFAULT_TIMEOUT
var _interrupted := false
Expand Down Expand Up @@ -43,14 +44,14 @@ func report_success() -> GdUnitFuncAssert:
return self


func report_error(error_message :String) -> GdUnitFuncAssert:
_current_error_message = error_message if _custom_failure_message == "" else _custom_failure_message
GdAssertReports.report_error(_current_error_message, _line_number)
func report_error(failure :String) -> GdUnitFuncAssert:
_current_failure_message = GdAssertMessages.build_failure_message(failure, _additional_failure_message, _custom_failure_message)
GdAssertReports.report_error(_current_failure_message, _line_number)
return self


func failure_message() -> String:
return _current_error_message
return _current_failure_message


func send_report(report :GdUnitReport)-> void:
Expand All @@ -62,6 +63,11 @@ func override_failure_message(message :String) -> GdUnitFuncAssert:
return self


func append_failure_message(message :String) -> GdUnitFuncAssert:
_additional_failure_message = message
return self


func wait_until(timeout := 2000) -> GdUnitFuncAssert:
if timeout <= 0:
push_warning("Invalid timeout param, alloed timeouts must be grater than 0. Use default timeout instead")
Expand Down
7 changes: 6 additions & 1 deletion addons/gdUnit4/src/asserts/GdUnitIntAssertImpl.gd
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,19 @@ func report_error(error :String) -> GdUnitIntAssert:


func failure_message() -> String:
return _base._current_error_message
return _base.failure_message()


func override_failure_message(message :String) -> GdUnitIntAssert:
_base.override_failure_message(message)
return self


func append_failure_message(message :String) -> GdUnitIntAssert:
_base.append_failure_message(message)
return self


func is_null() -> GdUnitIntAssert:
_base.is_null()
return self
Expand Down
7 changes: 6 additions & 1 deletion addons/gdUnit4/src/asserts/GdUnitObjectAssertImpl.gd
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,19 @@ func report_error(error :String) -> GdUnitObjectAssert:


func failure_message() -> String:
return _base._current_error_message
return _base.failure_message()


func override_failure_message(message :String) -> GdUnitObjectAssert:
_base.override_failure_message(message)
return self


func append_failure_message(message :String) -> GdUnitObjectAssert:
_base.append_failure_message(message)
return self


func is_equal(expected :Variant) -> GdUnitObjectAssert:
_base.is_equal(expected)
return self
Expand Down
7 changes: 6 additions & 1 deletion addons/gdUnit4/src/asserts/GdUnitResultAssertImpl.gd
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,19 @@ func report_error(error :String) -> GdUnitResultAssert:


func failure_message() -> String:
return _base._current_error_message
return _base.failure_message()


func override_failure_message(message :String) -> GdUnitResultAssert:
_base.override_failure_message(message)
return self


func append_failure_message(message :String) -> GdUnitResultAssert:
_base.append_failure_message(message)
return self


func is_null() -> GdUnitResultAssert:
_base.is_null()
return self
Expand Down
Loading

0 comments on commit fa781a3

Please sign in to comment.