Skip to content

Instantly share code, notes, and snippets.

@teriiehina
Created June 7, 2016 10:33
Show Gist options
  • Save teriiehina/adfc7198f81be7ad705a4c3913e05dea to your computer and use it in GitHub Desktop.
Save teriiehina/adfc7198f81be7ad705a4c3913e05dea to your computer and use it in GitHub Desktop.
module Fastlane
module Actions
module SharedValues
SUPER_SCAN_FAILING_TESTS_NUMBER = :SUPER_SCAN_FAILING_TESTS_NUMBER
SUPER_SCAN_TOTAL_TESTS_NUMBER = :SUPER_SCAN_TOTAL_TESTS_NUMBER
end
class SuperScanAction < Action
def self.run(options)
require 'scan'
begin
FastlaneCore::UpdateChecker.start_looking_for_update('scan') unless Helper.is_test?
# Scan::Manager.new.work(options)
Scan.config = options
FastlaneCore::PrintTable.print_values(config: options,
hide_keys: [:destination, :slack_url],
title: "Summary for scan #{Scan::VERSION}")
runner = Scan::Runner.new
exit_status = runner.test_app
result = parse_results
Actions.lane_context[SharedValues::SUPER_SCAN_FAILING_TESTS_NUMBER] = "#{result[:failures]}"
Actions.lane_context[SharedValues::SUPER_SCAN_TOTAL_TESTS_NUMBER] = "#{result[:tests]}"
runner.handle_results(exit_status)
ensure
FastlaneCore::UpdateChecker.show_update_status('scan', Scan::VERSION)
end
end
def self.parse_results
require 'tempfile'
output_file = Tempfile.new("junit_report")
report_collector = Scan::ReportCollector.new(Scan.config[:open_report],
Scan.config[:output_types],
Scan.config[:output_directory],
Scan.config[:use_clang_report_name])
cmd = report_collector.generate_commands(Scan::TestCommandGenerator.xcodebuild_log_path,
types: 'junit',
output_file_name: output_file.path).values.last
system(cmd)
result = Scan::TestResultParser.new.parse_result(output_file.read)
result
end
def self.description
"Easily test your app using `scan`"
end
def self.details
"More information: https://github.com/fastlane/fastlane/tree/master/scan"
end
def self.author
"KrauseFx"
end
def self.output
[
['SUPER_SCAN_FAILING_TESTS_NUMBER', 'The number of failing tests'],
['SUPER_SCAN_TOTAL_TESTS_NUMBER' , 'The number of tests']
]
end
def self.available_options
require 'scan'
Scan::Options.available_options
end
def self.is_supported?(platform)
[:ios, :mac].include? platform
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment