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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
b9950c22
Commit
b9950c22
authored
May 16, 2017
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use each_line. Avoid comparison of partial. Add UTF-8 spec.
parent
14c0833c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
5 deletions
+14
-5
lib/gitlab/ci/trace/stream.rb
lib/gitlab/ci/trace/stream.rb
+3
-5
spec/lib/gitlab/ci/trace/stream_spec.rb
spec/lib/gitlab/ci/trace/stream_spec.rb
+11
-0
No files found.
lib/gitlab/ci/trace/stream.rb
View file @
b9950c22
...
@@ -125,11 +125,10 @@ module Gitlab
...
@@ -125,11 +125,10 @@ module Gitlab
stream
.
seek
(
-
pos
,
IO
::
SEEK_END
)
stream
.
seek
(
-
pos
,
IO
::
SEEK_END
)
stream
.
read
(
BUFFER_SIZE
).
tap
do
|
buf
|
stream
.
read
(
BUFFER_SIZE
).
tap
do
|
buf
|
buf
=
buf
+
debris
buf
=
buf
+
debris
lines
=
buf
.
split
(
"
\n
"
)
debris
,
*
lines
=
buf
.
each_line
.
to_a
lines
.
reverse
.
each
do
|
line
|
lines
.
reverse
_
each
do
|
line
|
yield
(
line
)
yield
(
line
)
end
end
debris
=
lines
.
count
>
0
?
lines
[
0
]
:
''
end
end
pos
+=
BUFFER_SIZE
pos
+=
BUFFER_SIZE
end
end
...
@@ -139,8 +138,7 @@ module Gitlab
...
@@ -139,8 +138,7 @@ module Gitlab
last
=
(
max
>
BUFFER_SIZE
)
?
(
max
%
BUFFER_SIZE
)
:
max
last
=
(
max
>
BUFFER_SIZE
)
?
(
max
%
BUFFER_SIZE
)
:
max
stream
.
read
(
last
).
tap
do
|
buf
|
stream
.
read
(
last
).
tap
do
|
buf
|
buf
=
buf
+
debris
buf
=
buf
+
debris
lines
=
buf
.
split
(
"
\n
"
)
buf
.
each_line
.
reverse_each
do
|
line
|
lines
.
reverse
.
each
do
|
line
|
yield
(
line
)
yield
(
line
)
end
end
end
end
...
...
spec/lib/gitlab/ci/trace/stream_spec.rb
View file @
b9950c22
...
@@ -265,6 +265,17 @@ describe Gitlab::Ci::Trace::Stream do
...
@@ -265,6 +265,17 @@ describe Gitlab::Ci::Trace::Stream do
it
{
is_expected
.
to
eq
(
"98.29"
)
}
it
{
is_expected
.
to
eq
(
"98.29"
)
}
end
end
context
'when regex is multi-byte char'
do
let
(
:data
)
{
'ゴッドファット\n'
}
let
(
:regex
)
{
'ゴッドファット'
}
before
do
stub_const
(
'Gitlab::Ci::Trace::Stream::BUFFER_SIZE'
,
5
)
end
it
{
is_expected
.
to
be_nil
}
end
context
'when BUFFER_SIZE is equal to stream.size'
do
context
'when BUFFER_SIZE is equal to stream.size'
do
let
(
:data
)
{
'Coverage 1033 / 1051 LOC (98.29%) covered\n'
}
let
(
:data
)
{
'Coverage 1033 / 1051 LOC (98.29%) covered\n'
}
let
(
:regex
)
{
'\(\d+.\d+\%\) covered'
}
let
(
:regex
)
{
'\(\d+.\d+\%\) covered'
}
...
...
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