Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[scan] Reduce run time by removing report generation command as separ…
…ate process (#7365) * [scan] Increase speed of test report generation * [scan] Move xcpretty reporter code to separate file * Fix some bugs with output_files option * [scan] bug fixes and formatting * [scan] add tests for XCPrettyReporterOptionsGenerator * Rubocop fixes * [scan] Add backwards compatibility for option :custom_report_file_name In this way, it should now behave the same way as :output_files, but is marked as deprecated because the option name is misleading/confusing. * [scan] Add runtime deprecation warning message * [scan] Use fastlane-provided deprecation mechanism * [scan] Remove unneccesary comment * add mocks to fix unit tests * Slight refactoring to remove unit test workarounds * Fix trailing whitespace * Make changes for code review comments * Add a unit test for deprecated Scan option custom_report_file_name * Update tests to take order of values into account * Forgot to add check for warning message * Re-add line, accidentally removed * run rubocop
- Loading branch information
1 parent
7c8a66c
commit 6123fa0
Showing
10 changed files
with
370 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
module Scan | ||
class XCPrettyReporterOptionsGenerator | ||
SUPPORTED_REPORT_TYPES = %w(html junit json-compilation-database) | ||
|
||
def self.generate_from_scan_config | ||
self.new(Scan.config[:open_report], | ||
Scan.config[:output_types], | ||
Scan.config[:output_files] || Scan.config[:custom_report_file_name], | ||
Scan.config[:output_directory], | ||
Scan.config[:use_clang_report_name]) | ||
end | ||
|
||
# Intialize with values from Scan.config matching these param names | ||
def initialize(open_report, output_types, output_files, output_directory, use_clang_report_name) | ||
@open_report = open_report | ||
@output_types = output_types | ||
@output_files = output_files | ||
@output_directory = output_directory | ||
@use_clang_report_name = use_clang_report_name | ||
|
||
# might already be an array when passed via fastlane | ||
@output_types = @output_types.split(',') if @output_types.kind_of?(String) | ||
|
||
if @output_files.nil? | ||
@output_files = @output_types.map { |type| "report.#{type}" } | ||
elsif @output_files.kind_of?(String) | ||
# might already be an array when passed via fastlane | ||
@output_files = @output_files.split(',') | ||
end | ||
|
||
unless @output_types.length == @output_files.length | ||
UI.important("WARNING: output_types and output_files do not have the same number of items. Default values will be substituted as needed.") | ||
end | ||
|
||
(@output_types - SUPPORTED_REPORT_TYPES).each do |type| | ||
UI.error("Couldn't find reporter '#{type}', available #{SUPPORTED_REPORT_TYPES.join(', ')}") | ||
end | ||
end | ||
|
||
def generate_reporter_options | ||
reporter = [] | ||
|
||
valid_types = @output_types & SUPPORTED_REPORT_TYPES | ||
valid_types.each do |raw_type| | ||
type = raw_type.strip | ||
output_path = File.join(File.expand_path(@output_directory), determine_output_file_name(type)) | ||
reporter << "--report #{type}" | ||
reporter << "--output #{output_path}" | ||
|
||
if type == "html" && @open_report | ||
Scan.cache[:open_html_report_path] = output_path | ||
end | ||
end | ||
|
||
# adds another junit reporter in case the user does not specify one | ||
# this will be used to generate a results table and then discarded | ||
require 'tempfile' | ||
Scan.cache[:temp_junit_report] = Tempfile.new("junit_report").path | ||
reporter << "--report junit" | ||
reporter << "--output #{Scan.cache[:temp_junit_report]}" | ||
return reporter | ||
end | ||
|
||
private | ||
|
||
def determine_output_file_name(type) | ||
if @use_clang_report_name && type == "json-compilation-database" | ||
return "compile_commands.json" | ||
end | ||
|
||
index = @output_types.index(type) | ||
file = @output_files[index] | ||
file || "report.#{type}" | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.