Module: XCKnife::XCToolCmdHelper

Included in:
Runner
Defined in:
lib/xcknife/xctool_cmd_helper.rb

Instance Method Summary collapse

Instance Method Details

#only_arguments(output_type, partition) ⇒ Object


14
15
16
17
18
19
# File 'lib/xcknife/xctool_cmd_helper.rb', line 14

def only_arguments(output_type, partition)
  method = "#{output_type}_only_arguments"
  raise "Unknown output_type: #{output_type}" unless respond_to?(method)

  __send__(method, partition)
end

#only_arguments_for_a_partition_set(output_type, partition_set) ⇒ Object


7
8
9
10
11
12
# File 'lib/xcknife/xctool_cmd_helper.rb', line 7

def only_arguments_for_a_partition_set(output_type, partition_set)
  method = "#{output_type}_only_arguments_for_a_partition_set"
  raise "Unknown output_type: #{output_type}" unless respond_to?(method)

  __send__(method, partition_set)
end

#xcodebuild_only_arguments(single_partition, meta_partition = nil) ⇒ Object

only-testing is available since Xcode 8 rubocop:disable Metrics/CyclomaticComplexity


33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/xcknife/xctool_cmd_helper.rb', line 33

def xcodebuild_only_arguments(single_partition, meta_partition = nil)
  only_targets = Set.new

  if meta_partition
    filtered = meta_partition.flat_map(&:keys)
                             .group_by(&:to_s)
                             .select { |_, v| v.size == 1 }
                             .map(&:first)
                             .to_set

    only_targets = single_partition.keys.to_set & filtered
  end

  only_target_arguments = only_targets.sort.map { |test_target| "-only-testing:#{test_target}" }

  only_class_arguments = single_partition.flat_map do |test_target, classes|
    next [] if only_targets.include?(test_target)

    classes.sort.map do |clazz|
      "-only-testing:#{test_target}/#{clazz}"
    end
  end.sort

  only_target_arguments + only_class_arguments
end

#xcodebuild_only_arguments_for_a_partition_set(partition_set) ⇒ Object


72
73
74
# File 'lib/xcknife/xctool_cmd_helper.rb', line 72

def xcodebuild_only_arguments_for_a_partition_set(partition_set)
  partition_set.map { |partition| xctool_only_arguments(partition) }
end

#xcodebuild_skip_arguments(single_partition, test_time_for_partitions) ⇒ Object

skip-testing is available since Xcode 8


60
61
62
63
64
65
66
67
68
69
70
# File 'lib/xcknife/xctool_cmd_helper.rb', line 60

def xcodebuild_skip_arguments(single_partition, test_time_for_partitions)
  excluded_targets = test_time_for_partitions.keys.to_set - single_partition.keys.to_set
  skipped_target_arguments = excluded_targets.sort.map { |test_target| "-skip-testing:#{test_target}" }

  skipped_classes_arguments = single_partition.flat_map do |test_target, classes|
    all_classes = test_time_for_partitions[test_target].keys.to_set
    (all_classes - classes.to_set).sort.map { |test_class| "-skip-testing:#{test_target}/#{test_class}" }
  end

  skipped_target_arguments + skipped_classes_arguments
end

#xctool_only_arguments(single_partition) ⇒ Object


21
22
23
24
25
# File 'lib/xcknife/xctool_cmd_helper.rb', line 21

def xctool_only_arguments(single_partition)
  single_partition.flat_map do |test_target, classes|
    ['-only', "#{test_target}:#{classes.sort.join(',')}"]
  end
end

#xctool_only_arguments_for_a_partition_set(partition_set) ⇒ Object


27
28
29
# File 'lib/xcknife/xctool_cmd_helper.rb', line 27

def xctool_only_arguments_for_a_partition_set(partition_set)
  partition_set.map { |partition| xctool_only_arguments(partition) }
end