refinement 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d2b9ddd9af028db3ae8fa7d0303b0599bfea02b3f72827153fce14f32234b03a
4
- data.tar.gz: 89d35046cbad3a50e5fff65dbbeca5b18005d2d85ee267e5014b8b32a5bf0b2b
3
+ metadata.gz: a99bcf514ec4c492f440d7da3f88fa0fa985965ba26ba5a1d402f24c00a7bee9
4
+ data.tar.gz: 65bc69b43d47cf902c76e7271f77a611c29d7dab4e40d2bd09763d846a1dddcb
5
5
  SHA512:
6
- metadata.gz: 183ec917449425251c0fb7d9e1b695de35ec73e67b7f7a67de0931959650ae04c4855e5d310f8699f69fadab6a83e7e18877c8822199242f6ca4681bf7b113aa
7
- data.tar.gz: 7487a0a6bbb3367daf5ebd5df76eb67722718d609fc340b4e618bc59cacc8d502a5fbbcc65fa3e97d6ee7ed65b0fd9edadd5fcd139d7a318ead010803d18443f
6
+ metadata.gz: 59564e789d67708dcb2ad0a565f434f170d9343234a448106292be5eb1666c5b0b9cd41ec7a6ab359989fb2b1baef0c7977bcc799bb5d0f4ac537a650fc7aa98
7
+ data.tar.gz: 8f464e9634f5ab6227d1165c8e7c3653bbe949437065b17c2b9c2beb3af1ac6827a78ec95d1699cf82d183b90f1d83b6fe87bb3006580938d65f4c075d1ba37e
data/CHANGELOG.md CHANGED
@@ -1,6 +1,17 @@
1
1
  # Refinement Changes
2
2
 
3
- ## 0.1.2 (2019-03-20)
3
+ ## 0.2.0 (2019-03-21)
4
+
5
+ ##### Enhancements
6
+
7
+ * Allow filtering schemes for either `:building` or `:testing`,
8
+ since tests can expand their arguments and environment variables based upon
9
+ a build target, and removing the build target could thus break macro expansion
10
+ without any benefit when `xcodebuild build-for-testing / test` is being run,
11
+ since when building for testing or testing, having build entries is not harmful.
12
+
13
+
14
+ ## 0.1.3 (2019-03-20)
4
15
 
5
16
  ##### Bug Fixes
6
17
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.3
1
+ 0.2.0
@@ -50,10 +50,31 @@ module Refinement
50
50
  # Defaults to `false`
51
51
  # @param log_changes [Boolean] whether modifications to the scheme are logged.
52
52
  # Defaults to `false`
53
+ # @param filter_scheme_for_build_action [:building, :testing]
54
+ # The xcodebuild action the scheme is being filtered for. The currently supported values are
55
+ # `:building` and `:testing`, with the only difference being `BuildActionEntry` are not
56
+ # filtered out when building for testing, since test action macro expansion could
57
+ # depend on a build entry being present.
53
58
  # @return [Xcodeproj::XCScheme] a scheme whose unchanged targets have been removed
54
- def filtered_scheme(scheme_path:, change_level: :full_transitive, filter_when_scheme_has_changed: false, log_changes: false)
59
+ def filtered_scheme(scheme_path:, change_level: :full_transitive, filter_when_scheme_has_changed: false, log_changes: false,
60
+ filter_scheme_for_build_action:)
55
61
  scheme = Xcodeproj::XCScheme.new(scheme_path)
56
62
 
63
+ sections_to_filter =
64
+ case filter_scheme_for_build_action
65
+ when :building
66
+ %w[BuildActionEntry TestableReference]
67
+ when :testing
68
+ # don't want to filter out build action entries running
69
+ # xcodebuild build-for-testing / test, since the test action could have a macro expansion
70
+ # that depends upon one of the build targets.
71
+ %w[TestableReference]
72
+ else
73
+ raise ArgumentError,
74
+ 'The supported values for the `filter_scheme_for_build_action` parameter are: [:building, :testing]. ' \
75
+ "Given: #{filter_scheme_for_build_action.inspect}."
76
+ end
77
+
57
78
  if filter_when_scheme_has_changed ||
58
79
  !UsedPath.new(path: Pathname(scheme_path), inclusion_reason: 'scheme').find_in_changeset(changeset)
59
80
 
@@ -62,10 +83,7 @@ module Refinement
62
83
 
63
84
  doc = scheme.doc
64
85
 
65
- xpaths = %w[
66
- //*/TestableReference/BuildableReference
67
- //*/BuildActionEntry/BuildableReference
68
- ]
86
+ xpaths = sections_to_filter.map { |section| "//*/#{section}/BuildableReference" }
69
87
  xpaths.each do |xpath|
70
88
  doc.get_elements(xpath).to_a.each do |buildable_reference|
71
89
  suite_name = buildable_reference.attributes['BlueprintName']
@@ -18,7 +18,9 @@ module Refinement
18
18
  ['--[no-]print-changes', 'Print the change reason for changed targets'],
19
19
  ['--[no-]print-scheme-changes', 'Print the change reason for targets in the given scheme'],
20
20
  ['--change-level=LEVEL', 'Change level at which a target must have changed in order to be considered changed. ' \
21
- 'One of `full-transitive`, `itself`, or an integer']
21
+ 'One of `full-transitive`, `itself`, or an integer'],
22
+ ['--filter-scheme-for-build-action=BUILD_ACTION', 'The xcodebuild action the scheme (if given) is filtered for. ' \
23
+ 'One of `building` or `testing`.']
22
24
  ]
23
25
  end
24
26
 
@@ -30,6 +32,7 @@ module Refinement
30
32
  @print_changes = argv.flag?('print-changes', false)
31
33
  @print_scheme_changes = argv.flag?('print-scheme-changes', false)
32
34
  @change_level = argv.option('change-level', 'full-transitive')
35
+ @filter_scheme_for_build_action = argv.option('filter-scheme-for-build-action', 'testing').to_sym
33
36
 
34
37
  super
35
38
  end
@@ -45,7 +48,7 @@ module Refinement
45
48
  puts analyzer.format_changes if @print_changes
46
49
 
47
50
  return unless @scheme
48
- analyzer.filtered_scheme(scheme_path: @scheme, log_changes: @print_scheme_changes)
51
+ analyzer.filtered_scheme(scheme_path: @scheme, log_changes: @print_scheme_changes, filter_scheme_for_build_action: @filter_scheme_for_build_action)
49
52
  .save_as(@scheme.gsub(%r{\.(xcodeproj|xcworkspace)/.+}, '.\1'), File.basename(@scheme, '.xcscheme'), true)
50
53
  end
51
54
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: refinement
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Giddins
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-03-20 00:00:00.000000000 Z
11
+ date: 2019-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xcodeproj