Class: Scan::TestCommandGenerator
- Inherits:
-
Object
- Object
- Scan::TestCommandGenerator
- Defined in:
- lib/scan/test_command_generator.rb
Overview
Responsible for building the fully working xcodebuild command
Class Method Summary collapse
- .actions ⇒ Object
-
.build_path ⇒ Object
The path to set the Derived Data to.
- .generate ⇒ Object
- .options ⇒ Object
- .pipe ⇒ Object
- .prefix ⇒ Object
-
.project_path_array ⇒ Array
Path to the project or workspace as parameter This will also include the scheme (if given).
- .result_bundle_path ⇒ Object
- .suffix ⇒ Object
-
.xcodebuild_log_path ⇒ Object
Store the raw file.
Class Method Details
.actions ⇒ Object
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/scan/test_command_generator.rb', line 46 def actions config = Scan.config actions = [] actions << :clean if config[:clean] actions << :build unless config[:skip_build] actions << :test actions end |
.build_path ⇒ Object
The path to set the Derived Data to
98 99 100 101 102 103 104 105 106 |
# File 'lib/scan/test_command_generator.rb', line 98 def build_path unless Scan.cache[:build_path] day = Time.now.strftime("%F") # e.g. 2015-08-07 Scan.cache[:build_path] = File.("~/Library/Developer/Xcode/Archives/#{day}/") FileUtils.mkdir_p Scan.cache[:build_path] end Scan.cache[:build_path] end |
.generate ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/scan/test_command_generator.rb', line 5 def generate parts = prefix parts << "env NSUnbufferedIO=YES xcodebuild" parts += parts += actions parts += suffix parts += pipe parts end |
.options ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/scan/test_command_generator.rb', line 29 def config = Scan.config = [] += project_path_array << "-configuration '#{config[:configuration]}'" if config[:configuration] << "-sdk '#{config[:sdk]}'" if config[:sdk] << "-destination '#{config[:destination]}'" # generated in `detect_values` << "-derivedDataPath '#{config[:derived_data_path]}'" if config[:derived_data_path] << "-resultBundlePath '#{result_bundle_path}'" if config[:result_bundle] << "-enableCodeCoverage YES" if config[:code_coverage] << "-xcconfig '#{config[:xcconfig]}'" if config[:xcconfig] << config[:xcargs] if config[:xcargs] end |
.pipe ⇒ Object
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 |
# File 'lib/scan/test_command_generator.rb', line 62 def pipe # During building we just show the output in the terminal # Check out the ReportCollector class for more xcpretty things formatter = [] if Scan.config[:formatter] formatter << "-f `#{Scan.config[:formatter]}`" elsif ENV.key?("TRAVIS") formatter << "-f `xcpretty-travis-formatter`" UI.success("Automatically switched to Travis formatter") end if Helper.colors_disabled? formatter << "--no-color" end if Scan.config[:output_style] == 'basic' formatter << "--no-utf" end if Scan.config[:output_style] == 'rspec' formatter << "--test" end ["| tee '#{xcodebuild_log_path}' | xcpretty #{formatter.join(' ')}"] end |
.prefix ⇒ Object
16 17 18 |
# File 'lib/scan/test_command_generator.rb', line 16 def prefix ["set -o pipefail &&"] end |
.project_path_array ⇒ Array
Path to the project or workspace as parameter This will also include the scheme (if given)
23 24 25 26 27 |
# File 'lib/scan/test_command_generator.rb', line 23 def project_path_array proj = Scan.project.xcodebuild_parameters return proj if proj.count > 0 UI.user_error!("No project/workspace found") end |
.result_bundle_path ⇒ Object
108 109 110 111 112 113 |
# File 'lib/scan/test_command_generator.rb', line 108 def result_bundle_path unless Scan.cache[:result_bundle_path] Scan.cache[:result_bundle_path] = File.join(Scan.config[:output_directory], Scan.config[:scheme]) + ".test_result" end return Scan.cache[:result_bundle_path] end |
.suffix ⇒ Object
57 58 59 60 |
# File 'lib/scan/test_command_generator.rb', line 57 def suffix suffix = [] suffix end |
.xcodebuild_log_path ⇒ Object
Store the raw file
89 90 91 92 93 94 95 |
# File 'lib/scan/test_command_generator.rb', line 89 def xcodebuild_log_path file_name = "#{Scan.project.app_name}-#{Scan.config[:scheme]}.log" containing = File.(Scan.config[:buildlog_path]) FileUtils.mkdir_p(containing) return File.join(containing, file_name) end |