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
Boxiang Sun
gitlab-ce
Commits
b0f2861c
Commit
b0f2861c
authored
7 years ago
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make the SimpleExecutor rescue exceptions in the executing Checks
parent
6b86ce75
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
2 deletions
+19
-2
lib/system_check/simple_executor.rb
lib/system_check/simple_executor.rb
+2
-0
spec/lib/system_check/simple_executor_spec.rb
spec/lib/system_check/simple_executor_spec.rb
+17
-2
No files found.
lib/system_check/simple_executor.rb
View file @
b0f2861c
...
...
@@ -75,6 +75,8 @@ module SystemCheck
check
.
show_error
end
rescue
StandardError
=>
e
$stdout
.
puts
"Exception:
#{
e
.
message
}
"
.
color
(
:red
)
end
private
...
...
This diff is collapsed.
Click to expand it.
spec/lib/system_check/simple_executor_spec.rb
View file @
b0f2861c
...
...
@@ -75,6 +75,15 @@ describe SystemCheck::SimpleExecutor, lib: true do
end
end
class
BugousCheck
<
SystemCheck
::
BaseCheck
CustomError
=
Class
.
new
(
StandardError
)
set_name
'my bugous check'
def
check?
raise
CustomError
,
'omg'
end
end
describe
'#component'
do
it
'returns stored component name'
do
expect
(
subject
.
component
).
to
eq
(
'Test'
)
...
...
@@ -138,14 +147,14 @@ describe SystemCheck::SimpleExecutor, lib: true do
context
'when check pass'
do
it
'prints yes'
do
expect_any_instance_of
(
SimpleCheck
).
to
receive
(
:check?
).
and_call_original
expect
{
subject
.
run_check
(
SimpleCheck
)
}.
to
output
(
/ \.\.\. yes/
).
to_stdout
expect
{
subject
.
run_check
(
SimpleCheck
)
}.
to
output
(
/ \.\.\.
\e\[32m
yes/
).
to_stdout
end
end
context
'when check fails'
do
it
'prints no'
do
expect_any_instance_of
(
OtherCheck
).
to
receive
(
:check?
).
and_call_original
expect
{
subject
.
run_check
(
OtherCheck
)
}.
to
output
(
/ \.\.\. no/
).
to_stdout
expect
{
subject
.
run_check
(
OtherCheck
)
}.
to
output
(
/ \.\.\.
\e\[31m
no/
).
to_stdout
end
it
'displays error message from #show_error'
do
...
...
@@ -219,5 +228,11 @@ describe SystemCheck::SimpleExecutor, lib: true do
end
end
end
context
'when there is an exception'
do
it
'rescues the exception'
do
expect
{
subject
.
run_check
(
BugousCheck
)
}.
not_to
raise_exception
end
end
end
end
This diff is collapsed.
Click to expand it.
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