From 4f0d1626677f22dbdc37aa4a069b8ed1354f34f7 Mon Sep 17 00:00:00 2001 From: Nullpointer Date: Tue, 28 May 2024 13:47:17 +0200 Subject: [PATCH] GD-474: Fix test Godot Runtime Error is reported repeatedly (#475) # Why see https://github.com/MikeSchulze/gdUnit4/issues/474 # What Do cleanup log entries after collected as reports --- addons/gdUnit4/src/monitor/GodotGdErrorMonitor.gd | 1 + addons/gdUnit4/test/monitor/GodotGdErrorMonitorTest.gd | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/addons/gdUnit4/src/monitor/GodotGdErrorMonitor.gd b/addons/gdUnit4/src/monitor/GodotGdErrorMonitor.gd index 47dd6bf8..720fe5c8 100644 --- a/addons/gdUnit4/src/monitor/GodotGdErrorMonitor.gd +++ b/addons/gdUnit4/src/monitor/GodotGdErrorMonitor.gd @@ -28,6 +28,7 @@ func to_reports() -> Array[GdUnitReport]: var reports_ :Array[GdUnitReport] = [] if _report_enabled: reports_.assign(_entries.map(_to_report)) + _entries.clear() return reports_ diff --git a/addons/gdUnit4/test/monitor/GodotGdErrorMonitorTest.gd b/addons/gdUnit4/test/monitor/GodotGdErrorMonitorTest.gd index 4fafe82f..daf4b4a7 100644 --- a/addons/gdUnit4/test/monitor/GodotGdErrorMonitorTest.gd +++ b/addons/gdUnit4/test/monitor/GodotGdErrorMonitorTest.gd @@ -123,3 +123,10 @@ func test_integration_test() -> void: assert_str(reports[1].message()).contains("Test GodotGdErrorMonitor 'push_warning' reporting") else: fail("Expect reporting runtime errors") + + # scan second time should not report the same errors again + monitor.start() + monitor.stop() + await monitor.scan(true) + reports = monitor.to_reports() + assert_array(reports).is_empty()