test-kitchen 3.3.1 → 3.3.2

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: cbe0ba6a501464b8f253beca9d017b7d09a90fa5f4407e775d5fe31b81f610da
4
- data.tar.gz: c7e0c062a903e1be1fd5425f692fecdd28d29841a5bee156b89a0d7149a25b10
3
+ metadata.gz: 0b2b5ae9a13717d2eb6e02314305d2ee451bdf5739a396ffd649eeb03bd2cbd1
4
+ data.tar.gz: 2552cb2ca280b5f696fc17ed7f1346c7b9c9320d6d0f8b5bd729bb7ee23bd480
5
5
  SHA512:
6
- metadata.gz: abb1d27365dcdbfe5eaccffe717d7391f63a8784a75ee79bb44b8a5ba23d72d17bd7bd01a3d375454111ddcd0425874f0fa7b14dcdd2cf461ccdf978426f99c3
7
- data.tar.gz: 6bd22f60e9f13a0b74f1c4c4598be74071640f5593f7039f030aa5c95de1a595e5a6401eb092eee2f165715d28202bb0b43324e16b5393a96dc256b993d05109
6
+ metadata.gz: cd7e48cec7ae4a0a959dc58bdcb196549a432177b8338340d774c9b20165efa95306dcc3f5b1c4aebd8da225462165b5a3d0e5dadbdc1a8d07fd7f282046d0c8
7
+ data.tar.gz: cef3fceeb5cc11c249b814fc3681187207eaeadc92dd499f422555ce69992bc57ce8d9177e4e637e57433a6515cc5275b1dbeae60c78b8b10605fa4370980e41
@@ -1,3 +1,5 @@
1
+ require_relative "../platform_filter"
2
+
1
3
  module Kitchen
2
4
  class LifecycleHook
3
5
  class Base
@@ -59,14 +61,14 @@ module Kitchen
59
61
  lifecycle_hooks.state_file
60
62
  end
61
63
 
62
- # @return [Array<String>] names of excluded platforms
64
+ # @return [Array<PlatformFilter>] names of excluded platforms
63
65
  def excludes
64
- @excludes ||= hook.fetch(:excludes, [])
66
+ @excludes ||= PlatformFilter.convert(hook.fetch(:excludes, []))
65
67
  end
66
68
 
67
- # @return [Array<String>] names of only included platforms
69
+ # @return [Array<PlatformFilter>] names of only included platforms
68
70
  def includes
69
- @includes ||= hook.fetch(:includes, [])
71
+ @includes ||= PlatformFilter.convert(hook.fetch(:includes, []))
70
72
  end
71
73
 
72
74
  # @return [String]
@@ -0,0 +1,72 @@
1
+ #
2
+ # Author:: Baptiste Courtois (<b.courtois@criteo.com>)
3
+ #
4
+ # Copyright (C) 2021, Baptiste Courtois
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+
18
+ module Kitchen
19
+ # A wrapper on Regexp and strings to mix them in platform filters.
20
+ #
21
+ # This should handle backward compatibility in most cases were
22
+ # platform are matched against a filters array using Array.include?
23
+ #
24
+ # This wrapper does not work if filters arrays are converted to Set.
25
+ #
26
+ # @author Baptiste Courtois <b.courtois@criteo.com>
27
+ class PlatformFilter
28
+ # Pattern used to determine whether a filter should be handled as a Regexp
29
+ REGEXP_LIKE_PATTERN = %r{^/(?<pattern>.*)/(?<options>[ix]*)$}.freeze
30
+
31
+ # Converts platform filters into an array of PlatformFilter handling both strings and Regexp.
32
+ # A string "looks-like" a regexp if it starts by / and end by / + Regexp options i or x
33
+ #
34
+ # @return [Array] filters with regexp-like string converted to PlatformRegexpFilter
35
+ def self.convert(filters)
36
+ ::Kernel.Array(filters).map do |filter|
37
+ if (match = filter.match(REGEXP_LIKE_PATTERN))
38
+ options = match["options"].include?("i") ? ::Regexp::IGNORECASE : 0
39
+ options |= ::Regexp::EXTENDED if match["options"].include?("x")
40
+ filter = ::Regexp.new(match["pattern"], options)
41
+ end
42
+ new(filter)
43
+ end
44
+ end
45
+
46
+ # @return [Regexp] value of this filter
47
+ attr_reader :value
48
+
49
+ # Constructs a new filter.
50
+ #
51
+ # @param [Regexp,String] value of the filter
52
+ def initialize(value)
53
+ raise ::ArgumentError, "PlatformFilter#new requires value to be a String or a Regexp" unless value.is_a?(::Regexp) || value.is_a?(::String)
54
+
55
+ @value = value
56
+ end
57
+
58
+ # Override of the equality operator to check whether the wrapped Regexp match the given object.
59
+ #
60
+ # @param [Object] other object to compare to
61
+ # @return [Boolean] whether the objects are equal or the wrapped Regexp matches the given string or symbol
62
+ def ==(other)
63
+ if @value.is_a?(::Regexp) && (other.is_a?(::String) || other.is_a?(::Symbol))
64
+ @value =~ other
65
+ else
66
+ other == @value
67
+ end
68
+ end
69
+
70
+ alias eq? ==
71
+ end
72
+ end
data/lib/kitchen/suite.rb CHANGED
@@ -15,6 +15,8 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
+ require_relative "platform_filter"
19
+
18
20
  module Kitchen
19
21
  # A logical configuration representing a test case or fixture that will be
20
22
  # executed on a platform.
@@ -41,8 +43,8 @@ module Kitchen
41
43
  @name = options.fetch(:name) do
42
44
  raise ClientError, "Suite#new requires option :name"
43
45
  end
44
- @excludes = options.fetch(:excludes, [])
45
- @includes = options.fetch(:includes, [])
46
+ @excludes = PlatformFilter.convert(options.fetch(:excludes, []))
47
+ @includes = PlatformFilter.convert(options.fetch(:includes, []))
46
48
  end
47
49
  end
48
50
  end
@@ -16,5 +16,5 @@
16
16
  # limitations under the License.
17
17
 
18
18
  module Kitchen
19
- VERSION = "3.3.1".freeze
19
+ VERSION = "3.3.2".freeze
20
20
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: test-kitchen
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.1
4
+ version: 3.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fletcher Nichol
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-07-04 00:00:00.000000000 Z
11
+ date: 2022-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mixlib-shellout
@@ -440,6 +440,7 @@ files:
440
440
  - lib/kitchen/login_command.rb
441
441
  - lib/kitchen/metadata_chopper.rb
442
442
  - lib/kitchen/platform.rb
443
+ - lib/kitchen/platform_filter.rb
443
444
  - lib/kitchen/plugin.rb
444
445
  - lib/kitchen/plugin_base.rb
445
446
  - lib/kitchen/provisioner.rb
@@ -520,7 +521,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
520
521
  - !ruby/object:Gem::Version
521
522
  version: '0'
522
523
  requirements: []
523
- rubygems_version: 3.3.11
524
+ rubygems_version: 3.2.3
524
525
  signing_key:
525
526
  specification_version: 4
526
527
  summary: Test Kitchen is an integration tool for developing and testing infrastructure