Class: XCKnife::TestDumper

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args, logger: Logger.new($stdout, progname: 'xcknife test dumper')) ⇒ TestDumper

Returns a new instance of TestDumper.


23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/xcknife/test_dumper.rb', line 23

def initialize(args, logger: Logger.new($stdout, progname: 'xcknife test dumper'))
  @debug = false
  @max_retry_count = 150
  @temporary_output_folder = nil
  @xcscheme_file = nil
  @parser = build_parser
  @naive_dump_bundle_names = []
  @skip_dump_bundle_names = []
  @simctl_timeout = 0
  parse_arguments(args)
  @device_id ||= 'booted'
  @logger = logger
  @logger.level = @debug ? Logger::DEBUG : Logger::FATAL
  @parser = nil
end

Instance Attribute Details

#loggerObject (readonly)

Returns the value of attribute logger


21
22
23
# File 'lib/xcknife/test_dumper.rb', line 21

def logger
  @logger
end

Class Method Details

.invokeObject


17
18
19
# File 'lib/xcknife/test_dumper.rb', line 17

def self.invoke
  new(ARGV).run
end

Instance Method Details

#runObject


39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/xcknife/test_dumper.rb', line 39

def run
  helper = TestDumperHelper.new(@device_id, @max_retry_count, @debug, @logger, @dylib_logfile_path,
                                naive_dump_bundle_names: @naive_dump_bundle_names, skip_dump_bundle_names: @skip_dump_bundle_names, simctl_timeout: @simctl_timeout)
  extra_environment_variables = parse_scheme_file
  logger.info { "Environment variables from xcscheme: #{extra_environment_variables.pretty_inspect}" }
  output_fd = File.open(@output_file, 'w')
  if @temporary_output_folder.nil?
    Dir.mktmpdir('xctestdumper_') do |outfolder|
      list_tests(extra_environment_variables, helper, outfolder, output_fd)
    end
  else
    raise TestDumpError, "Error no such directory: #{@temporary_output_folder}" unless File.directory?(@temporary_output_folder)

    puts "Warning: #{@temporary_output_folder} is not empty! Files can be overwritten." if Dir.entries(@temporary_output_folder).any? { |f| File.file?(File.join(@temporary_output_folder, f)) }
    list_tests(extra_environment_variables, helper, File.absolute_path(@temporary_output_folder), output_fd)
  end
  output_fd.close
  puts 'Done listing test methods'
end