Class: Snapshot::TestCommandGenerator
- Inherits:
-
Object
- Object
- Snapshot::TestCommandGenerator
- Defined in:
- lib/snapshot/test_command_generator.rb
Overview
Responsible for building the fully working xcodebuild command
Class Method Summary collapse
- .actions ⇒ Object
- .derived_data_path ⇒ Object
- .destination(device) ⇒ Object
- .generate(device_type: nil) ⇒ 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).
- .suffix ⇒ Object
- .xcodebuild_log_path ⇒ Object
Class Method Details
.actions ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'lib/snapshot/test_command_generator.rb', line 45 def actions actions = [] actions << :clean if Snapshot.config[:clean] actions << :build # https://github.com/fastlane/snapshot/issues/246 actions << :test actions end |
.derived_data_path ⇒ Object
89 90 91 |
# File 'lib/snapshot/test_command_generator.rb', line 89 def derived_data_path "/tmp/snapshot_derived/" end |
.destination(device) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/snapshot/test_command_generator.rb', line 62 def destination(device) # we now fetch the device's udid. Why? Because we might get this error message # > The requested device could not be found because multiple devices matched the request. # # This happens when you have multiple simulators for a given device type / iOS combination # { platform:iOS Simulator, id:1685B071-AFB2-4DC1-BE29-8370BA4A6EBD, OS:9.0, name:iPhone 5 } # { platform:iOS Simulator, id:A141F23B-96B3-491A-8949-813B376C28A7, OS:9.0, name:iPhone 5 } # device_udid = nil FastlaneCore::Simulator.all.each do |sim| device_udid = sim.udid if sim.name.strip == device.strip and sim.ios_version == Snapshot.config[:ios_version] end value = "platform=iOS Simulator,id=#{device_udid},OS=#{Snapshot.config[:ios_version]}" return ["-destination '#{value}'"] end |
.generate(device_type: nil) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/snapshot/test_command_generator.rb', line 5 def generate(device_type: nil) parts = prefix parts << "xcodebuild" parts += parts += destination(device_type) parts += actions parts += suffix parts += pipe parts end |
.options ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/snapshot/test_command_generator.rb', line 30 def config = Snapshot.config = [] += project_path_array << "-configuration '#{config[:configuration]}'" if config[:configuration] << "-sdk '#{config[:sdk]}'" if config[:sdk] << "-derivedDataPath '#{derived_data_path}'" # options << "-xcconfig '#{config[:xcconfig]}'" if config[:xcconfig] # options << "-archivePath '#{archive_path}'" # options << config[:xcargs] if config[:xcargs] end |
.pipe ⇒ Object
58 59 60 |
# File 'lib/snapshot/test_command_generator.rb', line 58 def pipe ["| tee '#{xcodebuild_log_path}' | xcpretty"] end |
.prefix ⇒ Object
17 18 19 |
# File 'lib/snapshot/test_command_generator.rb', line 17 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)
24 25 26 27 28 |
# File 'lib/snapshot/test_command_generator.rb', line 24 def project_path_array proj = Snapshot.project.xcodebuild_parameters return proj if proj.count > 0 raise "No project/workspace found" end |
.suffix ⇒ Object
54 55 56 |
# File 'lib/snapshot/test_command_generator.rb', line 54 def suffix [] end |
.xcodebuild_log_path ⇒ Object
81 82 83 84 85 86 87 |
# File 'lib/snapshot/test_command_generator.rb', line 81 def xcodebuild_log_path file_name = "#{Snapshot.project.app_name}-#{Snapshot.config[:scheme]}.log" containing = File.(Snapshot.config[:buildlog_path]) FileUtils.mkdir_p(containing) return File.join(containing, file_name) end |