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
6baf8b3e
Commit
6baf8b3e
authored
Sep 28, 2021
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow Quality::TestLevel to have several prefixes
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
03b99718
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
7 deletions
+35
-7
spec/tooling/quality/test_level_spec.rb
spec/tooling/quality/test_level_spec.rb
+16
-2
tooling/quality/test_level.rb
tooling/quality/test_level.rb
+19
-5
No files found.
spec/tooling/quality/test_level_spec.rb
View file @
6baf8b3e
...
@@ -63,7 +63,14 @@ RSpec.describe Quality::TestLevel do
...
@@ -63,7 +63,14 @@ RSpec.describe Quality::TestLevel do
context
'with a prefix'
do
context
'with a prefix'
do
it
'returns a pattern'
do
it
'returns a pattern'
do
expect
(
described_class
.
new
(
'ee/'
).
pattern
(
:system
))
expect
(
described_class
.
new
(
'ee/'
).
pattern
(
:system
))
.
to
eq
(
"ee/spec/{features}{,/**/}*_spec.rb"
)
.
to
eq
(
"{ee/}spec/{features}{,/**/}*_spec.rb"
)
end
end
context
'with several prefixes'
do
it
'returns a pattern'
do
expect
(
described_class
.
new
([
''
,
'ee/'
,
'jh/'
]).
pattern
(
:system
))
.
to
eq
(
"{,ee/,jh/}spec/{features}{,/**/}*_spec.rb"
)
end
end
end
end
...
@@ -138,7 +145,14 @@ RSpec.describe Quality::TestLevel do
...
@@ -138,7 +145,14 @@ RSpec.describe Quality::TestLevel do
context
'with a prefix'
do
context
'with a prefix'
do
it
'returns a regexp'
do
it
'returns a regexp'
do
expect
(
described_class
.
new
(
'ee/'
).
regexp
(
:system
))
expect
(
described_class
.
new
(
'ee/'
).
regexp
(
:system
))
.
to
eq
(
%r{ee/spec/(features)}
)
.
to
eq
(
%r{(ee/)spec/(features)}
)
end
end
context
'with several prefixes'
do
it
'returns a regexp'
do
expect
(
described_class
.
new
([
''
,
'ee/'
,
'jh/'
]).
regexp
(
:system
))
.
to
eq
(
%r{(|ee/|jh/)spec/(features)}
)
end
end
end
end
...
...
tooling/quality/test_level.rb
View file @
6baf8b3e
...
@@ -60,20 +60,20 @@ module Quality
...
@@ -60,20 +60,20 @@ module Quality
system:
[
'features'
]
system:
[
'features'
]
}.
freeze
}.
freeze
attr_reader
:prefix
attr_reader
:prefix
es
def
initialize
(
prefix
=
nil
)
def
initialize
(
prefix
es
=
nil
)
@prefix
=
prefix
@prefix
es
=
Array
(
prefixes
)
@patterns
=
{}
@patterns
=
{}
@regexps
=
{}
@regexps
=
{}
end
end
def
pattern
(
level
)
def
pattern
(
level
)
@patterns
[
level
]
||=
"
#{
prefix
}
spec/
#{
folders_pattern
(
level
)
}
{,/**/}*
#{
suffix
(
level
)
}
"
@patterns
[
level
]
||=
"
#{
prefix
es_for_pattern
}
spec/
#{
folders_pattern
(
level
)
}
{,/**/}*
#{
suffix
(
level
)
}
"
end
end
def
regexp
(
level
)
def
regexp
(
level
)
@regexps
[
level
]
||=
Regexp
.
new
(
"
#{
prefix
}
spec/
#{
folders_regex
(
level
)
}
"
).
freeze
@regexps
[
level
]
||=
Regexp
.
new
(
"
#{
prefix
es_for_regex
}
spec/
#{
folders_regex
(
level
)
}
"
).
freeze
end
end
def
level_for
(
file_path
)
def
level_for
(
file_path
)
...
@@ -102,6 +102,20 @@ module Quality
...
@@ -102,6 +102,20 @@ module Quality
private
private
def
prefixes_for_pattern
return
''
if
prefixes
.
empty?
"{
#{
prefixes
.
join
(
','
)
}
}"
end
def
prefixes_for_regex
return
''
if
prefixes
.
empty?
regex_prefix
=
prefixes
.
map
(
&
Regexp
.
method
(
:escape
)).
join
(
'|'
)
"(
#{
regex_prefix
}
)"
end
def
suffix
(
level
)
def
suffix
(
level
)
case
level
case
level
when
:frontend_fixture
when
:frontend_fixture
...
...
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