Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/ci/reports/test_reports.rb')
-rw-r--r--lib/gitlab/ci/reports/test_reports.rb39
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/gitlab/ci/reports/test_reports.rb b/lib/gitlab/ci/reports/test_reports.rb
new file mode 100644
index 00000000000..c6e732e68eb
--- /dev/null
+++ b/lib/gitlab/ci/reports/test_reports.rb
@@ -0,0 +1,39 @@
+module Gitlab
+ module Ci
+ module Reports
+ class TestReports
+ attr_reader :test_suites
+
+ def initialize
+ @test_suites = {}
+ end
+
+ def get_suite(suite_name)
+ test_suites[suite_name] ||= TestSuite.new(suite_name)
+ end
+
+ def total_time
+ test_suites.values.sum(&:total_time)
+ end
+
+ def total_count
+ test_suites.values.sum(&:total_count)
+ end
+
+ def total_status
+ if failed_count > 0 || error_count > 0
+ TestCase::STATUS_FAILED
+ else
+ TestCase::STATUS_SUCCESS
+ end
+ end
+
+ TestCase::STATUS_TYPES.each do |status_type|
+ define_method("#{status_type}_count") do
+ test_suites.values.sum { |suite| suite.public_send("#{status_type}_count") } # rubocop:disable GitlabSecurity/PublicSend
+ end
+ end
+ end
+ end
+ end
+end