From 2779c5c41536afc55f77b4d2b3a232851e82eef6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Knut=20Olav=20L=C3=B8ite?= Date: Thu, 11 Jun 2026 16:43:37 +0200 Subject: [PATCH 1/2] fix(ruby-wrapper): resolve flakiness on Windows and fix gemspec path warning --- .../spannerlib-ruby/spannerlib-ruby.gemspec | 2 +- .../spannerlib-ruby/spec/spannerlib_ruby_spec.rb | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/spannerlib/wrappers/spannerlib-ruby/spannerlib-ruby.gemspec b/spannerlib/wrappers/spannerlib-ruby/spannerlib-ruby.gemspec index 06c1c1af..4bf46615 100644 --- a/spannerlib/wrappers/spannerlib-ruby/spannerlib-ruby.gemspec +++ b/spannerlib/wrappers/spannerlib-ruby/spannerlib-ruby.gemspec @@ -29,7 +29,7 @@ Gem::Specification.new do |spec| spec.files = Dir.chdir(File.expand_path(__dir__)) do files = [] # prefer git-tracked files when available (local dev), but also pick up built files present on disk (CI) - files += `git ls-files -z`.split("\x0") if system("git rev-parse --is-inside-work-tree > /dev/null 2>&1") + files += `git ls-files -z`.split("\x0") if system("git rev-parse --is-inside-work-tree > #{File::NULL} 2>&1") # include any built native libs (CI places them under lib/spannerlib/) files += Dir.glob("lib/spannerlib/**/*").select { |f| File.file?(f) } diff --git a/spannerlib/wrappers/spannerlib-ruby/spec/spannerlib_ruby_spec.rb b/spannerlib/wrappers/spannerlib-ruby/spec/spannerlib_ruby_spec.rb index dfb73aa3..4b6c7825 100644 --- a/spannerlib/wrappers/spannerlib-ruby/spec/spannerlib_ruby_spec.rb +++ b/spannerlib/wrappers/spannerlib-ruby/spec/spannerlib_ruby_spec.rb @@ -21,6 +21,7 @@ require "google/cloud/spanner/v1/spanner" require "timeout" require "tmpdir" +require "socket" require_relative "mock_server/statement_result" require_relative "../lib/spannerlib/ffi" @@ -94,7 +95,15 @@ def self.wait_for_port if File.exist?($port_file) content = File.read($port_file).strip - return content.to_i unless content.empty? + unless content.empty? + port = content.to_i + begin + Socket.tcp("127.0.0.1", port, connect_timeout: 0.1) { |s| s.close } + return port + rescue Errno::ECONNREFUSED, Errno::ETIMEDOUT + # Server not yet fully listening + end + end end raise "Mock server exited unexpectedly!" if Process.waitpid($server_pid, Process::WNOHANG) @@ -170,7 +179,7 @@ def find_transaction_options(requests) before do self.class.ensure_server_running! File.binwrite($mock_msg_file, Marshal.dump({})) - File.write($mock_req_file, "") + File.binwrite($mock_req_file, "") @dsn = "127.0.0.1:#{$server_port}/projects/p/instances/i/databases/d?useplaintext=true" @pool_id = SpannerLib.create_pool(@dsn) From 833836c2e4fd77882eb5069b7310842c665dfe33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Knut=20Olav=20L=C3=B8ite?= Date: Fri, 12 Jun 2026 09:27:37 +0200 Subject: [PATCH 2/2] fix(ruby-wrapper): run RuboCop linter fix --- .../wrappers/spannerlib-ruby/spec/spannerlib_ruby_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spannerlib/wrappers/spannerlib-ruby/spec/spannerlib_ruby_spec.rb b/spannerlib/wrappers/spannerlib-ruby/spec/spannerlib_ruby_spec.rb index 4b6c7825..1835afe6 100644 --- a/spannerlib/wrappers/spannerlib-ruby/spec/spannerlib_ruby_spec.rb +++ b/spannerlib/wrappers/spannerlib-ruby/spec/spannerlib_ruby_spec.rb @@ -98,9 +98,9 @@ def self.wait_for_port unless content.empty? port = content.to_i begin - Socket.tcp("127.0.0.1", port, connect_timeout: 0.1) { |s| s.close } + Socket.tcp("127.0.0.1", port, connect_timeout: 0.1) { nil } return port - rescue Errno::ECONNREFUSED, Errno::ETIMEDOUT + rescue SystemCallError # Server not yet fully listening end end