Class: GitlabQuality::TestTooling::CodeCoverage::Artifacts
- Inherits:
-
Object
- Object
- GitlabQuality::TestTooling::CodeCoverage::Artifacts
- Defined in:
- lib/gitlab_quality/test_tooling/code_coverage/artifacts.rb
Instance Method Summary collapse
-
#coverage_report ⇒ String
Loads the LCOV coverage report file.
-
#initialize(coverage_report:, test_map:, test_reports:) ⇒ Artifacts
constructor
Loads coverage artifacts from the filesystem.
-
#test_map ⇒ Hash
Loads and parses the test map file (supports gzipped or plain JSON).
-
#test_reports ⇒ Array<Hash>
Loads and parses test JSON report files (RSpec or Jest).
Constructor Details
#initialize(coverage_report:, test_map:, test_reports:) ⇒ Artifacts
Loads coverage artifacts from the filesystem
18 19 20 21 22 23 24 |
# File 'lib/gitlab_quality/test_tooling/code_coverage/artifacts.rb', line 18 def initialize(coverage_report:, test_map:, test_reports:) raise ArgumentError, "test_reports cannot be blank" if test_reports.blank? @test_reports_glob = test_reports @coverage_report_path = coverage_report @test_map_path = test_map end |
Instance Method Details
#coverage_report ⇒ String
Loads the LCOV coverage report file
42 43 44 |
# File 'lib/gitlab_quality/test_tooling/code_coverage/artifacts.rb', line 42 def coverage_report @coverage_report ||= read_coverage_reports end |
#test_map ⇒ Hash
Loads and parses the test map file (supports gzipped or plain JSON)
50 51 52 |
# File 'lib/gitlab_quality/test_tooling/code_coverage/artifacts.rb', line 50 def test_map @test_map ||= fetch_test_map end |
#test_reports ⇒ Array<Hash>
Loads and parses test JSON report files (RSpec or Jest)
30 31 32 33 34 35 36 |
# File 'lib/gitlab_quality/test_tooling/code_coverage/artifacts.rb', line 30 def test_reports @test_report_files ||= test_reports_paths.map do |report_path| JSON.parse(File.read(report_path)) rescue JSON::ParserError => e raise "Invalid JSON in test report file #{report_path}: #{e.}" end end |