From 895b23e6ca087e1e71516e0b66ec86339f43788f Mon Sep 17 00:00:00 2001 From: Andy Lindeman Date: Mon, 30 Dec 2013 12:00:19 -0500 Subject: [PATCH] Propagates exit codes from other runners --- lib/multi_test.rb | 8 +++++++- test/gemfiles/minitest-5.0.1/scenarios | 1 + test/gemfiles/minitest-5.1.0/scenarios | 1 + test/gemfiles/minitest-5.2.0/scenarios | 1 + test/scenarios/minitest_propagate_exit_code.rb | 9 +++++++++ 5 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 test/scenarios/minitest_propagate_exit_code.rb diff --git a/lib/multi_test.rb b/lib/multi_test.rb index 1460d1c..9291890 100644 --- a/lib/multi_test.rb +++ b/lib/multi_test.rb @@ -7,7 +7,13 @@ def self.disable_autorun if defined?(Minitest) Minitest.instance_eval do def run(*) - 0 # exit code + # propagate the exit code from cucumber or another runner + case $! + when SystemExit + $!.status + else + true + end end end diff --git a/test/gemfiles/minitest-5.0.1/scenarios b/test/gemfiles/minitest-5.0.1/scenarios index e1805e7..d7ae303 100644 --- a/test/gemfiles/minitest-5.0.1/scenarios +++ b/test/gemfiles/minitest-5.0.1/scenarios @@ -1,2 +1,3 @@ bundler_require.rb +minitest_propagate_exit_code.rb diff --git a/test/gemfiles/minitest-5.1.0/scenarios b/test/gemfiles/minitest-5.1.0/scenarios index e1805e7..d7ae303 100644 --- a/test/gemfiles/minitest-5.1.0/scenarios +++ b/test/gemfiles/minitest-5.1.0/scenarios @@ -1,2 +1,3 @@ bundler_require.rb +minitest_propagate_exit_code.rb diff --git a/test/gemfiles/minitest-5.2.0/scenarios b/test/gemfiles/minitest-5.2.0/scenarios index e1805e7..d7ae303 100644 --- a/test/gemfiles/minitest-5.2.0/scenarios +++ b/test/gemfiles/minitest-5.2.0/scenarios @@ -1,2 +1,3 @@ bundler_require.rb +minitest_propagate_exit_code.rb diff --git a/test/scenarios/minitest_propagate_exit_code.rb b/test/scenarios/minitest_propagate_exit_code.rb new file mode 100644 index 0000000..b2747a1 --- /dev/null +++ b/test/scenarios/minitest_propagate_exit_code.rb @@ -0,0 +1,9 @@ +# Imagine this is your rails app +require 'minitest/autorun' + +# Now cucumber loads and exits successfully +require "multi_test" +MultiTest.disable_autorun +exit 0 + +# Our Minitest hook should propagate that healthy status code