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')
-rw-r--r--lib/gitlab/ci/reports/accessibility_reports_comparer.rb2
-rw-r--r--lib/gitlab/ci/reports/test_report_summary.rb35
-rw-r--r--lib/gitlab/ci/reports/test_reports.rb4
-rw-r--r--lib/gitlab/ci/reports/test_suite.rb2
-rw-r--r--lib/gitlab/ci/reports/test_suite_summary.rb31
5 files changed, 28 insertions, 46 deletions
diff --git a/lib/gitlab/ci/reports/accessibility_reports_comparer.rb b/lib/gitlab/ci/reports/accessibility_reports_comparer.rb
index fa6337166d5..210eb17f2d3 100644
--- a/lib/gitlab/ci/reports/accessibility_reports_comparer.rb
+++ b/lib/gitlab/ci/reports/accessibility_reports_comparer.rb
@@ -17,7 +17,7 @@ module Gitlab
end
def status
- head_reports.errors_count.positive? ? STATUS_FAILED : STATUS_SUCCESS
+ head_reports.errors_count > 0 ? STATUS_FAILED : STATUS_SUCCESS
end
def existing_errors
diff --git a/lib/gitlab/ci/reports/test_report_summary.rb b/lib/gitlab/ci/reports/test_report_summary.rb
index 85b83b790e7..3e7227b7223 100644
--- a/lib/gitlab/ci/reports/test_report_summary.rb
+++ b/lib/gitlab/ci/reports/test_report_summary.rb
@@ -4,42 +4,17 @@ module Gitlab
module Ci
module Reports
class TestReportSummary
- attr_reader :all_results
-
- def initialize(all_results)
- @all_results = all_results
+ def initialize(build_report_results)
+ @build_report_results = build_report_results
+ @suite_summary = TestSuiteSummary.new(@build_report_results)
end
def total
- TestSuiteSummary.new(all_results)
- end
-
- def total_time
- total.total_time
- end
-
- def total_count
- total.total_count
- end
-
- def success_count
- total.success_count
- end
-
- def failed_count
- total.failed_count
- end
-
- def skipped_count
- total.skipped_count
- end
-
- def error_count
- total.error_count
+ @suite_summary.to_h
end
def test_suites
- all_results
+ @build_report_results
.group_by(&:tests_name)
.transform_values { |results| TestSuiteSummary.new(results) }
end
diff --git a/lib/gitlab/ci/reports/test_reports.rb b/lib/gitlab/ci/reports/test_reports.rb
index 86ba725c71e..a5a630642e5 100644
--- a/lib/gitlab/ci/reports/test_reports.rb
+++ b/lib/gitlab/ci/reports/test_reports.rb
@@ -43,9 +43,7 @@ module Gitlab
end
def suite_errors
- test_suites.each_with_object({}) do |(name, suite), errors|
- errors[suite.name] = suite.suite_error if suite.suite_error
- end
+ test_suites.transform_values(&:suite_error).compact
end
TestCase::STATUS_TYPES.each do |status_type|
diff --git a/lib/gitlab/ci/reports/test_suite.rb b/lib/gitlab/ci/reports/test_suite.rb
index 28b81e7a471..5ee779227ec 100644
--- a/lib/gitlab/ci/reports/test_suite.rb
+++ b/lib/gitlab/ci/reports/test_suite.rb
@@ -28,7 +28,7 @@ module Gitlab
def total_count
return 0 if suite_error
- test_cases.values.sum(&:count)
+ [success_count, failed_count, skipped_count, error_count].sum
end
# rubocop: enable CodeReuse/ActiveRecord
diff --git a/lib/gitlab/ci/reports/test_suite_summary.rb b/lib/gitlab/ci/reports/test_suite_summary.rb
index f9b0bedb712..32b06d0ad49 100644
--- a/lib/gitlab/ci/reports/test_suite_summary.rb
+++ b/lib/gitlab/ci/reports/test_suite_summary.rb
@@ -4,45 +4,54 @@ module Gitlab
module Ci
module Reports
class TestSuiteSummary
- attr_reader :results
-
- def initialize(results)
- @results = results
+ def initialize(build_report_results)
+ @build_report_results = build_report_results
end
def name
- @name ||= results.first.tests_name
+ @name ||= @build_report_results.first.tests_name
end
# rubocop: disable CodeReuse/ActiveRecord
def build_ids
- results.pluck(:build_id)
+ @build_report_results.pluck(:build_id)
end
def total_time
- @total_time ||= results.sum(&:tests_duration)
+ @total_time ||= @build_report_results.sum(&:tests_duration)
end
def success_count
- @success_count ||= results.sum(&:tests_success)
+ @success_count ||= @build_report_results.sum(&:tests_success)
end
def failed_count
- @failed_count ||= results.sum(&:tests_failed)
+ @failed_count ||= @build_report_results.sum(&:tests_failed)
end
def skipped_count
- @skipped_count ||= results.sum(&:tests_skipped)
+ @skipped_count ||= @build_report_results.sum(&:tests_skipped)
end
def error_count
- @error_count ||= results.sum(&:tests_errored)
+ @error_count ||= @build_report_results.sum(&:tests_errored)
end
def total_count
@total_count ||= [success_count, failed_count, skipped_count, error_count].sum
end
# rubocop: disable CodeReuse/ActiveRecord
+
+ def to_h
+ {
+ time: total_time,
+ count: total_count,
+ success: success_count,
+ failed: failed_count,
+ skipped: skipped_count,
+ error: error_count
+ }
+ end
end
end
end