Skip to content

Commit 1b35626

Browse files
committed
fix minitest after run hook to handle failing tests
1 parent b8bff29 commit 1b35626

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

spannerlib/wrappers/spannerlib-ruby/spec/mock_server_runner.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,18 @@
2424
require_relative "mock_server/spanner_mock_server"
2525

2626
<<<<<<< HEAD
27+
<<<<<<< HEAD
28+
=======
29+
>>>>>>> 04a62e7 (fix minitest after run hook to handle failing tests)
2730
Signal.trap("TERM") do
2831
exit!(0) # "exit skips cleanup hooks and prevents gRPC segfaults
2932
end
3033

34+
<<<<<<< HEAD
3135
=======
3236
>>>>>>> a953c19 (chore(ruby): Add CI workflow to run mock server tests)
37+
=======
38+
>>>>>>> 04a62e7 (fix minitest after run hook to handle failing tests)
3339
begin
3440
server = GRPC::RpcServer.new
3541
port = server.add_http2_port "127.0.0.1:0", :this_port_is_insecure

spannerlib/wrappers/spannerlib-ruby/spec/spannerlib_ruby_spec.rb

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
$server_pid = nil
3232
$server_port = nil
3333
$port_file = nil
34+
$any_failure = false
3435

3536
Minitest.after_run do
3637
if $server_pid
@@ -42,10 +43,15 @@
4243
end
4344
end
4445
File.delete($port_file) if $port_file && File.exist?($port_file)
45-
# The Go Runtime inside the DLL conflicts with Ruby's shutdown sequence on Windows,
46-
# causing a crash after tests pass. Process.exit!(0) skips the cleanup hooks
47-
# and exits immediately with success status.
48-
Process.exit!(0)
46+
if $any_failure
47+
puts "Tests Failed! Exiting with code 1"
48+
$stdout.flush
49+
Process.exit!(1)
50+
else
51+
puts "Tests Passed! Exiting with code 0"
52+
$stdout.flush
53+
Process.exit!(0)
54+
end
4955
end
5056

5157
describe "Connection" do

0 commit comments

Comments
 (0)