Module: Ace::TestRunner::Atoms::ReportPathResolver

Defined in:
lib/ace/test_runner/atoms/report_path_resolver.rb

Constant Summary collapse

REPORT_PRIORITY =
[
  "failures.json",
  "summary.json",
  "report.md",
  "report.json",
  "raw_output.txt"
].freeze

Class Method Summary collapse

Class Method Details

.call(package_path, report_root: nil, package_name: nil) ⇒ String?

Resolves the best available report file path for a package

The resolver checks for report files in the following priority order:

1. failures.json - Detailed failure information
2. summary.json - Summary of test results
3. report.md - Markdown formatted report
4. report.json - JSON formatted report
5. raw_output.txt - Raw test output

Parameters:

  • package_path (String)

    The root path of the package

  • report_root (String, nil) (defaults to: nil)

    Centralized report root

  • package_name (String, nil) (defaults to: nil)

    Package name used for centralized lookup

Returns:

  • (String, nil)

    The absolute path to the best available report file, or nil if none exist



30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/ace/test_runner/atoms/report_path_resolver.rb', line 30

def call(package_path, report_root: nil, package_name: nil)
  return nil unless package_path && Dir.exist?(package_path)

  reports_dir = report_directory(package_path, report_root: report_root, package_name: package_name)
  return nil unless reports_dir

  REPORT_PRIORITY.each do |filename|
    path = File.join(reports_dir, filename)
    return path if File.exist?(path)
  end

  nil
end

.candidates(package_path, report_root, package_name) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/ace/test_runner/atoms/report_path_resolver.rb', line 52

def candidates(package_path, report_root, package_name)
  dirs = []

  if report_root
    short_name = package_name.to_s.sub(/\Aace-/, "")
    short_name = File.basename(package_path).sub(/\Aace-/, "") if short_name.empty?
    dirs << File.join(report_root, short_name, "latest")
  end

  dirs << File.join(package_path, "test-reports", "latest")
  dirs.uniq
end

.report_directory(package_path, report_root: nil, package_name: nil) ⇒ Object



44
45
46
47
48
49
50
# File 'lib/ace/test_runner/atoms/report_path_resolver.rb', line 44

def report_directory(package_path, report_root: nil, package_name: nil)
  candidates(package_path, report_root, package_name).each do |dir|
    return dir if Dir.exist?(dir)
  end

  nil
end