Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix id file generation, closes #190, closes #193 #194

Merged
merged 6 commits into from
Jul 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 0 additions & 99 deletions addons/gdUnit4/bin/ProjectScanner.gd

This file was deleted.

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"
2 changes: 1 addition & 1 deletion addons/gdUnit4/plugin.gd
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ func check_running_in_test_env() -> bool:

func _on_resource_saved(resource: Resource) -> void:
if resource is Script:
_guard.discover(resource)
await _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
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
Loading
Loading