summaryrefslogtreecommitdiff
path: root/addons/gdUnit4/src/core/execution/GdUnitTestReportCollector.gd
diff options
context:
space:
mode:
authorradiohotline <radoihotline@disroot.rg>2026-08-25 16:33:56 +0300
committerradiohotline <radoihotline@disroot.rg>2026-08-25 16:33:56 +0300
commita89e744ed0e8c759caf041a580112365bbfe4303 (patch)
treedd61e320904176995727e86a857d00c90d4933ba /addons/gdUnit4/src/core/execution/GdUnitTestReportCollector.gd
parent6d53d8cac78250dc888aa49d5f9d4175c6652feb (diff)
escoria updateHEADmain
Diffstat (limited to 'addons/gdUnit4/src/core/execution/GdUnitTestReportCollector.gd')
-rw-r--r--addons/gdUnit4/src/core/execution/GdUnitTestReportCollector.gd77
1 files changed, 77 insertions, 0 deletions
diff --git a/addons/gdUnit4/src/core/execution/GdUnitTestReportCollector.gd b/addons/gdUnit4/src/core/execution/GdUnitTestReportCollector.gd
new file mode 100644
index 0000000..91247bd
--- /dev/null
+++ b/addons/gdUnit4/src/core/execution/GdUnitTestReportCollector.gd
@@ -0,0 +1,77 @@
+# Collects all reports seperated as warnings, failures and errors
+class_name GdUnitTestReportCollector
+extends RefCounted
+
+
+var _reports :Array[GdUnitReport] = []
+
+
+static func __filter_is_error(report :GdUnitReport) -> bool:
+ return report.is_error()
+
+
+static func __filter_is_failure(report :GdUnitReport) -> bool:
+ return report.is_failure()
+
+
+static func __filter_is_warning(report :GdUnitReport) -> bool:
+ return report.is_warning()
+
+
+static func __filter_is_skipped(report :GdUnitReport) -> bool:
+ return report.is_skipped()
+
+
+static func __filter_is_orphan(report: GdUnitReport) -> bool:
+ return report.is_orphan()
+
+
+static func count_failures(reports_: Array[GdUnitReport]) -> int:
+ return reports_.filter(__filter_is_failure).size()
+
+
+static func count_errors(reports_: Array[GdUnitReport]) -> int:
+ return reports_.filter(__filter_is_error).size()
+
+
+static func count_warnings(reports_: Array[GdUnitReport]) -> int:
+ return reports_.filter(__filter_is_warning).size()
+
+
+static func count_skipped(reports_: Array[GdUnitReport]) -> int:
+ return reports_.filter(__filter_is_skipped).size()
+
+
+static func count_orphans(reports_: Array[GdUnitReport]) -> int:
+ var orphan_reports := reports_.filter(__filter_is_orphan)
+ if orphan_reports.is_empty():
+ return 0
+ ## Collect orphan count from the reports
+ var orphans := 0
+ for report: GdUnitReport in orphan_reports:
+ orphans += report._current_value
+ return orphans
+
+
+func has_failures() -> bool:
+ return _reports.any(__filter_is_failure)
+
+
+func has_errors() -> bool:
+ return _reports.any(__filter_is_error)
+
+
+func has_warnings() -> bool:
+ return _reports.any(__filter_is_warning)
+
+
+func has_skipped() -> bool:
+ return _reports.any(__filter_is_skipped)
+
+
+func reports() -> Array[GdUnitReport]:
+ return _reports
+
+
+func push_back(report :GdUnitReport) -> void:
+ _reports.push_back(report)