Class: XCKnife::TestDumperHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/xcknife/test_dumper.rb

Defined Under Namespace

Classes: TestSpecification

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(device_id, max_retry_count, debug, logger) ⇒ TestDumperHelper

Returns a new instance of TestDumperHelper.



146
147
148
149
150
151
152
153
154
155
156
157
# File 'lib/xcknife/test_dumper.rb', line 146

def initialize(device_id, max_retry_count, debug, logger)
  @xcode_path = `xcode-select -p`.strip
  @simctl_path = `xcrun -f simctl`.strip
  @platforms_path = "#{@xcode_path}/Platforms/"
  @platform_path = "#{@platforms_path}/iPhoneSimulator.platform"
  @sdk_path = "#{@platform_path}/Developer/SDKs/iPhoneSimulator.sdk"
  @testroot = nil
  @device_id = device_id
  @max_retry_count = max_retry_count
  @logger = logger
  @debug = debug
end

Instance Attribute Details

#loggerObject (readonly)

Returns the value of attribute logger.



144
145
146
# File 'lib/xcknife/test_dumper.rb', line 144

def logger
  @logger
end

Instance Method Details

#call(derived_data_folder, list_folder, extra_environment_variables = {}) ⇒ Object



159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# File 'lib/xcknife/test_dumper.rb', line 159

def call(derived_data_folder, list_folder, extra_environment_variables = {})
  @testroot = "#{derived_data_folder}/Build/Products/"
  xctestrun_file = Dir["#{@testroot}/*.xctestrun"].first
  if xctestrun_file.nil?
    puts "No xctestrun on #{@testroot}"
    exit 1
  end
  xctestrun_as_json = `plutil -convert json -o - "#{xctestrun_file}"`
  FileUtils.mkdir_p(list_folder)
  JSON.load(xctestrun_as_json).map do |test_bundle_name, test_bundle|
    test_specification = list_tests_wiht_simctl(list_folder, test_bundle, test_bundle_name, extra_environment_variables)
    wait_test_dumper_completion(test_specification.json_stream_file)
    test_specification
  end
end