Class: Snapshot::TestCommandGeneratorXcode8
Overview
Responsible for building the fully working xcodebuild command This TestCommandGenerator supports Xcode 8’s xcodebuild requirements It is its own object, as the logic differs for how we want to handle creating xcodebuild commands for Xcode 9 (see test_command_generator.rb)
Class Method Summary
collapse
actions, build_settings, derived_data_path, device_udid, find_device, initialize, options, prefix, project_path_array, resolve_result_bundle_path, suffix
Class Method Details
.destination(device_name) ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'snapshot/lib/snapshot/test_command_generator_xcode_8.rb', line 33
def destination(device_name)
return ["-destination 'platform=macOS'"] if device_name =~ /^Mac/
os = device_name =~ /^Apple TV/ ? "tvOS" : "iOS"
os_version = Snapshot.config[:ios_version] || Snapshot::LatestOsVersion.version(os)
device = find_device(device_name, os_version)
if device.nil?
UI.user_error!("No device found named '#{device_name}' for version '#{os_version}'")
elsif device.os_version != os_version
UI.important("Using device named '#{device_name}' with version '#{device.os_version}' because no match was found for version '#{os_version}'")
end
value = "platform=#{os} Simulator,id=#{device.udid},OS=#{device.os_version}"
return ["-destination '#{value}'"]
end
|
.generate(device_type: nil, language: nil, locale: nil) ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'snapshot/lib/snapshot/test_command_generator_xcode_8.rb', line 12
def generate(device_type: nil, language: nil, locale: nil)
parts = prefix
parts << "xcodebuild"
parts += options(language, locale)
parts += destination(device_type)
parts += build_settings(language, locale)
parts += actions
parts += suffix
parts += pipe(device_type, language, locale)
return parts
end
|
.pipe(device_type, language, locale) ⇒ Object
25
26
27
28
29
30
31
|
# File 'snapshot/lib/snapshot/test_command_generator_xcode_8.rb', line 25
def pipe(device_type, language, locale)
log_path = xcodebuild_log_path(device_type: device_type, language: language, locale: locale)
pipe = ["| tee #{log_path.shellescape}"]
pipe << "| xcpretty #{Snapshot.config[:xcpretty_args]}"
pipe << "> /dev/null" if Snapshot.config[:suppress_xcode_output]
return pipe
end
|
.xcodebuild_log_path(device_type: nil, language: nil, locale: nil) ⇒ Object
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'snapshot/lib/snapshot/test_command_generator_xcode_8.rb', line 52
def xcodebuild_log_path(device_type: nil, language: nil, locale: nil)
name_components = [Snapshot.project.app_name, Snapshot.config[:scheme]]
if Snapshot.config[:namespace_log_files]
name_components << device_type if device_type
name_components << language if language
name_components << locale if locale
end
file_name = "#{name_components.join('-')}.log"
containing = File.expand_path(Snapshot.config[:buildlog_path])
FileUtils.mkdir_p(containing)
return File.join(containing, file_name)
end
|