Class: Fastlane::Actions::XcresulttoolCompareAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/xcresulttool/actions/xcresulttool_compare_action.rb

Class Method Summary collapse

Class Method Details

.authorsObject



45
46
47
# File 'lib/fastlane/plugin/xcresulttool/actions/xcresulttool_compare_action.rb', line 45

def self.authors
  ["crazymanish"]
end

.available_optionsObject



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/fastlane/plugin/xcresulttool/actions/xcresulttool_compare_action.rb', line 57

def self.available_options
  [
    FastlaneCore::ConfigItem.new(
      key: :result_bundle_path,
      description: "Path to the .xcresult bundle to be compared",
      optional: false,
      type: String
    ),
    FastlaneCore::ConfigItem.new(
      key: :baseline_path,
      description: "Path to the baseline .xcresult bundle for comparison",
      optional: false,
      type: String
    ),
    FastlaneCore::ConfigItem.new(
      key: :summary,
      description: "Include the differential summary info in the output",
      optional: true,
      default_value: true,
      is_string: false
    ),
    FastlaneCore::ConfigItem.new(
      key: :test_failures,
      description: "Include the differential test failures info in the output",
      optional: true,
      default_value: false,
      is_string: false
    ),
    FastlaneCore::ConfigItem.new(
      key: :tests,
      description: "Include the differential tests info in the output",
      optional: true,
      default_value: false,
      is_string: false
    ),
    FastlaneCore::ConfigItem.new(
      key: :build_warnings,
      description: "Include the differential build warnings info in the output",
      optional: true,
      default_value: false,
      is_string: false
    ),
    FastlaneCore::ConfigItem.new(
      key: :analyzer_issues,
      description: "Include the differential analyzer issues info in the output",
      optional: true,
      default_value: false,
      is_string: false
    ),
    FastlaneCore::ConfigItem.new(
      key: :format,
      description: "Output format (json, flat, human-readable)",
      optional: true,
      default_value: "json",
      type: String
    ),
    FastlaneCore::ConfigItem.new(
      key: :format_supported,
      description: "Whether the format option is supported by your version of xcresulttool (newer versions only)",
      optional: true,
      default_value: false,
      is_string: false
    ),
    FastlaneCore::ConfigItem.new(
      key: :output_path,
      description: "Path to save comparison results",
      optional: true,
      type: String
    ),
    FastlaneCore::ConfigItem.new(
      key: :verbose,
      description: "Enable verbose output",
      optional: true,
      default_value: false,
      is_string: false
    )
  ]
end

.categoryObject



160
161
162
# File 'lib/fastlane/plugin/xcresulttool/actions/xcresulttool_compare_action.rb', line 160

def self.category
  :testing
end

.descriptionObject



41
42
43
# File 'lib/fastlane/plugin/xcresulttool/actions/xcresulttool_compare_action.rb', line 41

def self.description
  "Compare two Result Bundles using xcresulttool"
end

.detailsObject



53
54
55
# File 'lib/fastlane/plugin/xcresulttool/actions/xcresulttool_compare_action.rb', line 53

def self.details
  "This action compares two Xcode result bundles (.xcresult) and reports differences using Apple's xcresulttool compare subcommand"
end

.example_codeObject



140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/fastlane/plugin/xcresulttool/actions/xcresulttool_compare_action.rb', line 140

def self.example_code
  [
    'xcresulttool_compare(
      result_bundle_path: "path/to/Test.xcresult",
      baseline_path: "path/to/Baseline.xcresult",
      summary: true,
      test_failures: true
    )',
    'xcresulttool_compare(
      result_bundle_path: "path/to/Test.xcresult",
      baseline_path: "path/to/Baseline.xcresult",
      summary: true,
      tests: true,
      build_warnings: true,
      analyzer_issues: true,
      output_path: "comparison_results.txt"
    )'
  ]
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


136
137
138
# File 'lib/fastlane/plugin/xcresulttool/actions/xcresulttool_compare_action.rb', line 136

def self.is_supported?(platform)
  [:ios, :mac].include?(platform)
end

.return_valueObject



49
50
51
# File 'lib/fastlane/plugin/xcresulttool/actions/xcresulttool_compare_action.rb', line 49

def self.return_value
  "The output of the xcresulttool compare command as a string, or nil if output_path is specified"
end

.run(params) ⇒ Object



7
8
9
10
11
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
# File 'lib/fastlane/plugin/xcresulttool/actions/xcresulttool_compare_action.rb', line 7

def self.run(params)
  args = ["compare"]
  
  # Validate result bundle paths
  Helper::XcresulttoolHelper.validate_result_bundle_path(params[:result_bundle_path])
  Helper::XcresulttoolHelper.validate_result_bundle_path(params[:baseline_path])
  
  # Add required arguments
  args << params[:result_bundle_path] # Use positional argument for comparison path
  args << "--baseline-path" << params[:baseline_path]
  
  # Add comparison output options
  args << "--summary" if params[:summary]
  args << "--test-failures" if params[:test_failures]
  args << "--tests" if params[:tests]
  args << "--build-warnings" if params[:build_warnings]
  args << "--analyzer-issues" if params[:analyzer_issues]
  
  # Add optional output format and path if supported
  args << "--format" << params[:format] if params[:format] && params[:format_supported]
  args << "--output-path" << params[:output_path] if params[:output_path]
  
  args << "--verbose" if params[:verbose]
  
  # Execute the command
  result = Helper::XcresulttoolHelper.execute_command(args)
  
  if params[:output_path]
    UI.success("Comparison results saved to #{params[:output_path]}")
  else
    return result
  end
end