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
3d11b7d8
Commit
3d11b7d8
authored
May 10, 2017
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix reverse_line from chunk based
parent
ddf67424
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
2 deletions
+39
-2
lib/gitlab/ci/trace/stream.rb
lib/gitlab/ci/trace/stream.rb
+17
-2
spec/lib/gitlab/ci/trace/stream_spec.rb
spec/lib/gitlab/ci/trace/stream_spec.rb
+22
-0
No files found.
lib/gitlab/ci/trace/stream.rb
View file @
3d11b7d8
...
@@ -119,16 +119,31 @@ module Gitlab
...
@@ -119,16 +119,31 @@ module Gitlab
def
reverse_line
def
reverse_line
pos
=
BUFFER_SIZE
pos
=
BUFFER_SIZE
max
=
stream
.
size
max
=
stream
.
size
debris
=
''
while
pos
<
max
while
pos
<
max
stream
.
seek
(
-
pos
,
IO
::
SEEK_END
)
stream
.
seek
(
-
pos
,
IO
::
SEEK_END
)
yield
(
stream
.
read
(
BUFFER_SIZE
))
stream
.
read
(
BUFFER_SIZE
).
tap
do
|
buf
|
buf
=
buf
+
debris
lines
=
buf
.
split
(
"
\n
"
)
lines
.
reverse
.
each
do
|
line
|
yield
(
line
)
end
debris
=
lines
.
count
>
0
?
lines
[
0
]
:
''
end
pos
+=
BUFFER_SIZE
pos
+=
BUFFER_SIZE
end
end
# Reached the head, read only left
# Reached the head, read only left
stream
.
seek
(
0
)
stream
.
seek
(
0
)
yield
(
stream
.
read
(
BUFFER_SIZE
-
(
pos
-
max
)))
last
=
(
max
>
BUFFER_SIZE
)
?
(
max
%
BUFFER_SIZE
)
:
max
stream
.
read
(
last
).
tap
do
|
buf
|
buf
=
buf
+
debris
lines
=
buf
.
split
(
"
\n
"
)
lines
.
reverse
.
each
do
|
line
|
yield
(
line
)
end
end
end
end
end
end
end
end
...
...
spec/lib/gitlab/ci/trace/stream_spec.rb
View file @
3d11b7d8
...
@@ -254,6 +254,28 @@ describe Gitlab::Ci::Trace::Stream do
...
@@ -254,6 +254,28 @@ describe Gitlab::Ci::Trace::Stream do
end
end
end
end
context
'when BUFFER_SIZE is smaller than stream.size'
do
let
(
:data
)
{
'Coverage 1033 / 1051 LOC (98.29%) covered\n'
}
let
(
:regex
)
{
'\(\d+.\d+\%\) covered'
}
before
do
stub_const
(
'Gitlab::Ci::Trace::Stream::BUFFER_SIZE'
,
5
)
end
it
{
is_expected
.
to
eq
(
"98.29"
)
}
end
context
'when BUFFER_SIZE is equal to stream.size'
do
let
(
:data
)
{
'Coverage 1033 / 1051 LOC (98.29%) covered\n'
}
let
(
:regex
)
{
'\(\d+.\d+\%\) covered'
}
before
do
stub_const
(
'Gitlab::Ci::Trace::Stream::BUFFER_SIZE'
,
data
.
length
)
end
it
{
is_expected
.
to
eq
(
"98.29"
)
}
end
context
'using a regex capture'
do
context
'using a regex capture'
do
let
(
:data
)
{
'TOTAL 9926 3489 65%'
}
let
(
:data
)
{
'TOTAL 9926 3489 65%'
}
let
(
:regex
)
{
'TOTAL\s+\d+\s+\d+\s+(\d{1,3}\%)'
}
let
(
:regex
)
{
'TOTAL\s+\d+\s+\d+\s+(\d{1,3}\%)'
}
...
...
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