From c92c48662a76d479203a44a0efbf4a69576e2db2 Mon Sep 17 00:00:00 2001 From: Stafford Brunk Date: Fri, 24 May 2013 15:50:22 -0600 Subject: [PATCH 1/2] Return true/false from Runner#runcall exit on that return value in Cli --- lib/strainer/cli.rb | 3 ++- lib/strainer/runner.rb | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/strainer/cli.rb b/lib/strainer/cli.rb index a12b1e7..c9b7972 100644 --- a/lib/strainer/cli.rb +++ b/lib/strainer/cli.rb @@ -67,7 +67,8 @@ def initialize(*args) desc 'test [COOKBOOKS]', 'Run tests against the given cookbooks' def test(*cookbooks) Strainer.ui.debug "Called Strainer::Cli#test with #{cookbooks.inspect}" - Strainer::Runner.new(cookbooks, options).run! + ret = Strainer::Runner.new(cookbooks, options).run! + exit(ret) end # strainer info diff --git a/lib/strainer/runner.rb b/lib/strainer/runner.rb index 1835084..032f14d 100644 --- a/lib/strainer/runner.rb +++ b/lib/strainer/runner.rb @@ -59,7 +59,7 @@ def run! if options[:fail_fast] && !success Strainer.ui.debug "Run was not successful and --fail-fast was specified" Strainer.ui.fatal "Exited early because '--fail-fast' was specified. Some tests may have been skipped!" - abort + return false end end end @@ -71,10 +71,10 @@ def run! if @report.values.collect(&:values).flatten.all? Strainer.ui.say "Strainer marked build OK" - exit(true) + return true else Strainer.ui.say "Strainer marked build as failure" - exit(false) + return false end end From 08c5fc53005df67909aa808cbce7cfa8f80c9ad8 Mon Sep 17 00:00:00 2001 From: Stafford Brunk Date: Wed, 7 Aug 2013 09:43:02 -0600 Subject: [PATCH 2/2] Refactor Strainer success reporting code in Runner#run! --- lib/strainer/runner.rb | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/strainer/runner.rb b/lib/strainer/runner.rb index 032f14d..1ea72a1 100644 --- a/lib/strainer/runner.rb +++ b/lib/strainer/runner.rb @@ -69,13 +69,12 @@ def run! FileUtils.mv(Strainer.logfile_path, Strainer.sandbox_path.join('strainer.out')) end - if @report.values.collect(&:values).flatten.all? - Strainer.ui.say "Strainer marked build OK" - return true - else - Strainer.ui.say "Strainer marked build as failure" - return false - end + success = @report.values.collect(&:values).flatten.all? + + msg = success ? "Strainer marked build OK" : "Strainer marked build as failure" + Strainer.ui.say msg + + return success end def hash