From f8ca8ea404d8854f45ce323e0de578081f62522b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 8 Sep 2026 22:57:03 +0000 Subject: [PATCH 1/2] Initial plan From b1447f649c373bc613a2214c490f0a0eefb793fc Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 8 Sep 2026 23:00:37 +0000 Subject: [PATCH 2/2] test: block until WEBrick server threads stop Co-authored-by: donoghuc <15354214+donoghuc@users.noreply.github.com> --- spec/outputs/http_spec.rb | 11 ++++------- spec/spec_helper.rb | 16 +++++++++++++--- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/spec/outputs/http_spec.rb b/spec/outputs/http_spec.rb index adceccd..0931fbc 100644 --- a/spec/outputs/http_spec.rb +++ b/spec/outputs/http_spec.rb @@ -5,12 +5,11 @@ # Requires pool_max to be 1 before(:all) do - @server = start_app_and_wait(TestApp) + @server, @server_thread = start_app_and_wait(TestApp) end after(:all) do - @server.shutdown # WEBrick::HTTPServer - TestApp.stop! rescue nil + stop_app_and_wait(TestApp, @server, @server_thread) end let(:port) { PORT } @@ -450,7 +449,7 @@ TestApp.last_request = nil - @server = start_app_and_wait(TestApp) + @server, @server_thread = start_app_and_wait(TestApp) end let(:webrick_config) do @@ -464,9 +463,7 @@ end after do - @server.shutdown # WEBrick::HTTPServer - - TestApp.stop! rescue nil + stop_app_and_wait(TestApp, @server, @server_thread) TestApp.server_settings = default_server_settings end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 3d8d563..b3a207c 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -104,8 +104,7 @@ def self.retry_fail_count() #http://stackoverflow.com/questions/6557079/start-and-call-ruby-http-server-in-the-same-script def start_app_and_wait(app, opts = {}) queue = Queue.new - - Thread.start do + server_thread = Thread.start do begin app.start!({ server: 'WEBrick', port: PORT }.merge opts) do |server| yield(server) if block_given? @@ -116,7 +115,18 @@ def start_app_and_wait(app, opts = {}) end end - queue.pop # blocks until the start! callback runs + server = queue.pop # blocks until the start! callback runs + [server, server_thread] + end + + def stop_app_and_wait(app, server, server_thread) + app.stop! rescue nil + server.shutdown rescue nil + + unless server_thread.join(30) + warn "Timed out waiting for test server thread to stop" + server_thread.kill + end end config.extend(Module.new do