Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
8dba90d8
Commit
8dba90d8
authored
Jun 24, 2020
by
Albert Salim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add prefix option to ImpactedTestFile
parent
4dd6d1af
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
18 deletions
+18
-18
tooling/lib/tooling/test_file_finder.rb
tooling/lib/tooling/test_file_finder.rb
+18
-18
No files found.
tooling/lib/tooling/test_file_finder.rb
View file @
8dba90d8
...
...
@@ -23,14 +23,15 @@ module Tooling
class
ImpactedTestFile
attr_reader
:pattern_matchers
def
initialize
def
initialize
(
prefix:
nil
)
@pattern_matchers
=
{}
@prefix
=
prefix
yield
self
if
block_given?
end
def
associate
(
pattern
,
&
block
)
@pattern_matchers
[
pattern
]
=
block
@pattern_matchers
[
%r{^
#{
@prefix
}#{
pattern
}
}
]
=
block
end
def
impact
(
file
)
...
...
@@ -54,34 +55,33 @@ module Tooling
end
def
ee_impact
ImpactedTestFile
.
new
do
|
impact
|
ImpactedTestFile
.
new
(
prefix:
EE_PREFIX
)
do
|
impact
|
unless
foss_test_only
impact
.
associate
(
%r{^
#{
EE_PREFIX
}
app/(.+)
\.
rb$}
)
{
|
match
|
"
#{
EE_PREFIX
}
spec/
#{
match
[
1
]
}
_spec.rb"
}
impact
.
associate
(
%r{^
#{
EE_PREFIX
}
app/(.*/)ee/(.+)
\.
rb$}
)
{
|
match
|
"
#{
EE_PREFIX
}
spec/
#{
match
[
1
]
}#{
match
[
2
]
}
_spec.rb"
}
impact
.
associate
(
%r{^
#{
EE_PREFIX
}
lib/(.+)
\.
rb$}
)
{
|
match
|
"
#{
EE_PREFIX
}
spec/lib/
#{
match
[
1
]
}
_spec.rb"
}
impact
.
associate
(
%r{^
#{
EE_PREFIX
}
spec/(.+)_spec.rb$}
)
{
|
match
|
match
[
0
]
}
impact
.
associate
(
%r{app/(.+)
\.
rb$}
)
{
|
match
|
"
#{
EE_PREFIX
}
spec/
#{
match
[
1
]
}
_spec.rb"
}
impact
.
associate
(
%r{app/(.*/)ee/(.+)
\.
rb$}
)
{
|
match
|
"
#{
EE_PREFIX
}
spec/
#{
match
[
1
]
}#{
match
[
2
]
}
_spec.rb"
}
impact
.
associate
(
%r{lib/(.+)
\.
rb$}
)
{
|
match
|
"
#{
EE_PREFIX
}
spec/lib/
#{
match
[
1
]
}
_spec.rb"
}
end
impact
.
associate
(
%r{
^
#{
EE_PREFIX
}
(?!spec)(.*/)ee/(.+)
\.
rb$}
)
{
|
match
|
"spec/
#{
match
[
1
]
}#{
match
[
2
]
}
_spec.rb"
}
impact
.
associate
(
%r{
^
#{
EE_PREFIX
}
spec/(.*/)ee/(.+)
\.
rb$}
)
{
|
match
|
"spec/
#{
match
[
1
]
}#{
match
[
2
]
}
.rb"
}
impact
.
associate
(
%r{(?!spec)(.*/)ee/(.+)
\.
rb$}
)
{
|
match
|
"spec/
#{
match
[
1
]
}#{
match
[
2
]
}
_spec.rb"
}
impact
.
associate
(
%r{spec/(.*/)ee/(.+)
\.
rb$}
)
{
|
match
|
"spec/
#{
match
[
1
]
}#{
match
[
2
]
}
.rb"
}
end
end
def
non_ee_impact
ImpactedTestFile
.
new
do
|
impact
|
impact
.
associate
(
%r{
^
app/(.+)
\.
rb$}
)
{
|
match
|
"spec/
#{
match
[
1
]
}
_spec.rb"
}
impact
.
associate
(
%r{
^
(tooling/)?lib/(.+)
\.
rb$}
)
{
|
match
|
"spec/
#{
match
[
1
]
}
lib/
#{
match
[
2
]
}
_spec.rb"
}
impact
.
associate
(
%r{
^spec/(.+)_spec.rb$}
)
{
|
match
|
match
[
0
]
}
impact
.
associate
(
%r{
^config/initializers/(.+).rb$}
)
{
|
match
|
"spec/initializers/
#{
match
[
1
]
}
_spec.rb"
}
impact
.
associate
(
%r{
^db/post_
migrate/([0-9]+)_(.+).rb$}
)
{
|
match
|
"spec/migrations/
#{
match
[
2
]
}
_spec.rb"
}
impact
.
associate
(
%r{^db/migrate/([0-9]+)_(.+).rb$}
)
{
|
match
|
"spec/migrations/
#{
match
[
2
]
}
_spec.rb"
}
impact
.
associate
(
%r{app/(.+)
\.
rb$}
)
{
|
match
|
"spec/
#{
match
[
1
]
}
_spec.rb"
}
impact
.
associate
(
%r{(tooling/)?lib/(.+)
\.
rb$}
)
{
|
match
|
"spec/
#{
match
[
1
]
}
lib/
#{
match
[
2
]
}
_spec.rb"
}
impact
.
associate
(
%r{
config/initializers/(.+).rb$}
)
{
|
match
|
"spec/initializers/
#{
match
[
1
]
}
_spec.rb"
}
impact
.
associate
(
%r{
db/post_migrate/([0-9]+)_(.+).rb$}
)
{
|
match
|
"spec/migrations/
#{
match
[
2
]
}
_spec.rb"
}
impact
.
associate
(
%r{
db/
migrate/([0-9]+)_(.+).rb$}
)
{
|
match
|
"spec/migrations/
#{
match
[
2
]
}
_spec.rb"
}
impact
.
associate
(
'db/structure.sql'
)
{
'spec/db/schema_spec.rb'
}
end
end
def
either_impact
ImpactedTestFile
.
new
do
|
impact
|
impact
.
associate
(
%r{
^(
#{
EE_PREFIX
}
)?spec/factories/.+
\.
rb$}
)
{
'spec/factories_spec.rb'
}
impact
.
associate
(
'db/structure.sql'
)
{
'spec/db/schema
_spec.rb'
}
ImpactedTestFile
.
new
(
prefix:
%r{^(
#{
EE_PREFIX
}
)?}
)
do
|
impact
|
impact
.
associate
(
%r{
spec/(.+)_spec.rb$}
)
{
|
match
|
match
[
0
]
}
impact
.
associate
(
%r{spec/factories/.+
\.
rb$}
)
{
'spec/factories
_spec.rb'
}
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment