Class: GitlabQuality::TestTooling::KnapsackReports::SpecRunTimeReport

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab_quality/test_tooling/knapsack_reports/spec_run_time_report.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project:, expected_report_path:, actual_report_path:, token: '') ⇒ SpecRunTimeReport

Returns a new instance of SpecRunTimeReport.



11
12
13
14
15
16
# File 'lib/gitlab_quality/test_tooling/knapsack_reports/spec_run_time_report.rb', line 11

def initialize(project:, expected_report_path:, actual_report_path:, token: '')
  @project = project
  @expected_report = parse(expected_report_path)
  @actual_report = parse(actual_report_path)
  @token = token
end

Instance Attribute Details

#actual_reportObject (readonly)

Returns the value of attribute actual_report.



9
10
11
# File 'lib/gitlab_quality/test_tooling/knapsack_reports/spec_run_time_report.rb', line 9

def actual_report
  @actual_report
end

#expected_reportObject (readonly)

Returns the value of attribute expected_report.



9
10
11
# File 'lib/gitlab_quality/test_tooling/knapsack_reports/spec_run_time_report.rb', line 9

def expected_report
  @expected_report
end

#projectObject (readonly)

Returns the value of attribute project.



9
10
11
# File 'lib/gitlab_quality/test_tooling/knapsack_reports/spec_run_time_report.rb', line 9

def project
  @project
end

Instance Method Details

#filtered_reportObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/gitlab_quality/test_tooling/knapsack_reports/spec_run_time_report.rb', line 18

def filtered_report
  @filtered_report = actual_report.keys.filter_map do |spec_file|
    expected_run_time = expected_report[spec_file]
    actual_run_time = actual_report[spec_file]

    if expected_run_time.nil?
      puts "#{spec_file} missing from the expected Knapsack report, skipping."
      next
    end

    spec_run_time = SpecRunTime.new(
      token: token,
      project: project,
      file: spec_file,
      expected: expected_run_time,
      actual: actual_run_time,
      expected_suite_duration: expected_test_suite_run_time_total,
      actual_suite_duration: actual_test_suite_run_time_total
    )

    spec_run_time if spec_run_time.should_report?
  end
end