cuke_slicer 2.2.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +19 -1
- data/LICENSE.txt +1 -1
- data/README.md +18 -10
- data/cuke_slicer.gemspec +34 -19
- data/lib/cuke_slicer/collections/nested_tag_collection.rb +6 -4
- data/lib/cuke_slicer/collections/path_collection.rb +4 -2
- data/lib/cuke_slicer/collections/tag_collection.rb +6 -4
- data/lib/cuke_slicer/extractors/directory_extractor.rb +3 -1
- data/lib/cuke_slicer/extractors/file_extractor.rb +11 -4
- data/lib/cuke_slicer/filters/filter_set.rb +12 -10
- data/lib/cuke_slicer/helpers/extraction_helpers.rb +11 -5
- data/lib/cuke_slicer/helpers/filter_helpers.rb +36 -30
- data/lib/cuke_slicer/helpers/helpers.rb +5 -4
- data/lib/cuke_slicer/helpers/matching_helpers.rb +12 -7
- data/lib/cuke_slicer/slicer.rb +16 -20
- data/lib/cuke_slicer/version.rb +1 -1
- data/lib/cuke_slicer.rb +2 -2
- data/{features → testing/cucumber/features}/test_case_extraction.feature +22 -0
- metadata +79 -57
- data/.gitignore +0 -24
- data/.simplecov +0 -7
- data/.travis.yml +0 -33
- data/Gemfile +0 -4
- data/Rakefile +0 -85
- data/appveyor.yml +0 -81
- data/features/step_definitions/action_steps.rb +0 -107
- data/features/step_definitions/setup_steps.rb +0 -103
- data/features/step_definitions/verification_steps.rb +0 -58
- data/features/support/env.rb +0 -18
- data/gemfiles/cuke_modeler0.gemfile +0 -28
- data/gemfiles/cuke_modeler1.gemfile +0 -29
- data/gemfiles/cuke_modeler2.gemfile +0 -29
- data/gemfiles/cuke_modeler3.gemfile +0 -12
- data/spec/cuke_slicer_spec.rb +0 -28
- data/spec/slicer_integration_spec.rb +0 -279
- data/spec/slicer_unit_spec.rb +0 -37
- data/spec/spec_helper.rb +0 -22
- /data/{features → testing/cucumber/features}/tag_logic.feature +0 -0
- /data/{features → testing/cucumber/features}/test_case_filtering.feature +0 -0
- /data/{features → testing/cucumber/features}/validation.feature +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa79b66cbc3e85e4d8a532123fe92ed2431da5435fc28617c171b891ba850b2e
|
4
|
+
data.tar.gz: 58106b978a4a83ac08e4f16b1c99f3c3c230170bb4273d2d6e634cefa2a40b8d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3bd5f29074a87dcc620347623feaca14023b1399ea56dc71bdebc1067e2b063a4a705ed3711b4c3f881acf33ce793a51eb7ef72902ce48d25a39a30097da2fcd
|
7
|
+
data.tar.gz: b69b1759f3aeab9c16bc9521280e6e12b9757ccfcc6960b60b46dec88352a51b2b14e729265f05f11597e14513dd1d1c3a1b56b42e93d978f085b5858f1b37d9
|
data/CHANGELOG.md
CHANGED
@@ -8,6 +8,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
8
8
|
|
9
9
|
Nothing yet...
|
10
10
|
|
11
|
+
|
12
|
+
## [3.0.0] - 2024-03-17
|
13
|
+
|
14
|
+
### Added
|
15
|
+
- Tests inside of `Rule` elements are now taken into account when slicing.
|
16
|
+
|
17
|
+
### Removed
|
18
|
+
- Removed support for some older versions of the gem's dependencies:
|
19
|
+
- CukeModeler `0.x`, CukeModeler `1.x`, and CukeModeler `2.x`. Slicing features with `Rule` elements requires at
|
20
|
+
least CukeModeler `3.x`, because that is the major version that first modeled rules.
|
21
|
+
- Ruby `1.x`. Testing against older Rubies in the current CI ecosystem has become too burdensome and Ruby `1.x` is
|
22
|
+
long past end-of-life. Additionally, CukeModeler `3.x` requires at least Ruby `2.x`.
|
23
|
+
|
24
|
+
### Changed
|
25
|
+
- No longer including every file in the Git repository as part of the gem. Only the files needed for using the
|
26
|
+
gem (and the informative ones like the README) will be packaged into the released gem.
|
27
|
+
|
11
28
|
## [2.2.0] - 2021-01-07
|
12
29
|
|
13
30
|
### Added
|
@@ -57,7 +74,8 @@ Nothing yet...
|
|
57
74
|
|
58
75
|
- Initial release
|
59
76
|
|
60
|
-
[Unreleased]: https://github.com/enkessler/cuke_slicer/compare/
|
77
|
+
[Unreleased]: https://github.com/enkessler/cuke_slicer/compare/v3.0.0...HEAD
|
78
|
+
[3.0.0]: https://github.com/enkessler/cuke_slicer/compare/v2.2.0...v3.0.0
|
61
79
|
[2.2.0]: https://github.com/enkessler/cuke_slicer/compare/v2.1.0...v2.2.0
|
62
80
|
[2.1.0]: https://github.com/enkessler/cuke_slicer/compare/v2.0.3...v2.1.0
|
63
81
|
[2.0.3]: https://github.com/enkessler/cuke_slicer/compare/v2.0.2...v2.0.3
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -4,13 +4,13 @@ Basic stuff:
|
|
4
4
|
[![Downloads](https://img.shields.io/gem/dt/cuke_slicer.svg)](https://rubygems.org/gems/cuke_slicer)
|
5
5
|
|
6
6
|
User stuff:
|
7
|
+
[![Cucumber Docs](http://img.shields.io/badge/Documentation-Features-green.svg)](https://github.com/enkessler/cuke_slicer/tree/master/testing/cucumber/features)
|
7
8
|
[![Yard Docs](http://img.shields.io/badge/Documentation-API-blue.svg)](https://www.rubydoc.info/gems/cuke_slicer)
|
8
9
|
|
9
10
|
Developer stuff:
|
10
|
-
[![Build Status](https://
|
11
|
-
[![
|
12
|
-
[![
|
13
|
-
[![Maintainability](https://codeclimate.com/github/enkessler/cuke_slicer/badges/gpa.svg)](https://codeclimate.com/github/enkessler/cuke_slicer/maintainability)
|
11
|
+
[![Build Status](https://github.com/enkessler/cuke_slicer/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/enkessler/cuke_slicer/actions/workflows/ci.yml?query=branch%3Amaster)
|
12
|
+
[![Coverage Status](https://coveralls.io/repos/github/enkessler/cuke_slicer/badge.svg?branch=master)](https://coveralls.io/github/enkessler/cuke_slicer?branch=master)
|
13
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/14c5ad2f8583be273418/maintainability)](https://codeclimate.com/github/enkessler/cuke_slicer/maintainability)
|
14
14
|
|
15
15
|
---
|
16
16
|
|
@@ -60,11 +60,19 @@ Or install it yourself as:
|
|
60
60
|
|
61
61
|
system('cucumber @tests_to_run.txt')
|
62
62
|
|
63
|
+
In addition to tag and path filters, a block can be used for filtering tests by inspecting the
|
64
|
+
underlying CukeModeler models that represent test cases and filtering on whatever criteria you can think up.
|
63
65
|
|
64
|
-
|
66
|
+
CukeSlicer::Slicer.new.slice(test_directory, {}, :file_line) do |test_case|
|
67
|
+
test_case.is_a?(CukeModeler::Scenario) &&
|
68
|
+
test_case.get_ancestor(:feature).name =~ /first/
|
69
|
+
end
|
65
70
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
+
|
72
|
+
## Development and Contributing
|
73
|
+
|
74
|
+
See [CONTRIBUTING.md](https://github.com/enkessler/cuke_slicer/blob/master/CONTRIBUTING.md)
|
75
|
+
|
76
|
+
## License
|
77
|
+
|
78
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/cuke_slicer.gemspec
CHANGED
@@ -1,34 +1,49 @@
|
|
1
|
-
# coding: utf-8
|
2
1
|
lib = File.expand_path('../lib', __FILE__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
3
|
require 'cuke_slicer/version'
|
5
4
|
|
6
5
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
6
|
+
spec.name = 'cuke_slicer'
|
8
7
|
spec.version = CukeSlicer::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
11
|
-
spec.summary =
|
12
|
-
spec.description =
|
13
|
-
|
14
|
-
|
8
|
+
spec.authors = ['Eric Kessler']
|
9
|
+
spec.email = ['morrow748@gmail.com']
|
10
|
+
spec.summary = 'A gem for extracting test cases from a Cucumber test suite.'
|
11
|
+
spec.description = ['Slices a Cucumber test suite into the smallest possible executable pieces (i.e. scenarios ',
|
12
|
+
'and individual outline example rows. These pieces can then be more easily used for running ',
|
13
|
+
'tests in parallel.'].join
|
14
|
+
spec.homepage = 'https://github.com/enkessler/cuke_slicer'
|
15
|
+
spec.license = 'MIT'
|
15
16
|
|
16
|
-
spec.
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
spec.metadata = {
|
18
|
+
'bug_tracker_uri' => 'https://github.com/enkessler/cuke_slicer/issues',
|
19
|
+
'changelog_uri' => 'https://github.com/enkessler/cuke_slicer/blob/master/CHANGELOG.md',
|
20
|
+
'documentation_uri' => 'https://www.rubydoc.info/gems/cuke_slicer',
|
21
|
+
'homepage_uri' => 'https://github.com/enkessler/cuke_slicer',
|
22
|
+
'source_code_uri' => 'https://github.com/enkessler/cuke_slicer'
|
23
|
+
}
|
20
24
|
|
21
|
-
|
25
|
+
# Specify which files should be added to the gem when it is released.
|
26
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
27
|
+
spec.files = Dir.chdir(File.expand_path('', __dir__)) do
|
28
|
+
source_controlled_files = `git ls-files -z`.split("\x0")
|
29
|
+
source_controlled_files.keep_if { |file| file =~ %r{^(lib|testing/cucumber/features)} }
|
30
|
+
source_controlled_files + ['README.md', 'LICENSE.txt', 'CHANGELOG.md', 'cuke_slicer.gemspec']
|
31
|
+
end
|
32
|
+
spec.require_paths = ['lib']
|
22
33
|
|
23
|
-
spec.
|
34
|
+
spec.required_ruby_version = '>= 2.3', '< 4.0'
|
24
35
|
|
36
|
+
spec.add_runtime_dependency 'cuke_modeler', '>= 3.2', '< 4.0'
|
37
|
+
|
38
|
+
spec.add_development_dependency 'childprocess', '< 5.0'
|
39
|
+
spec.add_development_dependency 'ffi', '< 2.0' # This is an invisible dependency for the `childprocess` gem on Windows
|
25
40
|
spec.add_development_dependency 'bundler', '< 3.0'
|
26
41
|
spec.add_development_dependency 'rake', '< 13.0.0'
|
27
|
-
spec.add_development_dependency
|
42
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
28
43
|
spec.add_development_dependency 'cucumber', '< 5.0.0'
|
29
|
-
spec.add_development_dependency 'simplecov', '
|
30
|
-
spec.add_development_dependency
|
31
|
-
spec.add_development_dependency 'coveralls', '< 1.0.0'
|
44
|
+
spec.add_development_dependency 'simplecov', '< 1.0.0'
|
45
|
+
spec.add_development_dependency 'simplecov-lcov', '< 1.0'
|
32
46
|
spec.add_development_dependency 'rainbow', '< 4.0.0'
|
33
|
-
|
47
|
+
spec.add_development_dependency 'rubocop', '<= 0.50.0' # RuboCop can not lint against Ruby 2.0 after this version
|
48
|
+
spec.add_development_dependency 'yard', '< 1.0'
|
34
49
|
end
|
@@ -1,22 +1,24 @@
|
|
1
|
-
require
|
1
|
+
require 'cuke_slicer/helpers/helpers'
|
2
2
|
|
3
3
|
|
4
4
|
# Internal helper module that is not part of the public API. Subject to change at any time.
|
5
5
|
# :nodoc: all
|
6
6
|
module CukeSlicer
|
7
|
+
# private
|
7
8
|
class NestedTagCollection
|
8
9
|
|
9
10
|
include Helpers
|
10
11
|
|
11
12
|
|
12
|
-
def initialize
|
13
|
+
def initialize(collection)
|
13
14
|
self.nested_collection = collection
|
14
15
|
end
|
15
16
|
|
17
|
+
# private
|
16
18
|
def validate
|
17
19
|
nested_collection.each do |element|
|
18
|
-
raise(ArgumentError,
|
19
|
-
raise(ArgumentError, "Filter '#{element}' must be a String or Regexp. Got #{element.class}") unless str_regex?(element)
|
20
|
+
raise(ArgumentError, 'Tag filters cannot be nested more than one level deep.') if element.is_a?(Array)
|
21
|
+
raise(ArgumentError, "Filter '#{element}' must be a String or Regexp. Got #{element.class}") unless str_regex?(element) # rubocop:disable Metrics/LineLength
|
20
22
|
end
|
21
23
|
end
|
22
24
|
|
@@ -1,18 +1,20 @@
|
|
1
|
-
require
|
1
|
+
require 'cuke_slicer/helpers/helpers'
|
2
2
|
|
3
3
|
|
4
4
|
# Internal helper module that is not part of the public API. Subject to change at any time.
|
5
5
|
# :nodoc: all
|
6
6
|
module CukeSlicer
|
7
|
+
# private
|
7
8
|
class PathCollection
|
8
9
|
|
9
10
|
include Helpers
|
10
11
|
|
11
12
|
|
12
|
-
def initialize
|
13
|
+
def initialize(filter_values)
|
13
14
|
self.filter_values = filter_values
|
14
15
|
end
|
15
16
|
|
17
|
+
# private
|
16
18
|
def validate
|
17
19
|
filter_values.each do |val|
|
18
20
|
raise(ArgumentError, "Filter '#{val}' must be a String or Regexp. Got #{val.class}") unless str_regex?(val)
|
@@ -1,22 +1,24 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'cuke_slicer/helpers/helpers'
|
2
|
+
require 'cuke_slicer/collections/nested_tag_collection'
|
3
3
|
|
4
4
|
|
5
5
|
# Internal helper module that is not part of the public API. Subject to change at any time.
|
6
6
|
# :nodoc: all
|
7
7
|
module CukeSlicer
|
8
|
+
# private
|
8
9
|
class TagCollection
|
9
10
|
|
10
11
|
include Helpers
|
11
12
|
|
12
13
|
|
13
|
-
def initialize
|
14
|
+
def initialize(parameters)
|
14
15
|
self.filter_values = parameters
|
15
16
|
end
|
16
17
|
|
18
|
+
# private
|
17
19
|
def validate
|
18
20
|
filter_values.each do |val|
|
19
|
-
raise(ArgumentError, "Filter '#{val}' must be a String, Regexp, or Array. Got #{val.class}") unless str_regex_arr?(val)
|
21
|
+
raise(ArgumentError, "Filter '#{val}' must be a String, Regexp, or Array. Got #{val.class}") unless str_regex_arr?(val) # rubocop:disable Metrics/LineLength
|
20
22
|
NestedTagCollection.new(val).validate if val.is_a?(Array)
|
21
23
|
end
|
22
24
|
end
|
@@ -1,10 +1,12 @@
|
|
1
1
|
# Internal helper module that is not part of the public API. Subject to change at any time.
|
2
2
|
# :nodoc: all
|
3
3
|
module CukeSlicer
|
4
|
+
# private
|
4
5
|
class DirectoryExtractor
|
5
6
|
|
7
|
+
# private
|
6
8
|
def extract(target, filters, format, &block)
|
7
|
-
|
9
|
+
[].tap do |test_cases|
|
8
10
|
target.feature_files.each do |feature_file|
|
9
11
|
test_cases.concat(FileExtractor.new.extract(feature_file, filters, format, &block))
|
10
12
|
end
|
@@ -1,20 +1,25 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require 'cuke_slicer/helpers/matching_helpers'
|
2
|
+
require 'cuke_slicer/helpers/filter_helpers'
|
3
|
+
require 'cuke_slicer/helpers/extraction_helpers'
|
4
4
|
|
5
|
+
# TODO: get rid of this class
|
6
|
+
# rubocop:disable Metrics/AbcSize
|
5
7
|
|
6
8
|
# Internal helper module that is not part of the public API. Subject to change at any time.
|
7
9
|
# :nodoc: all
|
8
10
|
module CukeSlicer
|
11
|
+
# private
|
9
12
|
class FileExtractor
|
10
13
|
|
11
14
|
include ExtractionHelpers
|
12
15
|
|
13
16
|
|
17
|
+
# private
|
14
18
|
def extract(target, filters, format, &block)
|
15
|
-
|
19
|
+
[].tap do |test_cases|
|
16
20
|
unless target.feature.nil?
|
17
21
|
tests = target.feature.tests
|
22
|
+
tests += target.feature.rules.flat_map(&:tests)
|
18
23
|
|
19
24
|
runnable_elements = extract_runnable_elements(extract_runnable_block_elements(tests, filters, &block))
|
20
25
|
|
@@ -32,3 +37,5 @@ module CukeSlicer
|
|
32
37
|
|
33
38
|
end
|
34
39
|
end
|
40
|
+
|
41
|
+
# rubocop:enable Metrics/AbcSize
|
@@ -1,29 +1,31 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require 'cuke_slicer/helpers/helpers'
|
2
|
+
require 'cuke_slicer/collections/tag_collection'
|
3
|
+
require 'cuke_slicer/collections/path_collection'
|
4
4
|
|
5
5
|
|
6
6
|
# Internal helper module that is not part of the public API. Subject to change at any time.
|
7
7
|
# :nodoc: all
|
8
8
|
module CukeSlicer
|
9
|
+
# private
|
9
10
|
class FilterSet
|
10
11
|
|
11
12
|
include Helpers
|
12
13
|
|
13
14
|
|
14
|
-
def initialize
|
15
|
+
def initialize(filter_type, filter_value)
|
15
16
|
self.filter_type = filter_type
|
16
17
|
self.filter_value = filter_value
|
17
18
|
end
|
18
19
|
|
20
|
+
# private
|
19
21
|
def validate
|
20
22
|
block_unknown
|
21
23
|
block_invalid
|
22
24
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
25
|
+
return unless filter_value.is_a?(Array)
|
26
|
+
|
27
|
+
TagCollection.new(filter_value).validate if tag?(filter_type)
|
28
|
+
PathCollection.new(filter_value).validate if path?(filter_type)
|
27
29
|
end
|
28
30
|
|
29
31
|
|
@@ -31,11 +33,11 @@ module CukeSlicer
|
|
31
33
|
|
32
34
|
|
33
35
|
def block_unknown
|
34
|
-
raise(ArgumentError, "Unknown filter '#{filter_type}'") unless CukeSlicer::Slicer.known_filters.include?(filter_type)
|
36
|
+
raise(ArgumentError, "Unknown filter '#{filter_type}'") unless CukeSlicer::Slicer.known_filters.include?(filter_type) # rubocop:disable Metrics/LineLength
|
35
37
|
end
|
36
38
|
|
37
39
|
def block_invalid
|
38
|
-
raise(ArgumentError, "Invalid filter '#{filter_value}'. Must be a String, Regexp, or Array thereof. Got #{filter_value.class}") unless str_regex_arr?(filter_value)
|
40
|
+
raise(ArgumentError, "Invalid filter '#{filter_value}'. Must be a String, Regexp, or Array thereof. Got #{filter_value.class}") unless str_regex_arr?(filter_value) # rubocop:disable Metrics/LineLength
|
39
41
|
end
|
40
42
|
|
41
43
|
attr_accessor :filter_type, :filter_value
|
@@ -1,13 +1,19 @@
|
|
1
|
+
# TODO: get rid of this module
|
2
|
+
# rubocop:disable Metrics/AbcSize
|
3
|
+
|
4
|
+
|
1
5
|
# Internal helper module that is not part of the public API. Subject to change at any time.
|
2
6
|
# :nodoc: all
|
3
7
|
module CukeSlicer
|
8
|
+
# private
|
4
9
|
module ExtractionHelpers
|
5
10
|
|
6
11
|
include FilterHelpers
|
7
12
|
|
8
13
|
|
14
|
+
# private
|
9
15
|
def extract_runnable_block_elements(things, filters, &block)
|
10
|
-
|
16
|
+
[].tap do |elements|
|
11
17
|
things.each do |thing|
|
12
18
|
if thing.is_a?(CukeModeler::Outline)
|
13
19
|
elements.concat(thing.examples)
|
@@ -25,14 +31,13 @@ module CukeSlicer
|
|
25
31
|
end
|
26
32
|
end
|
27
33
|
|
34
|
+
# private
|
28
35
|
def extract_runnable_elements(things)
|
29
|
-
|
30
|
-
|
31
|
-
Array.new.tap do |elements|
|
36
|
+
[].tap do |elements|
|
32
37
|
things.each do |thing|
|
33
38
|
if thing.is_a?(CukeModeler::Example)
|
34
39
|
# Slicing in order to remove the parameter row element
|
35
|
-
elements.concat(thing.
|
40
|
+
elements.concat(thing.rows.slice(1, thing.rows.count))
|
36
41
|
else
|
37
42
|
elements << thing
|
38
43
|
end
|
@@ -42,3 +47,4 @@ module CukeSlicer
|
|
42
47
|
|
43
48
|
end
|
44
49
|
end
|
50
|
+
# rubocop:enable Metrics/AbcSize
|
@@ -1,60 +1,66 @@
|
|
1
1
|
# Internal helper module that is not part of the public API. Subject to change at any time.
|
2
2
|
# :nodoc: all
|
3
3
|
module CukeSlicer
|
4
|
+
# private
|
4
5
|
module FilterHelpers
|
5
6
|
|
6
7
|
include MatchingHelpers
|
7
8
|
|
8
9
|
|
10
|
+
# private
|
9
11
|
def apply_custom_filter(elements, &block)
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
12
|
+
return unless block
|
13
|
+
|
14
|
+
elements.reject! do |element|
|
15
|
+
yield(element)
|
14
16
|
end
|
15
17
|
end
|
16
18
|
|
19
|
+
# private
|
17
20
|
def filter_excluded_tags(elements, filters)
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
21
|
+
return unless filters
|
22
|
+
|
23
|
+
filters = [filters] unless filters.is_a?(Array)
|
24
|
+
|
25
|
+
return if filters.empty?
|
26
|
+
|
27
|
+
elements.reject! do |element|
|
28
|
+
matching_tag?(element, filters)
|
26
29
|
end
|
27
30
|
end
|
28
31
|
|
32
|
+
# private
|
29
33
|
def filter_included_tags(elements, filters)
|
30
|
-
|
31
|
-
|
34
|
+
return unless filters
|
35
|
+
|
36
|
+
filters = [filters] unless filters.is_a?(Array)
|
32
37
|
|
33
|
-
|
34
|
-
|
35
|
-
end
|
38
|
+
elements.keep_if do |element|
|
39
|
+
matching_tag?(element, filters)
|
36
40
|
end
|
37
41
|
end
|
38
42
|
|
43
|
+
# private
|
39
44
|
def filter_excluded_paths(elements, filters)
|
40
|
-
|
41
|
-
filters = [filters] unless filters.is_a?(Array)
|
45
|
+
return unless filters
|
42
46
|
|
43
|
-
|
44
|
-
|
45
|
-
|
47
|
+
filters = [filters] unless filters.is_a?(Array)
|
48
|
+
|
49
|
+
elements.reject! do |element|
|
50
|
+
matching_path?(element, filters)
|
46
51
|
end
|
47
52
|
end
|
48
53
|
|
54
|
+
# private
|
49
55
|
def filter_included_paths(elements, filters)
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
56
|
+
return unless filters
|
57
|
+
|
58
|
+
filters = [filters] unless filters.is_a?(Array)
|
59
|
+
|
60
|
+
return if filters.empty?
|
61
|
+
|
62
|
+
elements.keep_if do |element|
|
63
|
+
matching_path?(element, filters)
|
58
64
|
end
|
59
65
|
end
|
60
66
|
|
@@ -1,21 +1,22 @@
|
|
1
1
|
# Internal helper module that is not part of the public API. Subject to change at any time.
|
2
2
|
# :nodoc: all
|
3
3
|
module CukeSlicer
|
4
|
+
# private
|
4
5
|
module Helpers
|
5
6
|
|
6
7
|
def str_regex?(parameter)
|
7
|
-
parameter.is_a?(String)
|
8
|
+
parameter.is_a?(String) || parameter.is_a?(Regexp)
|
8
9
|
end
|
9
10
|
|
10
11
|
def str_regex_arr?(parameter)
|
11
|
-
parameter.is_a?(String)
|
12
|
+
parameter.is_a?(String) || parameter.is_a?(Regexp) || parameter.is_a?(Array)
|
12
13
|
end
|
13
14
|
|
14
|
-
def
|
15
|
+
def tag?(parameter)
|
15
16
|
parameter.to_s =~ /tag/
|
16
17
|
end
|
17
18
|
|
18
|
-
def
|
19
|
+
def path?(parameter)
|
19
20
|
parameter.to_s =~ /path/
|
20
21
|
end
|
21
22
|
|
@@ -1,15 +1,17 @@
|
|
1
1
|
# Internal helper module that is not part of the public API. Subject to change at any time.
|
2
2
|
# :nodoc: all
|
3
3
|
module CukeSlicer
|
4
|
+
# private
|
4
5
|
module MatchingHelpers
|
5
6
|
|
7
|
+
# private
|
6
8
|
def matching_tag?(element, filters)
|
7
9
|
filters.each do |filter|
|
8
|
-
if filter.is_a?(Array)
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
filter_match = if filter.is_a?(Array)
|
11
|
+
or_filter_match(element, filter)
|
12
|
+
else
|
13
|
+
and_filter_match(element, filter)
|
14
|
+
end
|
13
15
|
|
14
16
|
return false unless filter_match
|
15
17
|
end
|
@@ -17,19 +19,21 @@ module CukeSlicer
|
|
17
19
|
true
|
18
20
|
end
|
19
21
|
|
22
|
+
# private
|
20
23
|
def and_filter_match(element, filter)
|
21
24
|
filter_match(element, filter)
|
22
25
|
end
|
23
26
|
|
27
|
+
# private
|
24
28
|
def or_filter_match(element, filters)
|
25
29
|
filters.any? do |filter|
|
26
30
|
filter_match(element, filter)
|
27
31
|
end
|
28
32
|
end
|
29
33
|
|
34
|
+
# private
|
30
35
|
def filter_match(element, filter)
|
31
|
-
tag_values = element.all_tags
|
32
|
-
tag_values = tag_values.collect { |tag| tag.name } unless Gem.loaded_specs['cuke_modeler'].version.version[/^[0]/]
|
36
|
+
tag_values = element.all_tags.map(&:name)
|
33
37
|
|
34
38
|
if filter.is_a?(Regexp)
|
35
39
|
tag_values.any? { |tag| tag =~ filter }
|
@@ -38,6 +42,7 @@ module CukeSlicer
|
|
38
42
|
end
|
39
43
|
end
|
40
44
|
|
45
|
+
# private
|
41
46
|
def matching_path?(element, filters)
|
42
47
|
filters.any? do |filtered_path|
|
43
48
|
if filtered_path.is_a?(Regexp)
|
data/lib/cuke_slicer/slicer.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
|
1
|
+
require 'cuke_slicer/extractors/directory_extractor'
|
2
|
+
require 'cuke_slicer/extractors/file_extractor'
|
3
|
+
require 'cuke_slicer/filters/filter_set'
|
5
4
|
|
5
|
+
# TODO: refactor all of this
|
6
|
+
# rubocop:disable Metrics/AbcSize, Style/OptionalArguments
|
6
7
|
module CukeSlicer
|
7
8
|
|
8
9
|
# The object responsible for slicing up a Cucumber test suite into discrete test cases.
|
@@ -32,29 +33,23 @@ module CukeSlicer
|
|
32
33
|
begin
|
33
34
|
target = File.directory?(target) ? CukeModeler::Directory.new(target) : CukeModeler::FeatureFile.new(target)
|
34
35
|
rescue => e
|
35
|
-
|
36
|
-
|
37
|
-
else
|
38
|
-
raise e
|
39
|
-
end
|
40
|
-
|
36
|
+
raise e unless e.message =~ /lexing|parsing/i
|
37
|
+
raise(ArgumentError, "A syntax or lexing problem was encountered while trying to parse #{target}")
|
41
38
|
end
|
42
39
|
|
43
40
|
if target.is_a?(CukeModeler::Directory)
|
44
|
-
|
41
|
+
DirectoryExtractor.new.extract(target, filters, format, &block)
|
45
42
|
else
|
46
|
-
|
43
|
+
FileExtractor.new.extract(target, filters, format, &block)
|
47
44
|
end
|
48
|
-
|
49
|
-
sliced_tests
|
50
45
|
end
|
51
46
|
|
52
47
|
# The filtering options that are currently supported by the slicer.
|
53
48
|
def self.known_filters
|
54
|
-
[
|
55
|
-
|
56
|
-
|
57
|
-
|
49
|
+
%i[excluded_tags
|
50
|
+
included_tags
|
51
|
+
excluded_paths
|
52
|
+
included_paths]
|
58
53
|
end
|
59
54
|
|
60
55
|
|
@@ -62,7 +57,7 @@ module CukeSlicer
|
|
62
57
|
|
63
58
|
|
64
59
|
def validate_target(target)
|
65
|
-
raise(ArgumentError, "File or directory '#{target}' does not exist") unless File.
|
60
|
+
raise(ArgumentError, "File or directory '#{target}' does not exist") unless File.exist?(target.to_s)
|
66
61
|
end
|
67
62
|
|
68
63
|
def validate_filters(filters)
|
@@ -71,8 +66,9 @@ module CukeSlicer
|
|
71
66
|
end
|
72
67
|
|
73
68
|
def validate_format(format)
|
74
|
-
raise(ArgumentError, "Invalid Output Format: #{format}") unless [
|
69
|
+
raise(ArgumentError, "Invalid Output Format: #{format}") unless %i[test_object file_line].include?(format)
|
75
70
|
end
|
76
71
|
|
77
72
|
end
|
78
73
|
end
|
74
|
+
# rubocop:enable Metrics/AbcSize, Style/OptionalArguments
|