fixed camera and sword animation issue and upgraded to Godot 4.6
This commit is contained in:
@@ -4,6 +4,7 @@ var _current_failure_message := ""
|
||||
var _custom_failure_message := ""
|
||||
var _additional_failure_message := ""
|
||||
var _callable: Callable
|
||||
var _logger := GodotGdErrorMonitor.new()
|
||||
|
||||
|
||||
func _init(callable: Callable) -> void:
|
||||
@@ -14,17 +15,10 @@ func _init(callable: Callable) -> void:
|
||||
|
||||
|
||||
func _execute() -> Array[ErrorLogEntry]:
|
||||
# execute the given code and monitor for runtime errors
|
||||
if _callable == null or not _callable.is_valid():
|
||||
@warning_ignore("return_value_discarded")
|
||||
_report_error("Invalid Callable '%s'" % _callable)
|
||||
else:
|
||||
await _callable.call()
|
||||
return await _error_monitor().scan(true)
|
||||
|
||||
|
||||
func _error_monitor() -> GodotGdErrorMonitor:
|
||||
return GdUnitThreadManager.get_current_context().get_execution_context().error_monitor
|
||||
_logger.start()
|
||||
await _callable.call()
|
||||
_logger.stop()
|
||||
return _logger.log_entries()
|
||||
|
||||
|
||||
func failure_message() -> String:
|
||||
@@ -46,8 +40,6 @@ func _report_error(error_message: String, failure_line_number: int = -1) -> GdUn
|
||||
func _has_log_entry(log_entries: Array[ErrorLogEntry], type: ErrorLogEntry.TYPE, error: Variant) -> bool:
|
||||
for entry in log_entries:
|
||||
if entry._type == type and GdObjects.equals(entry._message, error):
|
||||
# Erase the log entry we already handled it by this assertion, otherwise it will report at twice
|
||||
_error_monitor().erase_log_entry(entry)
|
||||
return true
|
||||
return false
|
||||
|
||||
@@ -55,12 +47,11 @@ func _has_log_entry(log_entries: Array[ErrorLogEntry], type: ErrorLogEntry.TYPE,
|
||||
func _to_list(log_entries: Array[ErrorLogEntry]) -> String:
|
||||
if log_entries.is_empty():
|
||||
return "no errors"
|
||||
if log_entries.size() == 1:
|
||||
return log_entries[0]._message
|
||||
var value := ""
|
||||
|
||||
var values := []
|
||||
for entry in log_entries:
|
||||
value += "'%s'\n" % entry._message
|
||||
return value
|
||||
values.append(entry)
|
||||
return "\n".join(values)
|
||||
|
||||
|
||||
func is_null() -> GdUnitGodotErrorAssert:
|
||||
@@ -90,6 +81,9 @@ func append_failure_message(message: String) -> GdUnitGodotErrorAssert:
|
||||
|
||||
|
||||
func is_success() -> GdUnitGodotErrorAssert:
|
||||
if not _validate_callable():
|
||||
return self
|
||||
|
||||
var log_entries := await _execute()
|
||||
if log_entries.is_empty():
|
||||
return _report_success()
|
||||
@@ -100,6 +94,9 @@ func is_success() -> GdUnitGodotErrorAssert:
|
||||
|
||||
|
||||
func is_runtime_error(expected_error: Variant) -> GdUnitGodotErrorAssert:
|
||||
if not _validate_callable():
|
||||
return self
|
||||
|
||||
var result := GdUnitArgumentMatchers.is_variant_string_matching(expected_error)
|
||||
if result.is_error():
|
||||
return _report_error(result.error_message())
|
||||
@@ -108,12 +105,15 @@ func is_runtime_error(expected_error: Variant) -> GdUnitGodotErrorAssert:
|
||||
return _report_success()
|
||||
return _report_error("""
|
||||
Expecting: a runtime error is triggered.
|
||||
message: '%s'
|
||||
found: %s
|
||||
expected: '%s'
|
||||
current: '%s'
|
||||
""".dedent().trim_prefix("\n") % [expected_error, _to_list(log_entries)])
|
||||
|
||||
|
||||
func is_push_warning(expected_warning: Variant) -> GdUnitGodotErrorAssert:
|
||||
if not _validate_callable():
|
||||
return self
|
||||
|
||||
var result := GdUnitArgumentMatchers.is_variant_string_matching(expected_warning)
|
||||
if result.is_error():
|
||||
return _report_error(result.error_message())
|
||||
@@ -122,12 +122,15 @@ func is_push_warning(expected_warning: Variant) -> GdUnitGodotErrorAssert:
|
||||
return _report_success()
|
||||
return _report_error("""
|
||||
Expecting: push_warning() is called.
|
||||
message: '%s'
|
||||
found: %s
|
||||
expected: '%s'
|
||||
current: '%s'
|
||||
""".dedent().trim_prefix("\n") % [expected_warning, _to_list(log_entries)])
|
||||
|
||||
|
||||
func is_push_error(expected_error: Variant) -> GdUnitGodotErrorAssert:
|
||||
if not _validate_callable():
|
||||
return self
|
||||
|
||||
var result := GdUnitArgumentMatchers.is_variant_string_matching(expected_error)
|
||||
if result.is_error():
|
||||
return _report_error(result.error_message())
|
||||
@@ -136,6 +139,14 @@ func is_push_error(expected_error: Variant) -> GdUnitGodotErrorAssert:
|
||||
return _report_success()
|
||||
return _report_error("""
|
||||
Expecting: push_error() is called.
|
||||
message: '%s'
|
||||
found: %s
|
||||
expected: '%s'
|
||||
current: '%s'
|
||||
""".dedent().trim_prefix("\n") % [expected_error, _to_list(log_entries)])
|
||||
|
||||
|
||||
func _validate_callable() -> bool:
|
||||
if _callable == null or not _callable.is_valid():
|
||||
@warning_ignore("return_value_discarded")
|
||||
_report_error("Invalid Callable '%s'" % _callable)
|
||||
return false
|
||||
return true
|
||||
|
||||
Reference in New Issue
Block a user