minitag 0.4.1 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +9 -5
- data/.rubocop.yml +12 -5
- data/Gemfile.lock +22 -20
- data/README.md +28 -10
- data/lib/minitag/context.rb +16 -3
- data/lib/minitag/minitest_tag.rb +35 -0
- data/lib/minitag/tag_extension.rb +4 -15
- data/lib/minitag/tag_registry.rb +21 -6
- data/lib/minitag/version.rb +1 -1
- data/lib/minitest/minitag_plugin.rb +1 -1
- data/minitag.gemspec +4 -2
- metadata +9 -9
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 02416e0cda7083e357dc0342f0d6d3f86bb738f6040e8d43e08d49c64acde976
|
|
4
|
+
data.tar.gz: b62593ed9ed8180006488b7cbeb01c536eb79b0b52f6b184795c98d17adeb643
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d327bd13b733bdfc9f1c0335f6f60c73c3ef621f67890389091a9aea23e2f6157074d4e4cc6c81efcec4ccfcc5f59cb42c44d12c8e54bd121102dcdabe782714
|
|
7
|
+
data.tar.gz: 3eab456a164f8272f761906de05f3737d42fa9ba1053682c4a90f43026b9f331d00c4a8602fba0a2167eec2af0fc77ed43a51a557d26f74045ed8546fcab864f
|
data/.github/workflows/ci.yml
CHANGED
|
@@ -1,22 +1,26 @@
|
|
|
1
1
|
name: continuous-integration
|
|
2
|
-
on: push
|
|
2
|
+
on: [push, pull_request]
|
|
3
3
|
|
|
4
4
|
jobs:
|
|
5
5
|
ci:
|
|
6
6
|
runs-on: ubuntu-latest
|
|
7
|
+
strategy:
|
|
8
|
+
matrix:
|
|
9
|
+
ruby: [ '2.6', '2.7' ]
|
|
10
|
+
name: Ruby ${{ matrix.ruby }}
|
|
7
11
|
steps:
|
|
8
12
|
- uses: actions/checkout@v2
|
|
9
|
-
- name: Set up Ruby
|
|
13
|
+
- name: Set up Ruby ${{ matrix.ruby }}
|
|
10
14
|
uses: actions/setup-ruby@v1
|
|
11
15
|
with:
|
|
12
|
-
ruby-version:
|
|
16
|
+
ruby-version: ${{ matrix.ruby }}
|
|
13
17
|
- name: Cache gems
|
|
14
18
|
uses: actions/cache@v2
|
|
15
19
|
with:
|
|
16
20
|
path: vendor/bundle
|
|
17
|
-
key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }}
|
|
21
|
+
key: ${{ runner.os }}-${{ matrix.ruby }}-gem-${{ hashFiles('**/Gemfile.lock') }}
|
|
18
22
|
restore-keys: |
|
|
19
|
-
${{ runner.os }}-gem-
|
|
23
|
+
${{ runner.os }}-${{ matrix.ruby }}-gem-
|
|
20
24
|
- name: Install gems
|
|
21
25
|
run: |
|
|
22
26
|
sed -i '/ruby ".*"/,+1 d' Gemfile
|
data/.rubocop.yml
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
AllCops:
|
|
2
2
|
NewCops: enable
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
Layout/LineLength:
|
|
5
|
+
Max: 120
|
|
6
6
|
|
|
7
|
-
Metrics/
|
|
7
|
+
Metrics/ClassLength:
|
|
8
8
|
Enabled: false
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
Metrics/BlockLength:
|
|
11
|
+
Exclude:
|
|
12
|
+
- 'test/**/*_test.rb'
|
|
12
13
|
|
|
14
|
+
Lint/EmptyBlock:
|
|
15
|
+
Exclude:
|
|
16
|
+
- 'test/**/*_test.rb'
|
|
13
17
|
|
|
18
|
+
Naming/VariableNumber:
|
|
19
|
+
Exclude:
|
|
20
|
+
- 'test/**/*_test.rb'
|
data/Gemfile.lock
CHANGED
|
@@ -1,46 +1,48 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
minitag (0.
|
|
4
|
+
minitag (0.6.2)
|
|
5
5
|
minitest (~> 5.0)
|
|
6
6
|
|
|
7
7
|
GEM
|
|
8
8
|
remote: https://rubygems.org/
|
|
9
9
|
specs:
|
|
10
|
-
ast (2.4.
|
|
11
|
-
minitest (5.14.
|
|
12
|
-
parallel (1.
|
|
13
|
-
parser (
|
|
10
|
+
ast (2.4.2)
|
|
11
|
+
minitest (5.14.4)
|
|
12
|
+
parallel (1.20.1)
|
|
13
|
+
parser (3.0.2.0)
|
|
14
14
|
ast (~> 2.4.1)
|
|
15
15
|
rainbow (3.0.0)
|
|
16
|
-
rake (13.0.
|
|
17
|
-
regexp_parser (1.
|
|
18
|
-
rexml (3.2.
|
|
19
|
-
rubocop (
|
|
16
|
+
rake (13.0.6)
|
|
17
|
+
regexp_parser (2.1.1)
|
|
18
|
+
rexml (3.2.5)
|
|
19
|
+
rubocop (1.18.4)
|
|
20
20
|
parallel (~> 1.10)
|
|
21
|
-
parser (>=
|
|
21
|
+
parser (>= 3.0.0.0)
|
|
22
22
|
rainbow (>= 2.2.2, < 4.0)
|
|
23
|
-
regexp_parser (>= 1.
|
|
23
|
+
regexp_parser (>= 1.8, < 3.0)
|
|
24
24
|
rexml
|
|
25
|
-
rubocop-ast (>=
|
|
25
|
+
rubocop-ast (>= 1.8.0, < 2.0)
|
|
26
26
|
ruby-progressbar (~> 1.7)
|
|
27
|
-
unicode-display_width (>= 1.4.0, <
|
|
28
|
-
rubocop-ast (
|
|
29
|
-
parser (>=
|
|
30
|
-
ruby-progressbar (1.
|
|
31
|
-
unicode-display_width (
|
|
27
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
|
28
|
+
rubocop-ast (1.8.0)
|
|
29
|
+
parser (>= 3.0.1.1)
|
|
30
|
+
ruby-progressbar (1.11.0)
|
|
31
|
+
unicode-display_width (2.0.0)
|
|
32
32
|
|
|
33
33
|
PLATFORMS
|
|
34
34
|
ruby
|
|
35
|
+
universal-darwin-20
|
|
36
|
+
x86_64-linux
|
|
35
37
|
|
|
36
38
|
DEPENDENCIES
|
|
37
|
-
bundler (
|
|
39
|
+
bundler (>= 2.2.10)
|
|
38
40
|
minitag!
|
|
39
41
|
rake (>= 12.3.3)
|
|
40
|
-
rubocop (~>
|
|
42
|
+
rubocop (~> 1.18)
|
|
41
43
|
|
|
42
44
|
RUBY VERSION
|
|
43
45
|
ruby 2.6.3p62
|
|
44
46
|
|
|
45
47
|
BUNDLED WITH
|
|
46
|
-
|
|
48
|
+
2.2.25
|
data/README.md
CHANGED
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
# Minitag
|
|
4
4
|
|
|
5
|
-
A simple gem that allow developers to
|
|
6
|
-
|
|
5
|
+
A simple gem that allow developers using minitest to specify tags for their classes and tests, and run their test suite based on these tags.
|
|
6
|
+
|
|
7
|
+
This gem should be framework agnostic, let me know if you encounter any problems
|
|
8
|
+
running this within the framework of your choice.
|
|
7
9
|
|
|
8
10
|
## Installation
|
|
9
11
|
|
|
@@ -21,20 +23,18 @@ $ gem install minitag
|
|
|
21
23
|
|
|
22
24
|
## Usage
|
|
23
25
|
|
|
24
|
-
### Setup
|
|
25
|
-
|
|
26
|
-
Require `minitag` in our `test_helper.rb`:
|
|
27
|
-
|
|
28
|
-
`require 'minitag'`
|
|
29
|
-
|
|
30
26
|
### Adding tags
|
|
31
27
|
|
|
32
|
-
We can tag specific tests with one or more tags.
|
|
28
|
+
We can tag specific classes or tests with one or more tags.
|
|
33
29
|
|
|
34
|
-
It is important to point out that tags associated with a test have no concept of being inclusive or exclusive. This distinction is only valid for [tag filters](#running-tests-with-tag-filters).
|
|
30
|
+
It is important to point out that tags associated with a class or test have no concept of being inclusive or exclusive. This distinction is only valid for [tag filters](#running-tests-with-tag-filters).
|
|
35
31
|
|
|
36
32
|
```rb
|
|
37
33
|
class MyTest < Minitest::Test
|
|
34
|
+
# Every test within this class will inherit this tag
|
|
35
|
+
tag_namespace 'my_namespace_tag'
|
|
36
|
+
|
|
37
|
+
# Only the test below will have this tag
|
|
38
38
|
tag 'my_tag', 'another_tag'
|
|
39
39
|
def test_hello_minitest
|
|
40
40
|
# ...
|
|
@@ -70,6 +70,24 @@ $ bundle exec rake test --tag '~unit'
|
|
|
70
70
|
$ bundle exec rake test --tag 'unit' --tag '~parallel'
|
|
71
71
|
```
|
|
72
72
|
|
|
73
|
+
## FAQ
|
|
74
|
+
|
|
75
|
+
### Is this gem compatible with Rails?
|
|
76
|
+
|
|
77
|
+
Yes. Found any problems? Please open an issue or reach out to me.
|
|
78
|
+
|
|
79
|
+
### Is this gem compatible with the spec part of minitest?
|
|
80
|
+
|
|
81
|
+
For the most part yes, but tagging `describe` blocks are not supported.
|
|
82
|
+
|
|
83
|
+
### When should I use this gem?
|
|
84
|
+
|
|
85
|
+
- When there's a need to split a test suite into different CI steps.
|
|
86
|
+
- During development, it's helpful to have extra flexibility when running a big
|
|
87
|
+
test suite.
|
|
88
|
+
- When there are tests that you want to run only occasionality. For example,
|
|
89
|
+
tests that perform network calls or have expensive side effects.
|
|
90
|
+
|
|
73
91
|
## Development
|
|
74
92
|
|
|
75
93
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/minitag/context.rb
CHANGED
|
@@ -18,12 +18,25 @@ module Minitag
|
|
|
18
18
|
# @param [Array] tags the collection of tags.
|
|
19
19
|
#
|
|
20
20
|
# @return [void]
|
|
21
|
-
def
|
|
21
|
+
def add_test_tags(namespace:, name:, tags:)
|
|
22
22
|
@tag_registry.add(namespace: namespace, name: name, tags: tags)
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
+
# Add tags to an entire namespace. Every test within the namespace will
|
|
26
|
+
# share these tags.
|
|
27
|
+
#
|
|
28
|
+
# @param [String] namespace the namespace that contain tests.
|
|
29
|
+
# @param [Array] tags the collection of tags.
|
|
30
|
+
#
|
|
31
|
+
# @return [void]
|
|
32
|
+
def add_namespace_tags(namespace:, tags:)
|
|
33
|
+
@tag_registry.add_for_namespace(namespace: namespace, tags: tags)
|
|
34
|
+
end
|
|
35
|
+
|
|
25
36
|
# Adds a filter tag.
|
|
26
|
-
#
|
|
37
|
+
#
|
|
38
|
+
# Tags with a ~ prefix are treated as exclusive filters or inclusive filters
|
|
39
|
+
# otherwise.
|
|
27
40
|
#
|
|
28
41
|
# param [String] name the name of the filter tag.
|
|
29
42
|
#
|
|
@@ -61,7 +74,7 @@ module Minitag
|
|
|
61
74
|
def match?(namespace:, name:)
|
|
62
75
|
return true if no_filters?
|
|
63
76
|
|
|
64
|
-
tags = @tag_registry.
|
|
77
|
+
tags = @tag_registry.get(namespace: namespace, name: name)
|
|
65
78
|
match_inclusive_filters?(tags) && match_exclusive_filters?(tags)
|
|
66
79
|
end
|
|
67
80
|
|
data/lib/minitag/minitest_tag.rb
CHANGED
|
@@ -3,6 +3,24 @@
|
|
|
3
3
|
module Minitag
|
|
4
4
|
# Module used to extend Minitest::Test with the tag method.
|
|
5
5
|
module MinitestTag
|
|
6
|
+
# Add tags to be associated with an entire class that inherits from
|
|
7
|
+
# Minitest::Test. Every test that belongs to this class will also inherit
|
|
8
|
+
# these tags.
|
|
9
|
+
#
|
|
10
|
+
# It is important to notice that tags associated with a class have no
|
|
11
|
+
# concept of being inclusive or exclusive. This distinction is only
|
|
12
|
+
# valid for tag filters.
|
|
13
|
+
#
|
|
14
|
+
# @param [Array] tags the list of tags to be associated with a test class.
|
|
15
|
+
#
|
|
16
|
+
# @return [void]
|
|
17
|
+
def tag_namespace(*tags)
|
|
18
|
+
Minitag.context.add_namespace_tags(
|
|
19
|
+
namespace: to_s,
|
|
20
|
+
tags: tags.map { |tag| tag.to_s.strip.downcase }
|
|
21
|
+
)
|
|
22
|
+
end
|
|
23
|
+
|
|
6
24
|
# Add tags to be associated with the next test definition and extends the
|
|
7
25
|
# class from which the tag method is being used with Minitag::TagExtension.
|
|
8
26
|
#
|
|
@@ -17,6 +35,23 @@ module Minitag
|
|
|
17
35
|
Minitag.pending_tags = tags.map { |tag| tag.to_s.strip.downcase }
|
|
18
36
|
Minitag.register_for_extension(self)
|
|
19
37
|
end
|
|
38
|
+
|
|
39
|
+
# Decides which methods to run based on an Array of test names provided by
|
|
40
|
+
# the superclass and the tags defined within test classes.
|
|
41
|
+
#
|
|
42
|
+
# Invariants:
|
|
43
|
+
# - Returns the full list of test names when the test suite runs without
|
|
44
|
+
# any tag filtering.
|
|
45
|
+
#
|
|
46
|
+
# @return [Array] the list of test names that should run.
|
|
47
|
+
def runnable_methods
|
|
48
|
+
methods = super.dup
|
|
49
|
+
return methods if Minitag.context.no_filters?
|
|
50
|
+
|
|
51
|
+
methods.select do |runnable_method|
|
|
52
|
+
Minitag.context.match?(namespace: to_s, name: runnable_method)
|
|
53
|
+
end
|
|
54
|
+
end
|
|
20
55
|
end
|
|
21
56
|
end
|
|
22
57
|
|
|
@@ -1,28 +1,17 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Minitag
|
|
4
|
-
#
|
|
5
|
-
#
|
|
6
|
-
# - Associate tags with tests
|
|
7
|
-
# - Filter tests based on the specified tags
|
|
4
|
+
# Responsible for listening to added methods and associating tags
|
|
5
|
+
# with those.
|
|
8
6
|
module TagExtension
|
|
9
7
|
define_method(:method_added) do |name|
|
|
10
8
|
if name[/\Atest_/]
|
|
11
|
-
Minitag.context.
|
|
12
|
-
namespace:
|
|
9
|
+
Minitag.context.add_test_tags(
|
|
10
|
+
namespace: to_s, name: name, tags: Minitag.pending_tags
|
|
13
11
|
)
|
|
14
12
|
|
|
15
13
|
Minitag.pending_tags = []
|
|
16
14
|
end
|
|
17
15
|
end
|
|
18
|
-
|
|
19
|
-
def runnable_methods
|
|
20
|
-
methods = super.dup
|
|
21
|
-
return methods if Minitag.context.no_filters?
|
|
22
|
-
|
|
23
|
-
methods.select do |runnable_method|
|
|
24
|
-
Minitag.context.match?(namespace: self, name: runnable_method)
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
16
|
end
|
|
28
17
|
end
|
data/lib/minitag/tag_registry.rb
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Minitag
|
|
4
|
-
# Stores tags associated with a
|
|
5
|
-
#
|
|
4
|
+
# Stores tags associated with a namespace or a single test case.
|
|
5
|
+
#
|
|
6
|
+
# A namespace is usually the class which tests belongs to.
|
|
6
7
|
class TagRegistry
|
|
7
8
|
def initialize
|
|
8
|
-
@
|
|
9
|
+
@registry = {}
|
|
9
10
|
end
|
|
10
11
|
|
|
11
12
|
# Associates tags with a name taking into account its namespace.
|
|
@@ -18,7 +19,19 @@ module Minitag
|
|
|
18
19
|
#
|
|
19
20
|
# @return [void]
|
|
20
21
|
def add(namespace:, name:, tags:)
|
|
21
|
-
@
|
|
22
|
+
@registry[key(namespace, name)] = Set.new(tags)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Associates tags with a namespace.
|
|
26
|
+
#
|
|
27
|
+
# Duplicated tags will be removed during this operation.
|
|
28
|
+
#
|
|
29
|
+
# @param [String] namespace the context which a test name belongs.
|
|
30
|
+
# @param [Array] tags the collection of tags associated with a test.
|
|
31
|
+
#
|
|
32
|
+
# @return [void]
|
|
33
|
+
def add_for_namespace(namespace:, tags:)
|
|
34
|
+
@registry[namespace] = Set.new(tags)
|
|
22
35
|
end
|
|
23
36
|
|
|
24
37
|
# Fetches tags associated with a test name and namespace.
|
|
@@ -27,8 +40,10 @@ module Minitag
|
|
|
27
40
|
# @param [String] name the test name.
|
|
28
41
|
#
|
|
29
42
|
# @return [Set] the tags associated with the specified namespace and test name.
|
|
30
|
-
def
|
|
31
|
-
@
|
|
43
|
+
def get(namespace:, name:)
|
|
44
|
+
@registry.fetch(namespace, Set.new).union(
|
|
45
|
+
@registry.fetch(key(namespace, name), Set.new)
|
|
46
|
+
)
|
|
32
47
|
end
|
|
33
48
|
|
|
34
49
|
private
|
data/lib/minitag/version.rb
CHANGED
data/minitag.gemspec
CHANGED
|
@@ -23,9 +23,11 @@ Gem::Specification.new do |spec|
|
|
|
23
23
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
24
24
|
spec.require_paths = ['lib']
|
|
25
25
|
|
|
26
|
-
spec.add_development_dependency 'bundler', '
|
|
26
|
+
spec.add_development_dependency 'bundler', '>= 2.2.10'
|
|
27
27
|
spec.add_development_dependency 'rake', '>= 12.3.3'
|
|
28
|
-
spec.add_development_dependency 'rubocop', '~>
|
|
28
|
+
spec.add_development_dependency 'rubocop', '~> 1.18'
|
|
29
29
|
|
|
30
30
|
spec.add_dependency 'minitest', '~> 5.0'
|
|
31
|
+
|
|
32
|
+
spec.required_ruby_version = '>= 2.6.0'
|
|
31
33
|
end
|
metadata
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: minitag
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.6.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Bernardo de Araujo
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2021-07-31 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- - "
|
|
17
|
+
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version:
|
|
19
|
+
version: 2.2.10
|
|
20
20
|
type: :development
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
|
-
- - "
|
|
24
|
+
- - ">="
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version:
|
|
26
|
+
version: 2.2.10
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: rake
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -44,14 +44,14 @@ dependencies:
|
|
|
44
44
|
requirements:
|
|
45
45
|
- - "~>"
|
|
46
46
|
- !ruby/object:Gem::Version
|
|
47
|
-
version:
|
|
47
|
+
version: '1.18'
|
|
48
48
|
type: :development
|
|
49
49
|
prerelease: false
|
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
51
|
requirements:
|
|
52
52
|
- - "~>"
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
|
-
version:
|
|
54
|
+
version: '1.18'
|
|
55
55
|
- !ruby/object:Gem::Dependency
|
|
56
56
|
name: minitest
|
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -105,7 +105,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
105
105
|
requirements:
|
|
106
106
|
- - ">="
|
|
107
107
|
- !ruby/object:Gem::Version
|
|
108
|
-
version:
|
|
108
|
+
version: 2.6.0
|
|
109
109
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
110
110
|
requirements:
|
|
111
111
|
- - ">="
|