summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2017-06-27 19:41:23 +0000
committerClement Ho <ClemMakesApps@gmail.com>2017-06-27 16:10:13 -0500
commit5f5523c68a4b155f56424320e2dbf07088b351a2 (patch)
tree275863f5c20f2f990f1aa1280266d44cf36fe85d
parentc5da65b9e33e711b5ccaf55ceec52523a97dc89f (diff)
downloadgitlab-ce-5f5523c68a4b155f56424320e2dbf07088b351a2.tar.gz
Merge branch 'backport-system-check-fix' into 'master'
Make the SimpleExecutor rescue exceptions in the executing Checks See merge request !12487
-rw-r--r--lib/system_check/simple_executor.rb2
-rw-r--r--spec/lib/system_check/simple_executor_spec.rb24
2 files changed, 26 insertions, 0 deletions
diff --git a/lib/system_check/simple_executor.rb b/lib/system_check/simple_executor.rb
index dc2d4643a01..e5986612908 100644
--- a/lib/system_check/simple_executor.rb
+++ b/lib/system_check/simple_executor.rb
@@ -75,6 +75,8 @@ module SystemCheck
check.show_error
end
+ rescue StandardError => e
+ $stdout.puts "Exception: #{e.message}".color(:red)
end
private
diff --git a/spec/lib/system_check/simple_executor_spec.rb b/spec/lib/system_check/simple_executor_spec.rb
index a5c6170cd7d..795f11ee1f8 100644
--- a/spec/lib/system_check/simple_executor_spec.rb
+++ b/spec/lib/system_check/simple_executor_spec.rb
@@ -75,6 +75,24 @@ 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
+
+ before do
+ @rainbow = Rainbow.enabled
+ Rainbow.enabled = false
+ end
+
+ after do
+ Rainbow.enabled = @rainbow
+ end
+
describe '#component' do
it 'returns stored component name' do
expect(subject.component).to eq('Test')
@@ -219,5 +237,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