Module: Ace::TestRunner::Molecules::FailedPackageReporter

Defined in:
lib/ace/test_runner/molecules/failed_package_reporter.rb

Class Method Summary collapse

Class Method Details

.format_for_display(package) ⇒ Object



12
13
14
15
16
17
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/ace/test_runner/molecules/failed_package_reporter.rb', line 12

def format_for_display(package)
  path = extract_path(package)
  report_root = extract_report_root(package)
  package_name = extract_name(package) || File.basename(path)
  report_path = Atoms::ReportPathResolver.call(
    path,
    report_root: report_root,
    package_name: package_name
  )

  if report_path
    begin
      relative_path = Pathname.new(report_path).relative_path_from(Dir.pwd)
      "    → See #{relative_path}"
    rescue => e
      warn "Failed to calculate relative path: #{e.message}" if debug_mode?
      "    → See #{report_path}"
    end
  else
    reports_path = fallback_reports_path(path, report_root, package_name)
    begin
      relative_path = Pathname.new(reports_path).relative_path_from(Dir.pwd)
      "    → Check #{relative_path}/ for details"
    rescue => e
      warn "Failed to calculate relative path: #{e.message}" if debug_mode?
      "    → Check #{reports_path}/ for details"
    end
  end
end

.format_for_markdown(package) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/ace/test_runner/molecules/failed_package_reporter.rb', line 42

def format_for_markdown(package)
  path = extract_path(package)
  report_root = extract_report_root(package)
  package_name = extract_name(package) || File.basename(path)
  report_path = Atoms::ReportPathResolver.call(
    path,
    report_root: report_root,
    package_name: package_name
  )

  if report_path
    relative_report_path = relative_or_absolute(report_path)
    "- Report: `#{relative_report_path}`"
  else
    reports_path = fallback_reports_path(path, report_root, package_name)
    relative_reports_path = relative_or_absolute(reports_path)
    "- Report: Check `#{relative_reports_path}/` for details"
  end
end