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
d0c85390
Commit
d0c85390
authored
Sep 18, 2020
by
Kev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for build_trace_section_regex
parent
f6327f4e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
1 deletion
+51
-1
lib/gitlab/regex.rb
lib/gitlab/regex.rb
+20
-1
spec/lib/gitlab/regex_spec.rb
spec/lib/gitlab/regex_spec.rb
+31
-0
No files found.
lib/gitlab/regex.rb
View file @
d0c85390
...
...
@@ -220,8 +220,27 @@ module Gitlab
"Must start with a letter, and cannot end with '-'"
end
# The section start, e.g. section_start:12345678:NAME
def
logs_section_prefix_regex
/section_((?:start)|(?:end)):(\d+):([a-zA-Z0-9_.-]+)/
end
# The optional section options, e.g. [collapsed=true]
def
logs_section_options_regex
/(\[(?:\w+=\w+)(?:, ?(?:\w+=\w+))*\])?/
end
# The region end, always: \r\e\[0K
def
logs_section_suffix_regex
/\r\033\[0K/
end
def
build_trace_section_regex
@build_trace_section_regexp
||=
/section_((?:start)|(?:end)):(\d+):([a-zA-Z0-9_.-]+)(\[(?:\w+=\w+)(?:, ?(?:\w+=\w+))*\])?\r\033\[0K/
.
freeze
@build_trace_section_regexp
||=
%r{
#{
logs_section_prefix_regex
}
#{
logs_section_options_regex
}
#{
logs_section_suffix_regex
}
}x
.
freeze
end
def
markdown_code_or_html_blocks
...
...
spec/lib/gitlab/regex_spec.rb
View file @
d0c85390
...
...
@@ -99,6 +99,37 @@ RSpec.describe Gitlab::Regex do
it
{
is_expected
.
not_to
match
(
'foo-'
)
}
end
describe
'.build_trace_section_regex'
do
subject
{
described_class
.
build_trace_section_regex
}
context
'without options'
do
example
=
"section_start:1600445393032:NAME
\r\033\[
0K"
it
{
is_expected
.
to
match
(
example
)
}
it
{
is_expected
.
to
match
(
"section_end:12345678:aBcDeFg1234
\r\033\[
0K"
)
}
it
{
is_expected
.
to
match
(
"section_start:0:sect_for_alpha-v1.0
\r\033\[
0K"
)
}
it
{
is_expected
.
not_to
match
(
"section_start:section:0
\r\033\[
0K"
)
}
it
{
is_expected
.
not_to
match
(
"section_:1600445393032:NAME
\r\033\[
0K"
)
}
it
{
is_expected
.
not_to
match
(
example
.
upcase
)
}
end
context
'with options'
do
it
{
is_expected
.
to
match
(
"section_start:1600445393032:NAME[collapsed=true]
\r\033\[
0K"
)
}
it
{
is_expected
.
to
match
(
"section_start:1600445393032:NAME[collapsed=true, example_option=false]
\r\033\[
0K"
)
}
it
{
is_expected
.
to
match
(
"section_start:1600445393032:NAME[collapsed=true,example_option=false]
\r\033\[
0K"
)
}
it
{
is_expected
.
to
match
(
"section_start:1600445393032:NAME[numeric_option=1234567]
\r\033\[
0K"
)
}
# Without splitting the regex in one for start and one for end,
# this is possible, however, it is ignored for section_end.
it
{
is_expected
.
to
match
(
"section_end:1600445393032:NAME[collapsed=true]
\r\033\[
0K"
)
}
it
{
is_expected
.
not_to
match
(
"section_start:1600445393032:NAME[collapsed=[]]]
\r\033\[
0K"
)
}
it
{
is_expected
.
not_to
match
(
"section_start:1600445393032:NAME[collapsed = true]
\r\033\[
0K"
)
}
it
{
is_expected
.
not_to
match
(
"section_start:1600445393032:NAME[collapsed = true, example_option=false]
\r\033\[
0K"
)
}
it
{
is_expected
.
not_to
match
(
"section_start:1600445393032:NAME[collapsed=true, example_option=false]
\r\033\[
0K"
)
}
it
{
is_expected
.
not_to
match
(
"section_start:1600445393032:NAME[]
\r\033\[
0K"
)
}
end
end
describe
'.container_repository_name_regex'
do
subject
{
described_class
.
container_repository_name_regex
}
...
...
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