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
7bbd5f6e
Commit
7bbd5f6e
authored
Mar 02, 2018
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Define Trace::ArchiveError to make it explit as an error
parent
481d0bc3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
9 deletions
+9
-9
lib/gitlab/ci/trace.rb
lib/gitlab/ci/trace.rb
+5
-3
spec/lib/gitlab/ci/trace_spec.rb
spec/lib/gitlab/ci/trace_spec.rb
+4
-6
No files found.
lib/gitlab/ci/trace.rb
View file @
7bbd5f6e
module
Gitlab
module
Ci
class
Trace
ArchiveError
=
Class
.
new
(
StandardError
)
attr_reader
:job
delegate
:old_trace
,
to: :job
...
...
@@ -94,8 +96,8 @@ module Gitlab
end
def
archive!
raise
'Already archived'
if
trace_artifact
raise
'Job is not finished yet'
unless
job
.
complete?
raise
ArchiveError
,
'Already archived'
if
trace_artifact
raise
ArchiveError
,
'Job is not finished yet'
unless
job
.
complete?
if
current_path
File
.
open
(
current_path
)
do
|
stream
|
...
...
@@ -124,7 +126,7 @@ module Gitlab
temp_path
=
File
.
join
(
dir_path
,
"job.log"
)
FileUtils
.
touch
(
temp_path
)
size
=
IO
.
copy_stream
(
src_stream
,
temp_path
)
raise
'Not all saved
'
unless
size
==
src_stream
.
size
raise
ArchiveError
,
'Failed to copy stream
'
unless
size
==
src_stream
.
size
yield
(
temp_path
)
end
...
...
spec/lib/gitlab/ci/trace_spec.rb
View file @
7bbd5f6e
...
...
@@ -463,11 +463,10 @@ describe Gitlab::Ci::Trace do
context
'when failed to create clone file'
do
before
do
allow_any_instance_of
(
described_class
)
.
to
receive
(
:clone_file!
).
and_raise
(
'Not all saved'
)
allow
(
IO
).
to
receive
(
:copy_stream
).
and_return
(
0
)
end
it_behaves_like
'source trace file stays intact'
,
error:
'Not all saved'
it_behaves_like
'source trace file stays intact'
,
error:
Gitlab
::
Ci
::
Trace
::
ArchiveError
end
context
'when failed to create job artifact record'
do
...
...
@@ -494,11 +493,10 @@ describe Gitlab::Ci::Trace do
context
'when failed to create clone file'
do
before
do
allow_any_instance_of
(
described_class
)
.
to
receive
(
:clone_file!
).
and_raise
(
'Not all saved'
)
allow
(
IO
).
to
receive
(
:copy_stream
).
and_return
(
0
)
end
it_behaves_like
'source trace in database stays intact'
,
error:
'Not all saved'
it_behaves_like
'source trace in database stays intact'
,
error:
Gitlab
::
Ci
::
Trace
::
ArchiveError
end
context
'when failed to create job artifact record'
do
...
...
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