Merge branch 'master' into 15531-logincluster-migrate
[arvados.git] / apps / workbench / test / test_helper.rb
index 1d26deefa38bbe7c593d07d47dfe0d7d409cf49d..28a7fa51375bfd15acd9fc8b178eac7541376842 100644 (file)
@@ -348,3 +348,29 @@ end
 
 # Reset fixtures now (i.e., before any tests run).
 ActiveSupport::TestCase.reset_api_fixtures_now
+
+module Minitest
+  class Test
+    def capture_exceptions *args
+      begin
+        n = 0
+        begin
+          yield
+        rescue *PASSTHROUGH_EXCEPTIONS
+          raise
+        rescue Exception => e
+          n += 1
+          raise if n > 2 || e.is_a?(Skip)
+          STDERR.puts "Test failed, retrying (##{n})"
+          retry
+        end
+      rescue *PASSTHROUGH_EXCEPTIONS
+        raise
+      rescue Assertion => e
+        self.failures << e
+      rescue Exception => e
+        self.failures << UnexpectedError.new(e)
+      end
+    end
+  end
+end