Skip to content

Error string on engine errors lacks actual error message #803

@dreed-sd

Description

@dreed-sd

Versions

(list all versions where you have replicated the bug)

  • Godot: 4.6
  • GUT: 9.5
  • OS: MacOS

The Bug

When a test fails due to an engine error, the text that reports why the test failed lacks the original error message from the engine.

Reason is that when there's an engine error, there are 2 strings provided to the OS logger that is registered (in this case GUT's ErrorTracker): code, and rationale. The code is usually some arcane statement like the variable that was asserted on, while the rationale has a more meaningful message. But GUT reports only the code.

Steps To Reproduce

Run this test:

func test_gut_error_reporting() -> void:
	OS.delay_usec(-10)
	assert_true(true)

The test will fail with:

    [Failed]:  Unexpected Errors:
    [1] <engine-0>Condition "p_usec < 0" is true.
          at line -1

But the actual error message logged by the engine was much better:

ERROR: Can't sleep for -10 microseconds. The delay provided must be greater than or equal to 0 microseconds.

This is not the best example as even the 'code' message is useful, but often times it isn't. If there's a problem loading a scene, for example, then the error 'code' is just "!valid was true" instead of the much more meaningful string about what part of the scene had a problem.

I believe the fix should be to update the ErrorTracker to do this ternary operation in get_fail_text_for_errors, but maybe there's a better format that uses both strings, and maybe there are other locations where this should be done.

	if(errors.items.has(test_id)):
		for error in errors.items[test_id]:
			if(_is_error_failable(error)):
				error_texts.append(str('<', error.get_error_type_name(), '>', error.rationale if error.rationale else error.code)) # <-- use rationale if provided

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions