fastlane 2.199.0 → 2.201.0.rc3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -1
  3. data/README.md +92 -92
  4. data/deliver/lib/deliver/app_screenshot.rb +7 -0
  5. data/fastlane/lib/fastlane/.version.rb.swp +0 -0
  6. data/fastlane/lib/fastlane/actions/download_dsyms.rb +1 -1
  7. data/fastlane/lib/fastlane/actions/get_version_number.rb +1 -0
  8. data/fastlane/lib/fastlane/actions/trainer.rb +49 -0
  9. data/fastlane/lib/fastlane/helper/xcodebuild_formatter_helper.rb +9 -0
  10. data/fastlane/lib/fastlane/tools.rb +2 -1
  11. data/fastlane/lib/fastlane/version.rb +1 -1
  12. data/fastlane/swift/Actions.swift +1 -1
  13. data/fastlane/swift/Appfile.swift +1 -1
  14. data/fastlane/swift/ArgumentProcessor.swift +1 -1
  15. data/fastlane/swift/ControlCommand.swift +1 -1
  16. data/fastlane/swift/Deliverfile.swift +2 -2
  17. data/fastlane/swift/DeliverfileProtocol.swift +2 -2
  18. data/fastlane/swift/Fastlane.swift +11 -3
  19. data/fastlane/swift/Gymfile.swift +2 -2
  20. data/fastlane/swift/GymfileProtocol.swift +2 -2
  21. data/fastlane/swift/LaneFileProtocol.swift +1 -1
  22. data/fastlane/swift/MainProcess.swift +1 -1
  23. data/fastlane/swift/Matchfile.swift +2 -2
  24. data/fastlane/swift/MatchfileProtocol.swift +2 -2
  25. data/fastlane/swift/OptionalConfigValue.swift +1 -1
  26. data/fastlane/swift/Plugins.swift +1 -1
  27. data/fastlane/swift/Precheckfile.swift +2 -2
  28. data/fastlane/swift/PrecheckfileProtocol.swift +2 -2
  29. data/fastlane/swift/RubyCommand.swift +1 -1
  30. data/fastlane/swift/RubyCommandable.swift +1 -1
  31. data/fastlane/swift/Runner.swift +1 -1
  32. data/fastlane/swift/RunnerArgument.swift +1 -1
  33. data/fastlane/swift/Scanfile.swift +2 -2
  34. data/fastlane/swift/ScanfileProtocol.swift +2 -2
  35. data/fastlane/swift/Screengrabfile.swift +2 -2
  36. data/fastlane/swift/ScreengrabfileProtocol.swift +2 -2
  37. data/fastlane/swift/Snapshotfile.swift +2 -2
  38. data/fastlane/swift/SnapshotfileProtocol.swift +2 -2
  39. data/fastlane/swift/SocketClient.swift +1 -1
  40. data/fastlane/swift/SocketClientDelegateProtocol.swift +1 -1
  41. data/fastlane/swift/SocketResponse.swift +1 -1
  42. data/fastlane/swift/formatting/Brewfile.lock.json +3 -3
  43. data/fastlane/swift/main.swift +1 -1
  44. data/fastlane_core/lib/fastlane_core/ipa_file_analyser.rb +10 -5
  45. data/fastlane_core/lib/fastlane_core/itunes_transporter.rb +4 -1
  46. data/gym/lib/gym/generators/build_command_generator.rb +68 -22
  47. data/gym/lib/gym/options.rb +17 -5
  48. data/scan/lib/scan/.detect_values.rb.swp +0 -0
  49. data/scan/lib/scan/.options.rb.swp +0 -0
  50. data/scan/lib/scan/.runner.rb.swp +0 -0
  51. data/scan/lib/scan/options.rb +25 -5
  52. data/scan/lib/scan/runner.rb +115 -14
  53. data/scan/lib/scan/test_command_generator.rb +55 -5
  54. data/snapshot/lib/snapshot/.collector.rb.swp +0 -0
  55. data/snapshot/lib/snapshot/options.rb +23 -7
  56. data/snapshot/lib/snapshot/test_command_generator.rb +37 -2
  57. data/spaceship/lib/spaceship/connect_api/models/app.rb +43 -0
  58. data/spaceship/lib/spaceship/connect_api/models/app_info.rb +1 -0
  59. data/spaceship/lib/spaceship/connect_api/models/app_screenshot_set.rb +2 -0
  60. data/spaceship/lib/spaceship/connect_api/models/review_submission.rb +73 -0
  61. data/spaceship/lib/spaceship/connect_api/models/review_submission_item.rb +40 -0
  62. data/spaceship/lib/spaceship/connect_api/tunes/tunes.rb +83 -0
  63. data/spaceship/lib/spaceship/connect_api.rb +2 -0
  64. data/supply/lib/supply/options.rb +8 -0
  65. data/supply/lib/supply/uploader.rb +6 -2
  66. data/trainer/lib/assets/.junit.xml.erb.swp +0 -0
  67. data/trainer/lib/assets/junit.xml.erb +20 -0
  68. data/trainer/lib/trainer/.junit_generator.rb.swp +0 -0
  69. data/trainer/lib/trainer/.test_parser.rb.swp +0 -0
  70. data/trainer/lib/trainer/commands_generator.rb +51 -0
  71. data/trainer/lib/trainer/junit_generator.rb +31 -0
  72. data/trainer/lib/trainer/module.rb +10 -0
  73. data/trainer/lib/trainer/options.rb +55 -0
  74. data/trainer/lib/trainer/test_parser.rb +352 -0
  75. data/trainer/lib/trainer/xcresult.rb +403 -0
  76. data/trainer/lib/trainer.rb +7 -0
  77. metadata +42 -22
@@ -1,5 +1,5 @@
1
1
  // OptionalConfigValue.swift
2
- // Copyright (c) 2021 FastlaneTools
2
+ // Copyright (c) 2022 FastlaneTools
3
3
 
4
4
  //
5
5
  // ** NOTE **
@@ -1,5 +1,5 @@
1
1
  // Plugins.swift
2
- // Copyright (c) 2021 FastlaneTools
2
+ // Copyright (c) 2022 FastlaneTools
3
3
 
4
4
  // This autogenerated file will be overwritten or replaced when installing/updating plugins or running "fastlane generate_swift"
5
5
  //
@@ -1,5 +1,5 @@
1
1
  // Precheckfile.swift
2
- // Copyright (c) 2021 FastlaneTools
2
+ // Copyright (c) 2022 FastlaneTools
3
3
 
4
4
  // This class is automatically included in FastlaneRunner during build
5
5
 
@@ -17,4 +17,4 @@ public class Precheckfile: PrecheckfileProtocol {
17
17
  // during the `init` process, and you won't see this message
18
18
  }
19
19
 
20
- // Generated with fastlane 2.199.0
20
+ // Generated with fastlane 2.200.0
@@ -1,5 +1,5 @@
1
1
  // PrecheckfileProtocol.swift
2
- // Copyright (c) 2021 FastlaneTools
2
+ // Copyright (c) 2022 FastlaneTools
3
3
 
4
4
  public protocol PrecheckfileProtocol: class {
5
5
  /// Path to your App Store Connect API Key JSON file (https://docs.fastlane.tools/app-store-connect-api/#using-fastlane-api-key-json-file)
@@ -52,4 +52,4 @@ public extension PrecheckfileProtocol {
52
52
 
53
53
  // Please don't remove the lines below
54
54
  // They are used to detect outdated files
55
- // FastlaneRunnerAPIVersion [0.9.85]
55
+ // FastlaneRunnerAPIVersion [0.9.86]
@@ -1,5 +1,5 @@
1
1
  // RubyCommand.swift
2
- // Copyright (c) 2021 FastlaneTools
2
+ // Copyright (c) 2022 FastlaneTools
3
3
 
4
4
  //
5
5
  // ** NOTE **
@@ -1,5 +1,5 @@
1
1
  // RubyCommandable.swift
2
- // Copyright (c) 2021 FastlaneTools
2
+ // Copyright (c) 2022 FastlaneTools
3
3
 
4
4
  //
5
5
  // ** NOTE **
@@ -1,5 +1,5 @@
1
1
  // Runner.swift
2
- // Copyright (c) 2021 FastlaneTools
2
+ // Copyright (c) 2022 FastlaneTools
3
3
 
4
4
  //
5
5
  // ** NOTE **
@@ -1,5 +1,5 @@
1
1
  // RunnerArgument.swift
2
- // Copyright (c) 2021 FastlaneTools
2
+ // Copyright (c) 2022 FastlaneTools
3
3
 
4
4
  //
5
5
  // ** NOTE **
@@ -1,5 +1,5 @@
1
1
  // Scanfile.swift
2
- // Copyright (c) 2021 FastlaneTools
2
+ // Copyright (c) 2022 FastlaneTools
3
3
 
4
4
  // This class is automatically included in FastlaneRunner during build
5
5
 
@@ -17,4 +17,4 @@ public class Scanfile: ScanfileProtocol {
17
17
  // during the `init` process, and you won't see this message
18
18
  }
19
19
 
20
- // Generated with fastlane 2.199.0
20
+ // Generated with fastlane 2.200.0
@@ -1,5 +1,5 @@
1
1
  // ScanfileProtocol.swift
2
- // Copyright (c) 2021 FastlaneTools
2
+ // Copyright (c) 2022 FastlaneTools
3
3
 
4
4
  public protocol ScanfileProtocol: class {
5
5
  /// Path to the workspace file
@@ -296,4 +296,4 @@ public extension ScanfileProtocol {
296
296
 
297
297
  // Please don't remove the lines below
298
298
  // They are used to detect outdated files
299
- // FastlaneRunnerAPIVersion [0.9.97]
299
+ // FastlaneRunnerAPIVersion [0.9.98]
@@ -1,5 +1,5 @@
1
1
  // Screengrabfile.swift
2
- // Copyright (c) 2021 FastlaneTools
2
+ // Copyright (c) 2022 FastlaneTools
3
3
 
4
4
  // This class is automatically included in FastlaneRunner during build
5
5
 
@@ -17,4 +17,4 @@ public class Screengrabfile: ScreengrabfileProtocol {
17
17
  // during the `init` process, and you won't see this message
18
18
  }
19
19
 
20
- // Generated with fastlane 2.199.0
20
+ // Generated with fastlane 2.200.0
@@ -1,5 +1,5 @@
1
1
  // ScreengrabfileProtocol.swift
2
- // Copyright (c) 2021 FastlaneTools
2
+ // Copyright (c) 2022 FastlaneTools
3
3
 
4
4
  public protocol ScreengrabfileProtocol: class {
5
5
  /// Path to the root of your Android SDK installation, e.g. ~/tools/android-sdk-macosx
@@ -96,4 +96,4 @@ public extension ScreengrabfileProtocol {
96
96
 
97
97
  // Please don't remove the lines below
98
98
  // They are used to detect outdated files
99
- // FastlaneRunnerAPIVersion [0.9.87]
99
+ // FastlaneRunnerAPIVersion [0.9.88]
@@ -1,5 +1,5 @@
1
1
  // Snapshotfile.swift
2
- // Copyright (c) 2021 FastlaneTools
2
+ // Copyright (c) 2022 FastlaneTools
3
3
 
4
4
  // This class is automatically included in FastlaneRunner during build
5
5
 
@@ -17,4 +17,4 @@ public class Snapshotfile: SnapshotfileProtocol {
17
17
  // during the `init` process, and you won't see this message
18
18
  }
19
19
 
20
- // Generated with fastlane 2.199.0
20
+ // Generated with fastlane 2.200.0
@@ -1,5 +1,5 @@
1
1
  // SnapshotfileProtocol.swift
2
- // Copyright (c) 2021 FastlaneTools
2
+ // Copyright (c) 2022 FastlaneTools
3
3
 
4
4
  public protocol SnapshotfileProtocol: class {
5
5
  /// Path the workspace file
@@ -200,4 +200,4 @@ public extension SnapshotfileProtocol {
200
200
 
201
201
  // Please don't remove the lines below
202
202
  // They are used to detect outdated files
203
- // FastlaneRunnerAPIVersion [0.9.81]
203
+ // FastlaneRunnerAPIVersion [0.9.82]
@@ -1,5 +1,5 @@
1
1
  // SocketClient.swift
2
- // Copyright (c) 2021 FastlaneTools
2
+ // Copyright (c) 2022 FastlaneTools
3
3
 
4
4
  //
5
5
  // ** NOTE **
@@ -1,5 +1,5 @@
1
1
  // SocketClientDelegateProtocol.swift
2
- // Copyright (c) 2021 FastlaneTools
2
+ // Copyright (c) 2022 FastlaneTools
3
3
 
4
4
  //
5
5
  // ** NOTE **
@@ -1,5 +1,5 @@
1
1
  // SocketResponse.swift
2
- // Copyright (c) 2021 FastlaneTools
2
+ // Copyright (c) 2022 FastlaneTools
3
3
 
4
4
  //
5
5
  // ** NOTE **
@@ -56,11 +56,11 @@
56
56
  "macOS": "11.6"
57
57
  },
58
58
  "monterey": {
59
- "HOMEBREW_VERSION": "3.3.7-38-g6295b08",
59
+ "HOMEBREW_VERSION": "3.3.10-21-g3ba6afb",
60
60
  "HOMEBREW_PREFIX": "/opt/homebrew",
61
- "Homebrew/homebrew-core": "e340d22f5ef83cf4acc489b34e2478426dbf53b9",
61
+ "Homebrew/homebrew-core": "54f307bcd04cec374c7fd3f22fe7e6b13f1ad783",
62
62
  "CLT": "13.1.0.0.1.1633545042",
63
- "Xcode": "13.1",
63
+ "Xcode": "13.2.1",
64
64
  "macOS": "12.0.1"
65
65
  }
66
66
  }
@@ -1,5 +1,5 @@
1
1
  // main.swift
2
- // Copyright (c) 2021 FastlaneTools
2
+ // Copyright (c) 2022 FastlaneTools
3
3
 
4
4
  //
5
5
  // ** NOTE **
@@ -73,12 +73,17 @@ module FastlaneCore
73
73
  end
74
74
 
75
75
  def self.fetch_info_plist_with_unzip(path)
76
- list, error, = Open3.capture3("unzip", "-Z", "-1", path)
76
+ entry, error, = Open3.capture3("unzip", "-Z", "-1", path, "*Payload/*.app/Info.plist")
77
+
78
+ # unzip can return multiple Info.plist files if is an embedded app bundle (a WatchKit app)
79
+ # - ContainsWatchApp/Payload/Sample.app/Watch/Sample WatchKit App.app/Info.plist
80
+ # - ContainsWatchApp/Payload/Sample.app/Info.plist
81
+ #
82
+ # we can determine the main Info.plist by the shortest path
83
+ entry = entry.lines.map(&:chomp).min_by(&:size)
84
+
77
85
  UI.command_output(error) unless error.empty?
78
- return nil if list.empty?
79
- entry = list.chomp.split("\n").find do |e|
80
- File.fnmatch("**/Payload/*.app/Info.plist", e, File::FNM_PATHNAME)
81
- end
86
+ return nil if entry.nil? || entry.empty?
82
87
  data, error, = Open3.capture3("unzip", "-p", path, entry)
83
88
  UI.command_output(error) unless error.empty?
84
89
  return nil if data.empty?
@@ -2,6 +2,7 @@ require 'shellwords'
2
2
  require 'tmpdir'
3
3
  require 'fileutils'
4
4
  require 'credentials_manager/account_manager'
5
+ require 'securerandom'
5
6
 
6
7
  require_relative 'features'
7
8
  require_relative 'helper'
@@ -501,7 +502,9 @@ module FastlaneCore
501
502
 
502
503
  actual_dir = if can_use_asset_path && !force_itmsp
503
504
  # The asset gets deleted upon completion so copying to a temp directory
504
- tmp_asset_path = File.join(Dir.tmpdir, File.basename(asset_path))
505
+ # (with randomized filename, for multibyte-mixed filename upload fails)
506
+ new_file_name = "#{SecureRandom.uuid}#{File.extname(asset_path)}"
507
+ tmp_asset_path = File.join(Dir.tmpdir, new_file_name)
505
508
  FileUtils.cp(asset_path, tmp_asset_path)
506
509
  tmp_asset_path
507
510
  elsif package_path
@@ -43,7 +43,7 @@ module Gym
43
43
  options << "-scmProvider system"
44
44
  end
45
45
  options << config[:xcargs] if config[:xcargs]
46
- options << "OTHER_SWIFT_FLAGS=\"-Xfrontend -debug-time-function-bodies\"" if config[:analyze_build_time]
46
+ options << "OTHER_SWIFT_FLAGS=\"\\\$(value) -Xfrontend -debug-time-function-bodies\"" if config[:analyze_build_time]
47
47
 
48
48
  options
49
49
  end
@@ -72,32 +72,78 @@ module Gym
72
72
  def pipe
73
73
  pipe = []
74
74
  pipe << "| tee #{xcodebuild_log_path.shellescape}"
75
- unless Gym.config[:disable_xcpretty]
76
- formatter = Gym.config[:xcpretty_formatter]
77
- pipe << "| xcpretty"
78
- pipe << " --test" if Gym.config[:xcpretty_test_format]
79
- pipe << " --no-color" if Helper.colors_disabled?
80
- pipe << " --formatter " if formatter
81
- pipe << formatter if formatter
82
- pipe << "--utf" if Gym.config[:xcpretty_utf]
83
- report_output_junit = Gym.config[:xcpretty_report_junit]
84
- report_output_html = Gym.config[:xcpretty_report_html]
85
- report_output_json = Gym.config[:xcpretty_report_json]
86
- if report_output_junit
87
- pipe << " --report junit --output "
88
- pipe << report_output_junit.shellescape
89
- elsif report_output_html
90
- pipe << " --report html --output "
91
- pipe << report_output_html.shellescape
92
- elsif report_output_json
93
- pipe << " --report json-compilation-database --output "
94
- pipe << report_output_json.shellescape
95
- end
75
+
76
+ formatter = Gym.config[:xcodebuild_formatter].chomp
77
+ options = legacy_xcpretty_options
78
+
79
+ if Gym.config[:disable_xcpretty] || formatter == ''
80
+ UI.verbose("Not using an xcodebuild formatter")
81
+ elsif !options.empty?
82
+ UI.important("Detected legacy xcpretty being used so formatting wth xcpretty")
83
+ UI.important("Option(s) used: #{options.join(', ')}")
84
+ pipe += pipe_xcpretty
85
+ elsif formatter == 'xcpretty'
86
+ pipe += pipe_xcpretty
87
+ elsif formatter == 'xcbeautify'
88
+ pipe += pipe_xcbeautify
89
+ else
90
+ pipe << "| #{formatter}"
96
91
  end
92
+
97
93
  pipe << "> /dev/null" if Gym.config[:suppress_xcode_output]
98
94
  pipe
99
95
  end
100
96
 
97
+ def pipe_xcbeautify
98
+ pipe = ['| xcbeautify']
99
+
100
+ if FastlaneCore::Helper.colors_disabled?
101
+ pipe << '--disable-colored-output'
102
+ end
103
+
104
+ return pipe
105
+ end
106
+
107
+ def legacy_xcpretty_options
108
+ options = []
109
+
110
+ options << "xcpretty_test_format" if Gym.config[:xcpretty_test_format]
111
+ options << "xcpretty_formatter" if Gym.config[:xcpretty_formatter]
112
+ options << "xcpretty_report_junit" if Gym.config[:xcpretty_report_junit]
113
+ options << "xcpretty_report_html" if Gym.config[:xcpretty_report_html]
114
+ options << "xcpretty_report_json" if Gym.config[:xcpretty_report_json]
115
+ options << "xcpretty_utf" if Gym.config[:xcpretty_utf]
116
+
117
+ return options
118
+ end
119
+
120
+ def pipe_xcpretty
121
+ pipe = []
122
+
123
+ formatter = Gym.config[:xcpretty_formatter]
124
+ pipe << "| xcpretty"
125
+ pipe << " --test" if Gym.config[:xcpretty_test_format]
126
+ pipe << " --no-color" if Helper.colors_disabled?
127
+ pipe << " --formatter " if formatter
128
+ pipe << formatter if formatter
129
+ pipe << "--utf" if Gym.config[:xcpretty_utf]
130
+ report_output_junit = Gym.config[:xcpretty_report_junit]
131
+ report_output_html = Gym.config[:xcpretty_report_html]
132
+ report_output_json = Gym.config[:xcpretty_report_json]
133
+ if report_output_junit
134
+ pipe << " --report junit --output "
135
+ pipe << report_output_junit.shellescape
136
+ elsif report_output_html
137
+ pipe << " --report html --output "
138
+ pipe << report_output_html.shellescape
139
+ elsif report_output_json
140
+ pipe << " --report json-compilation-database --output "
141
+ pipe << report_output_json.shellescape
142
+ end
143
+
144
+ pipe
145
+ end
146
+
101
147
  def post_build
102
148
  commands = []
103
149
  commands << %{grep -E '^[0-9.]+ms' #{xcodebuild_log_path.shellescape} | grep -vE '^0\.[0-9]' | sort -nr > culprits.txt} if Gym.config[:analyze_build_time]
@@ -1,4 +1,5 @@
1
1
  require 'fastlane_core/configuration/config_item'
2
+ require 'fastlane/helper/xcodebuild_formatter_helper'
2
3
  require 'credentials_manager/appfile_config'
3
4
  require_relative 'module'
4
5
 
@@ -230,8 +231,18 @@ module Gym
230
231
  description: "Suppress the output of xcodebuild to stdout. Output is still saved in buildlog_path",
231
232
  optional: true,
232
233
  type: Boolean),
234
+
235
+ FastlaneCore::ConfigItem.new(key: :xcodebuild_formatter,
236
+ env_names: ["GYM_XCODEBUILD_FORMATTER", "FASTLANE_XCODEBUILD_FORMATTER"],
237
+ description: "xcodebuild formatter to use (ex: 'xcbeautify', 'xcbeautify --quieter', 'xcpretty', 'xcpretty -test'). Use empty string (ex: '') to disable any formatter",
238
+ type: String,
239
+ default_value: Fastlane::Helper::XcodebuildFormatterHelper.xcbeautify_installed? ? 'xcbeautify' : 'xcpretty',
240
+ default_value_dynamic: true),
241
+
242
+ # xcpretty
233
243
  FastlaneCore::ConfigItem.new(key: :disable_xcpretty,
234
244
  env_name: "DISABLE_XCPRETTY",
245
+ deprecated: "Use `xcodebuild_formatter: ''` instead",
235
246
  description: "Disable xcpretty formatting of build output",
236
247
  optional: true,
237
248
  type: Boolean),
@@ -259,16 +270,17 @@ module Gym
259
270
  env_name: "XCPRETTY_REPORT_JSON",
260
271
  description: "Have xcpretty create a JSON compilation database at the provided path",
261
272
  optional: true),
262
- FastlaneCore::ConfigItem.new(key: :analyze_build_time,
263
- env_name: "GYM_ANALYZE_BUILD_TIME",
264
- description: "Analyze the project build time and store the output in 'culprits.txt' file",
265
- optional: true,
266
- type: Boolean),
267
273
  FastlaneCore::ConfigItem.new(key: :xcpretty_utf,
268
274
  env_name: "XCPRETTY_UTF",
269
275
  description: "Have xcpretty use unicode encoding when reporting builds",
270
276
  optional: true,
271
277
  type: Boolean),
278
+
279
+ FastlaneCore::ConfigItem.new(key: :analyze_build_time,
280
+ env_name: "GYM_ANALYZE_BUILD_TIME",
281
+ description: "Analyze the project build time and store the output in 'culprits.txt' file",
282
+ optional: true,
283
+ type: Boolean),
272
284
  FastlaneCore::ConfigItem.new(key: :skip_profile_detection,
273
285
  env_name: "GYM_SKIP_PROFILE_DETECTION",
274
286
  description: "Do not try to build a profile mapping from the xcodeproj. Match or a manually provided mapping should be used",
Binary file
Binary file
Binary file
@@ -1,4 +1,5 @@
1
1
  require 'fastlane_core/configuration/config_item'
2
+ require 'fastlane/helper/xcodebuild_formatter_helper'
2
3
  require 'credentials_manager/appfile_config'
3
4
  require_relative 'module'
4
5
 
@@ -214,11 +215,7 @@ module Scan
214
215
  description: "Should the HTML report be opened when tests are completed?",
215
216
  is_string: false,
216
217
  default_value: false),
217
- FastlaneCore::ConfigItem.new(key: :disable_xcpretty,
218
- env_name: "SCAN_DISABLE_XCPRETTY",
219
- description: "Disable xcpretty formatting of build, similar to `output_style='raw'` but this will also skip the test results table",
220
- type: Boolean,
221
- optional: true),
218
+
222
219
  FastlaneCore::ConfigItem.new(key: :output_directory,
223
220
  short_option: "-o",
224
221
  env_name: "SCAN_OUTPUT_DIRECTORY",
@@ -227,6 +224,7 @@ module Scan
227
224
  code_gen_default_value: "./test_output",
228
225
  default_value: File.join(containing, "test_output"),
229
226
  default_value_dynamic: true),
227
+
230
228
  FastlaneCore::ConfigItem.new(key: :output_style,
231
229
  short_option: "-b",
232
230
  env_name: "SCAN_OUTPUT_STYLE",
@@ -263,9 +261,30 @@ module Scan
263
261
  description: "Suppress the output of xcodebuild to stdout. Output is still saved in buildlog_path",
264
262
  optional: true,
265
263
  type: Boolean),
264
+
265
+ FastlaneCore::ConfigItem.new(key: :xcodebuild_formatter,
266
+ env_names: ["SCAN_XCODEBUILD_FORMATTER", "FASTLANE_XCODEBUILD_FORMATTER"],
267
+ description: "xcodebuild formatter to use (ex: 'xcbeautify', 'xcbeautify --quieter', 'xcpretty', 'xcpretty -test'). Use empty string (ex: '') to disable any formatter",
268
+ type: String,
269
+ default_value: Fastlane::Helper::XcodebuildFormatterHelper.xcbeautify_installed? ? 'xcbeautify' : 'xcpretty',
270
+ default_value_dynamic: true),
271
+
272
+ # xcpretty
273
+ FastlaneCore::ConfigItem.new(key: :disable_xcpretty,
274
+ env_name: "SCAN_DISABLE_XCPRETTY",
275
+ deprecated: "Use `output_style: 'raw'` instead",
276
+ description: "Disable xcpretty formatting of build, similar to `output_style='raw'` but this will also skip the test results table",
277
+ type: Boolean,
278
+ optional: true),
266
279
  FastlaneCore::ConfigItem.new(key: :formatter,
267
280
  short_option: "-n",
268
281
  env_name: "SCAN_FORMATTER",
282
+ deprecated: "Use 'xcpretty_formatter' instead",
283
+ description: "A custom xcpretty formatter to use",
284
+ optional: true),
285
+ FastlaneCore::ConfigItem.new(key: :xcpretty_formatter,
286
+ short_option: "-N",
287
+ env_name: "SCAN_XCPRETTY_FORMATTER",
269
288
  description: "A custom xcpretty formatter to use",
270
289
  optional: true),
271
290
  FastlaneCore::ConfigItem.new(key: :xcpretty_args,
@@ -273,6 +292,7 @@ module Scan
273
292
  description: "Pass in xcpretty additional command line arguments (e.g. '--test --no-color' or '--tap --no-utf')",
274
293
  type: String,
275
294
  optional: true),
295
+
276
296
  FastlaneCore::ConfigItem.new(key: :derived_data_path,
277
297
  short_option: "-j",
278
298
  env_name: "SCAN_DERIVED_DATA_PATH",
@@ -51,7 +51,9 @@ module Scan
51
51
  end
52
52
  end
53
53
 
54
- execute(retries: Scan.config[:number_of_retries])
54
+ # Set retries to 0 if Xcode 13 because TestCommandGenerator will set '-retry-tests-on-failure -test-iterations'
55
+ retries = Helper.xcode_at_least?(13) ? 0 : Scan.config[:number_of_retries]
56
+ execute(retries: retries)
55
57
  end
56
58
 
57
59
  def execute(retries: 0)
@@ -126,7 +128,7 @@ module Scan
126
128
 
127
129
  test_cases = suite.split(":\n").fetch(1, []).split("\n").each
128
130
  .select { |line| line.match?(/^\s+/) }
129
- .map { |line| line.strip.gsub(".", "/").gsub("()", "") }
131
+ .map { |line| line.strip.gsub(/[\s\.]/, "/").gsub(/[\-\[\]\(\)]/, "") }
130
132
  .map { |line| suite_name + "/" + line }
131
133
 
132
134
  retryable_tests += test_cases
@@ -135,27 +137,126 @@ module Scan
135
137
  return retryable_tests.uniq
136
138
  end
137
139
 
138
- def handle_results(tests_exit_status)
139
- if Scan.config[:disable_xcpretty]
140
- unless tests_exit_status == 0
141
- UI.test_failure!("Test execution failed. Exit status: #{tests_exit_status}")
140
+ def find_filename(type)
141
+ index = Scan.config[:output_types].split(',').index(type)
142
+ return nil if index.nil?
143
+ return (Scan.config[:output_files] || "").split(',')[index]
144
+ end
145
+
146
+ def output_html?
147
+ return Scan.config[:output_types].split(',').include?('html')
148
+ end
149
+
150
+ def output_junit?
151
+ return Scan.config[:output_types].split(',').include?('junit')
152
+ end
153
+
154
+ def output_json_compilation_database?
155
+ return Scan.config[:output_types].split(',').include?('json-compilation-database')
156
+ end
157
+
158
+ def output_html_filename
159
+ return find_filename('html')
160
+ end
161
+
162
+ def output_junit_filename
163
+ return find_filename('junit')
164
+ end
165
+
166
+ def output_json_compilation_database_filename
167
+ return find_filename('json-compilation-database')
168
+ end
169
+
170
+ def trainer_test_results
171
+ require "trainer"
172
+
173
+ results = {
174
+ number_of_tests: 0,
175
+ number_of_failures: 0,
176
+ number_of_retries: 0
177
+ }
178
+
179
+ result_bundle_path = Scan.cache[:result_bundle_path]
180
+
181
+ output_path = Scan.config[:output_directory] || Dir.mktmpdir
182
+ output_path = File.absolute_path(output_path)
183
+
184
+ UI.crash!("A -resultBundlePath is needed to parse the test results. This should not have happened. Please file an issue.") unless result_bundle_path
185
+
186
+ params = {
187
+ path: result_bundle_path,
188
+ silent: !FastlaneCore::Globals.verbose?
189
+ }
190
+
191
+ formatter = Scan.config[:xcodebuild_formatter].chomp
192
+ show_output_types_tip = false
193
+ if output_html? && formatter != 'xcpretty'
194
+ UI.important("Skipping HTML... only available with `xcodebuild_formatter: 'xcpretty'` right now")
195
+ show_output_types_tip = true
196
+ end
197
+
198
+ if output_json_compilation_database? && formatter != 'xcpretty'
199
+ UI.important("Skipping JSON Compilation Database... only available with `xcodebuild_formatter: 'xcpretty'` right now")
200
+ show_output_types_tip = true
201
+ end
202
+
203
+ if show_output_types_tip
204
+ UI.important("Your 'xcodebuild_formatter' doesn't support these 'output_types'. Change your 'output_types' to prevent these warnings from showing...")
205
+ end
206
+
207
+ if output_junit?
208
+ if formatter == 'xcpretty'
209
+ UI.verbose("Generating junit report with xcpretty")
210
+ else
211
+ UI.verbose("Generating junit report with trainer")
212
+ params[:output_filename] = output_junit_filename || "report.junit"
213
+ params[:output_directory] = output_path
142
214
  end
143
- return
144
215
  end
145
216
 
146
- result = TestResultParser.new.parse_result(test_results)
147
- SlackPoster.new.run(result)
217
+ resulting_paths = Trainer::TestParser.auto_convert(params)
218
+ resulting_paths.each do |path, data|
219
+ results[:number_of_tests] += data[:number_of_tests_excluding_retries]
220
+ results[:number_of_failures] += data[:number_of_failures_excluding_retries]
221
+ results[:number_of_retries] += data[:number_of_retries]
222
+ end
223
+
224
+ return results
225
+ end
226
+
227
+ def handle_results(tests_exit_status)
228
+ return if Scan.config[:build_for_testing]
148
229
 
149
- if result[:failures] > 0
150
- failures_str = result[:failures].to_s.red
230
+ results = trainer_test_results
231
+
232
+ number_of_retries = results[:number_of_retries]
233
+ number_of_tests = results[:number_of_tests]
234
+ number_of_failures = results[:number_of_failures]
235
+
236
+ SlackPoster.new.run({
237
+ tests: number_of_tests,
238
+ failures: number_of_failures
239
+ })
240
+
241
+ if number_of_failures > 0
242
+ failures_str = number_of_failures.to_s.red
151
243
  else
152
- failures_str = result[:failures].to_s.green
244
+ failures_str = number_of_failures.to_s.green
153
245
  end
154
246
 
247
+ retries_str = case number_of_retries
248
+ when 0
249
+ ""
250
+ when 1
251
+ " (and 1 retry)"
252
+ else
253
+ " (and #{number_of_retries} retries)"
254
+ end
255
+
155
256
  puts(Terminal::Table.new({
156
257
  title: "Test Results",
157
258
  rows: [
158
- ["Number of tests", result[:tests]],
259
+ ["Number of tests", "#{number_of_tests}#{retries_str}"],
159
260
  ["Number of failures", failures_str]
160
261
  ]
161
262
  }))
@@ -165,7 +266,7 @@ module Scan
165
266
  zip_build_products
166
267
  copy_xctestrun
167
268
 
168
- if result[:failures] > 0
269
+ if number_of_failures > 0
169
270
  open_report
170
271
 
171
272
  UI.test_failure!("Tests have failed")