test_file_finder 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 +4 -4
- data/.gitignore +1 -0
- data/.gitlab-ci.yml +25 -10
- data/Gemfile.lock +30 -26
- data/README.md +12 -8
- data/feature/tff_exe_spec.rb +50 -10
- data/fixtures/features/smoke.feature +1 -0
- data/fixtures/mapping.yml +18 -8
- data/fixtures/spec/smoke_spec.rb +1 -0
- data/fixtures/spec/views/main_spec.rb +1 -0
- data/lib/test_file_finder/mapping_strategies/pattern_matching.rb +5 -3
- data/lib/test_file_finder/version.rb +1 -1
- data/test_file_finder.gemspec +3 -3
- metadata +20 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6270de89006e6f674e716156d8a92063126b235496cc7d149cadb09fe9bd6481
|
4
|
+
data.tar.gz: e8cfa86f850151e53e771a141e2fd2f34a77439d2347b6202c322825d1e2ce46
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ef8a72686e8360cc926c7b6d286e1b5769b4bdfedc5662d76d80e5527e15f3775af6138b484aa66075796c5b05145b16ef3ea6288e329f069a4b525e58293c0
|
7
|
+
data.tar.gz: cb524babc76288de16f90824e34e1da0d4a1e2ac20e833827aeb8201c9ec31104ea2a6e098dd6a5864c3f8f1e62d92cfe5049dd10028a7a5d12f75d373d070dc
|
data/.gitignore
CHANGED
data/.gitlab-ci.yml
CHANGED
@@ -1,19 +1,34 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
---
|
3
2
|
stages:
|
4
3
|
- test
|
5
4
|
- deploy
|
6
5
|
|
7
|
-
|
8
|
-
|
9
|
-
rules:
|
10
|
-
- if: $CI
|
6
|
+
variables:
|
7
|
+
BUNDLE_FROZEN: "true"
|
11
8
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
9
|
+
rspec:
|
10
|
+
stage: test
|
11
|
+
image: "ruby:$RUBY_VERSION"
|
12
|
+
cache:
|
13
|
+
paths:
|
14
|
+
- vendor/ruby
|
15
|
+
before_script:
|
16
|
+
- ruby -v # Print out ruby version for debugging
|
17
|
+
- gem install bundler -v 2.4.13
|
18
|
+
- bundle config set --local path "vendor/ruby/$RUBY_VERSION"
|
19
|
+
- bundle install
|
20
|
+
script:
|
21
|
+
- bundle exec rspec
|
22
|
+
- bundle exec rspec feature
|
23
|
+
parallel:
|
24
|
+
matrix:
|
25
|
+
- RUBY_VERSION:
|
26
|
+
- "2.7"
|
27
|
+
- "3.0"
|
28
|
+
- "3.1"
|
29
|
+
- "3.2"
|
16
30
|
|
17
31
|
include:
|
32
|
+
- template: 'Workflows/MergeRequest-Pipelines.gitlab-ci.yml'
|
18
33
|
- project: 'gitlab-org/quality/pipeline-common'
|
19
34
|
file: '/ci/gem-release.yml'
|
data/Gemfile.lock
CHANGED
@@ -1,38 +1,42 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
test_file_finder (0.
|
5
|
-
faraday (
|
4
|
+
test_file_finder (0.2.0)
|
5
|
+
faraday (>= 2.0.1, >= 1.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
addressable (2.
|
11
|
-
public_suffix (>= 2.0.2, <
|
10
|
+
addressable (2.8.4)
|
11
|
+
public_suffix (>= 2.0.2, < 6.0)
|
12
12
|
byebug (11.1.3)
|
13
|
-
crack (0.4.
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
crack (0.4.5)
|
14
|
+
rexml
|
15
|
+
diff-lcs (1.5.0)
|
16
|
+
faraday (2.7.10)
|
17
|
+
faraday-net_http (>= 2.0, < 3.1)
|
18
|
+
ruby2_keywords (>= 0.0.4)
|
19
|
+
faraday-net_http (3.0.2)
|
17
20
|
hashdiff (1.0.1)
|
18
|
-
|
19
|
-
public_suffix (4.0.6)
|
21
|
+
public_suffix (5.0.1)
|
20
22
|
rake (10.5.0)
|
21
|
-
|
22
|
-
|
23
|
-
rspec-
|
24
|
-
rspec-
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
rexml (3.2.5)
|
24
|
+
rspec (3.12.0)
|
25
|
+
rspec-core (~> 3.12.0)
|
26
|
+
rspec-expectations (~> 3.12.0)
|
27
|
+
rspec-mocks (~> 3.12.0)
|
28
|
+
rspec-core (3.12.2)
|
29
|
+
rspec-support (~> 3.12.0)
|
30
|
+
rspec-expectations (3.12.3)
|
28
31
|
diff-lcs (>= 1.2.0, < 2.0)
|
29
|
-
rspec-support (~> 3.
|
30
|
-
rspec-mocks (3.
|
32
|
+
rspec-support (~> 3.12.0)
|
33
|
+
rspec-mocks (3.12.5)
|
31
34
|
diff-lcs (>= 1.2.0, < 2.0)
|
32
|
-
rspec-support (~> 3.
|
33
|
-
rspec-support (3.
|
34
|
-
|
35
|
-
|
35
|
+
rspec-support (~> 3.12.0)
|
36
|
+
rspec-support (3.12.0)
|
37
|
+
ruby2_keywords (0.0.5)
|
38
|
+
webmock (3.18.1)
|
39
|
+
addressable (>= 2.8.0)
|
36
40
|
crack (>= 0.3.2)
|
37
41
|
hashdiff (>= 0.4.0, < 2.0.0)
|
38
42
|
|
@@ -40,12 +44,12 @@ PLATFORMS
|
|
40
44
|
ruby
|
41
45
|
|
42
46
|
DEPENDENCIES
|
43
|
-
bundler (~> 1
|
47
|
+
bundler (~> 2.1)
|
44
48
|
byebug
|
45
49
|
rake (~> 10.0)
|
46
50
|
rspec (~> 3.0)
|
47
51
|
test_file_finder!
|
48
|
-
webmock (~> 3.
|
52
|
+
webmock (~> 3.18)
|
49
53
|
|
50
54
|
BUNDLED WITH
|
51
|
-
2.
|
55
|
+
2.4.13
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# TestFileFinder
|
2
2
|
|
3
|
-
A Ruby gem for
|
3
|
+
A Ruby gem for detecting test files associated with input files.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -46,21 +46,25 @@ $ rspec $(tff $(git diff --name-only master..head))
|
|
46
46
|
|
47
47
|
##### `-f mapping`
|
48
48
|
|
49
|
-
`TestFileFinder` can be used with an optional YAML mapping file to specify the mapping from a source file to a test file.
|
49
|
+
`TestFileFinder` can be used with an optional YAML mapping file to specify the mapping from a `source` file to a `test` file. Both, `source` and `test` can be lists to map multiple files.
|
50
50
|
|
51
51
|
The mapping file is a yaml file containing to entries to match file patterns to its test files. The patterns may include capturing groups to be used to identify the test file. To refer to a captured value in the test file, use the `%s` placeholder. For example:
|
52
52
|
|
53
53
|
```yaml
|
54
54
|
mapping:
|
55
55
|
# maps `app/file.rb` to `spec/file_spec.rb`
|
56
|
-
- source: app/(.+)\.rb
|
57
|
-
test: spec/%s_spec.rb
|
58
|
-
# maps `db/schema.rb` to `spec/db/schema_spec.rb`
|
59
|
-
- source:
|
56
|
+
- source: 'app/(.+)\.rb'
|
57
|
+
test: 'spec/%s_spec.rb'
|
58
|
+
# maps `db/schema.rb` and `db/migrate/*` to `spec/db/schema_spec.rb`
|
59
|
+
- source:
|
60
|
+
- 'db/schema.rb'
|
61
|
+
- 'db/migrate/(.+)'
|
60
62
|
test: spec/db/schema_spec.rb
|
61
|
-
# maps `ee/app/models/ee/user.rb` to `ee/spec/models/user_spec.rb`
|
63
|
+
# maps `ee/app/models/ee/user.rb` to `ee/spec/models/user_spec.rb` and `spec/models/user_spec.rb`
|
62
64
|
- source: ee/app/(.*/)ee/(.+)\.rb
|
63
|
-
test:
|
65
|
+
test:
|
66
|
+
- 'spec/%s%s_spec.rb'
|
67
|
+
- 'ee/spec/%s%s_spec.rb'
|
64
68
|
```
|
65
69
|
|
66
70
|
Command line example:
|
data/feature/tff_exe_spec.rb
CHANGED
@@ -12,16 +12,53 @@ RSpec.describe 'tff exe' do
|
|
12
12
|
let(:files) { 'app/models/test_file_finder_gem_executable_widget.rb' }
|
13
13
|
|
14
14
|
it 'prints matching test files using default rails mapping' do
|
15
|
-
expect(subject).to eq
|
15
|
+
expect(subject).to eq <<~OUTPUT
|
16
|
+
spec/models/test_file_finder_gem_executable_widget_spec.rb
|
17
|
+
OUTPUT
|
16
18
|
end
|
17
19
|
end
|
18
20
|
|
19
21
|
context 'with a yaml mapping' do
|
20
22
|
let(:options) { '-f mapping.yml' }
|
21
|
-
let(:files) { 'db/schema.rb' }
|
22
23
|
|
23
|
-
|
24
|
-
|
24
|
+
context 'with multiple sources' do
|
25
|
+
['db/schema.rb', 'db/migrate/001_init.rb'].each do |file|
|
26
|
+
context "for file #{file}" do
|
27
|
+
let(:files) { file }
|
28
|
+
|
29
|
+
it 'prints matching test files using given yaml mapping' do
|
30
|
+
expect(subject).to eq <<~OUTPUT
|
31
|
+
spec/db/schema_spec.rb
|
32
|
+
OUTPUT
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context 'with multiple tests' do
|
39
|
+
let(:files) { 'spec/models/project_spec.rb' }
|
40
|
+
|
41
|
+
it 'prints matching test files using given yaml mapping' do
|
42
|
+
expect(subject).to eq <<~OUTPUT
|
43
|
+
spec/models/project_spec.rb
|
44
|
+
spec/smoke_spec.rb
|
45
|
+
OUTPUT
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'with multiple sources and tests' do
|
50
|
+
['views/main.html.haml', 'assets/application.css'].each do |file|
|
51
|
+
context "for file #{file}" do
|
52
|
+
let(:files) { file }
|
53
|
+
|
54
|
+
it 'prints matching test files using given yaml mapping' do
|
55
|
+
expect(subject).to eq <<~OUTPUT
|
56
|
+
spec/views/main_spec.rb
|
57
|
+
features/smoke.feature
|
58
|
+
OUTPUT
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
25
62
|
end
|
26
63
|
end
|
27
64
|
|
@@ -30,7 +67,11 @@ RSpec.describe 'tff exe' do
|
|
30
67
|
let(:files) { 'db/schema.rb app/models/project.rb ' }
|
31
68
|
|
32
69
|
it 'prints matching test files using both yaml and json mappings' do
|
33
|
-
expect(subject
|
70
|
+
expect(subject).to eq <<~OUTPUT
|
71
|
+
spec/models/project_spec.rb
|
72
|
+
spec/controllers/projects_controller_spec.rb
|
73
|
+
spec/db/schema_spec.rb
|
74
|
+
OUTPUT
|
34
75
|
end
|
35
76
|
end
|
36
77
|
|
@@ -39,11 +80,10 @@ RSpec.describe 'tff exe' do
|
|
39
80
|
let(:files) { 'app/models/test_file_finder_gem_executable_widget.rb app/models/project.rb' }
|
40
81
|
|
41
82
|
it 'prints matching test files using json mapping' do
|
42
|
-
expect(subject
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
expect(subject.split("\n")).not_to include('spec/models/test_file_finder_gem_executable_widget_spec.rb')
|
83
|
+
expect(subject).to eq <<~OUTPUT
|
84
|
+
spec/models/project_spec.rb
|
85
|
+
spec/controllers/projects_controller_spec.rb
|
86
|
+
OUTPUT
|
47
87
|
end
|
48
88
|
end
|
49
89
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
features tests
|
data/fixtures/mapping.yml
CHANGED
@@ -1,9 +1,19 @@
|
|
1
1
|
mapping:
|
2
|
-
- source: app/(.+)\.rb
|
3
|
-
test: spec/%s_spec.rb
|
4
|
-
- source: lib/(.+)\.rb
|
5
|
-
test: spec/lib/%s_spec.rb
|
6
|
-
- source:
|
7
|
-
|
8
|
-
|
9
|
-
test: spec
|
2
|
+
- source: 'app/(.+)\.rb'
|
3
|
+
test: 'spec/%s_spec.rb'
|
4
|
+
- source: 'lib/(.+)\.rb'
|
5
|
+
test: 'spec/lib/%s_spec.rb'
|
6
|
+
- source:
|
7
|
+
- 'db/schema\.rb'
|
8
|
+
- 'db/migrate/(.+)\.rb'
|
9
|
+
test: 'spec/db/schema_spec.rb'
|
10
|
+
- source: 'spec/(.+)_spec.rb'
|
11
|
+
test:
|
12
|
+
- 'spec/%s_spec.rb'
|
13
|
+
- 'spec/smoke_spec.rb'
|
14
|
+
- source:
|
15
|
+
- 'views/.+\.html\.haml'
|
16
|
+
- 'assets/.+'
|
17
|
+
test:
|
18
|
+
- 'spec/views/main_spec.rb'
|
19
|
+
- 'features/smoke.feature'
|
@@ -0,0 +1 @@
|
|
1
|
+
smoke specs
|
@@ -0,0 +1 @@
|
|
1
|
+
main page specs
|
@@ -11,9 +11,11 @@ module TestFileFinder
|
|
11
11
|
|
12
12
|
new do |mapping|
|
13
13
|
maps.each do |map|
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
Array(map['source']).each do |source|
|
15
|
+
Array(map['test']).each do |test|
|
16
|
+
mapping.relate(source, test)
|
17
|
+
end
|
18
|
+
end
|
17
19
|
end
|
18
20
|
end
|
19
21
|
end
|
data/test_file_finder.gemspec
CHANGED
@@ -33,11 +33,11 @@ Gem::Specification.new do |spec|
|
|
33
33
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
34
34
|
spec.require_paths = ['lib']
|
35
35
|
|
36
|
-
spec.add_runtime_dependency 'faraday', '
|
36
|
+
spec.add_runtime_dependency 'faraday', ['>= 1.0', '>= 2.0.1']
|
37
37
|
|
38
|
-
spec.add_development_dependency 'bundler', '~> 1
|
38
|
+
spec.add_development_dependency 'bundler', '~> 2.1'
|
39
39
|
spec.add_development_dependency 'byebug'
|
40
40
|
spec.add_development_dependency 'rake', '~> 10.0'
|
41
41
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
42
|
-
spec.add_development_dependency 'webmock', '~> 3.
|
42
|
+
spec.add_development_dependency 'webmock', '~> 3.18'
|
43
43
|
end
|
metadata
CHANGED
@@ -1,43 +1,49 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: test_file_finder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GitLab
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-08-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
- - ">="
|
18
21
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
22
|
+
version: 2.0.1
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - "
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.0'
|
30
|
+
- - ">="
|
25
31
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
32
|
+
version: 2.0.1
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: bundler
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
30
36
|
requirements:
|
31
37
|
- - "~>"
|
32
38
|
- !ruby/object:Gem::Version
|
33
|
-
version: '1
|
39
|
+
version: '2.1'
|
34
40
|
type: :development
|
35
41
|
prerelease: false
|
36
42
|
version_requirements: !ruby/object:Gem::Requirement
|
37
43
|
requirements:
|
38
44
|
- - "~>"
|
39
45
|
- !ruby/object:Gem::Version
|
40
|
-
version: '1
|
46
|
+
version: '2.1'
|
41
47
|
- !ruby/object:Gem::Dependency
|
42
48
|
name: byebug
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,14 +92,14 @@ dependencies:
|
|
86
92
|
requirements:
|
87
93
|
- - "~>"
|
88
94
|
- !ruby/object:Gem::Version
|
89
|
-
version: '3.
|
95
|
+
version: '3.18'
|
90
96
|
type: :development
|
91
97
|
prerelease: false
|
92
98
|
version_requirements: !ruby/object:Gem::Requirement
|
93
99
|
requirements:
|
94
100
|
- - "~>"
|
95
101
|
- !ruby/object:Gem::Version
|
96
|
-
version: '3.
|
102
|
+
version: '3.18'
|
97
103
|
description: A command-line tool for guessing which spec files are relavant to a passed-in
|
98
104
|
set of file paths.
|
99
105
|
email:
|
@@ -116,12 +122,15 @@ files:
|
|
116
122
|
- docs/release_process.md
|
117
123
|
- exe/tff
|
118
124
|
- feature/tff_exe_spec.rb
|
125
|
+
- fixtures/features/smoke.feature
|
119
126
|
- fixtures/mapping.json
|
120
127
|
- fixtures/mapping.yml
|
121
128
|
- fixtures/spec/controllers/projects_controller_spec.rb
|
122
129
|
- fixtures/spec/db/schema_spec.rb
|
123
130
|
- fixtures/spec/models/project_spec.rb
|
124
131
|
- fixtures/spec/models/test_file_finder_gem_executable_widget_spec.rb
|
132
|
+
- fixtures/spec/smoke_spec.rb
|
133
|
+
- fixtures/spec/views/main_spec.rb
|
125
134
|
- fixtures/test_reports.json
|
126
135
|
- lib/test_file_finder.rb
|
127
136
|
- lib/test_file_finder/file_finder.rb
|
@@ -156,7 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
156
165
|
- !ruby/object:Gem::Version
|
157
166
|
version: '0'
|
158
167
|
requirements: []
|
159
|
-
rubygems_version: 3.1.
|
168
|
+
rubygems_version: 3.1.6
|
160
169
|
signing_key:
|
161
170
|
specification_version: 4
|
162
171
|
summary: Guesses spec file paths given input file paths.
|