From 81980c09e519442a0f1540b9c48740d77330c705 Mon Sep 17 00:00:00 2001 From: Jun Aruga Date: Oct 30 2020 15:51:17 +0000 Subject: Fix to run the tests on RSpec 3. --- diff --git a/rubygem-thin-1.7.2-Extend-startup-time-daemonizing-test.patch b/rubygem-thin-1.7.2-Extend-startup-time-daemonizing-test.patch new file mode 100644 index 0000000..b9a9edf --- /dev/null +++ b/rubygem-thin-1.7.2-Extend-startup-time-daemonizing-test.patch @@ -0,0 +1,24 @@ +From 64a9295cd9928506fb85f2819920f0c6fd83e417 Mon Sep 17 00:00:00 2001 +From: Samuel Williams +Date: Mon, 3 Aug 2020 19:45:59 +1200 +Subject: [PATCH 3/7] Extend startup time. + +--- + spec/daemonizing_spec.rb | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/spec/daemonizing_spec.rb b/spec/daemonizing_spec.rb +index efeef08..8ac4439 100644 +--- a/spec/daemonizing_spec.rb ++++ b/spec/daemonizing_spec.rb +@@ -203,6 +203,6 @@ describe 'Daemonizing' do + + private + def wait_for_server_to_start +- proc { sleep 0.1 until File.exist?(@server.pid_file) }.should take_less_then(10) ++ proc { sleep 0.1 until File.exist?(@server.pid_file) }.should take_less_then(30) + end + end +-- +2.26.2 + diff --git a/rubygem-thin-1.7.2-Increase-timeouts-daemonizing-test.patch b/rubygem-thin-1.7.2-Increase-timeouts-daemonizing-test.patch new file mode 100644 index 0000000..30dce5d --- /dev/null +++ b/rubygem-thin-1.7.2-Increase-timeouts-daemonizing-test.patch @@ -0,0 +1,43 @@ +From b6900d7350e68e7272a2959fe63671f86772948e Mon Sep 17 00:00:00 2001 +From: Samuel Williams +Date: Mon, 3 Aug 2020 22:10:41 +1200 +Subject: [PATCH 4/7] Increase timeouts. + +--- + spec/daemonizing_spec.rb | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/spec/daemonizing_spec.rb b/spec/daemonizing_spec.rb +index 8ac4439..1ef8f02 100644 +--- a/spec/daemonizing_spec.rb ++++ b/spec/daemonizing_spec.rb +@@ -45,7 +45,7 @@ describe 'Daemonizing' do + File.exist?(@server.pid_file).should be_true + @pid = @server.pid + +- proc { sleep 0.1 while File.exist?(@server.pid_file) }.should take_less_then(5) ++ proc { sleep 0.1 while File.exist?(@server.pid_file) }.should take_less_then(20) + end + + it 'should redirect stdio to a log file' do +@@ -59,7 +59,7 @@ describe 'Daemonizing' do + end + Process.wait(@pid) + # Wait for the file to close and magical stuff to happen +- proc { sleep 0.1 until File.exist?('daemon_test.log') }.should take_less_then(3) ++ proc { sleep 0.1 until File.exist?('daemon_test.log') }.should take_less_then(20) + sleep 0.5 + + @pid = @server.pid +@@ -153,7 +153,7 @@ describe 'Daemonizing' do + + Process.wait(@pid) + +- proc { sleep 0.1 while File.exist?(@server.pid_file) }.should take_less_then(10) ++ proc { sleep 0.1 while File.exist?(@server.pid_file) }.should take_less_then(20) + end + + it "should ignore if no restart block specified" do +-- +2.26.2 + diff --git a/rubygem-thin-1.7.2-Isolate-daemonization-specs-tests.patch b/rubygem-thin-1.7.2-Isolate-daemonization-specs-tests.patch new file mode 100644 index 0000000..be47923 --- /dev/null +++ b/rubygem-thin-1.7.2-Isolate-daemonization-specs-tests.patch @@ -0,0 +1,351 @@ +From 1d48444420df67aa7538c1687ca1aa32cb5273fe Mon Sep 17 00:00:00 2001 +From: Samuel Williams +Date: Tue, 4 Aug 2020 15:38:15 +1200 +Subject: [PATCH] Isolate daemonization specs. + +--- + spec/daemonizing_spec.rb | 216 ++++++++++++++++++--------------------- + spec/logging_spec.rb | 4 +- + spec/spec_helper.rb | 4 + + 4 files changed, 126 insertions(+), 123 deletions(-) + +diff --git a/spec/daemonizing_spec.rb b/spec/daemonizing_spec.rb +index 81a8c8f..10e41b1 100644 +--- a/spec/daemonizing_spec.rb ++++ b/spec/daemonizing_spec.rb +@@ -3,202 +3,186 @@ require 'spec_helper' + require 'timeout' + + class TestServer +- include Logging # Daemonizable should include this? ++ include Logging + include Daemonizable +- ++ + def stop + end +- ++ + def name + 'Thin test server' + end + end + + describe 'Daemonizing' do +- before :all do +- @logfile = File.dirname(__FILE__) + '/../log/daemonizing_test.log' +- @pidfile = 'test.pid' +- File.delete(@logfile) if File.exist?(@logfile) +- File.delete(@pidfile) if File.exist?(@pidfile) ++ let(:path) {File.expand_path("tmp", __dir__)} ++ let(:log_file) {File.expand_path("test_server.log", path)} ++ let(:pid_file) {File.expand_path("test.pid", path)} ++ ++ before do ++ FileUtils.rm_rf path ++ FileUtils.mkpath path ++ FileUtils.touch log_file + end +- +- before :each do +- @server = TestServer.new +- @server.log_file = @logfile +- @server.pid_file = @pidfile +- @pid = nil ++ ++ subject(:server) do ++ TestServer.new.tap do |server| ++ server.log_file = log_file ++ server.pid_file = pid_file ++ end + end +- ++ + it 'should have a pid file' do +- @server.should respond_to(:pid_file) +- @server.should respond_to(:pid_file=) ++ subject.should respond_to(:pid_file) ++ subject.should respond_to(:pid_file=) + end +- ++ + it 'should create a pid file' do +- @pid = fork do +- @server.daemonize +- sleep 1 ++ fork do ++ subject.daemonize ++ sleep + end +- +- sleep 1 +- Process.wait(@pid) +- File.exist?(@server.pid_file).should be_truthy +- @pid = @server.pid + +- proc { sleep 0.1 while File.exist?(@server.pid_file) }.should take_less_then(20) ++ wait_for_server_to_start ++ ++ subject.kill + end + + it 'should redirect stdio to a log file' do +- @pid = fork do +- @server.log_file = 'daemon_test.log' +- @server.daemonize ++ pid = fork do ++ subject.daemonize + + puts "simple puts" + STDERR.puts "STDERR.puts" + STDOUT.puts "STDOUT.puts" ++ ++ sleep + end + +- Process.wait(@pid) ++ wait_for_server_to_start + +- log = File.read('daemon_test.log') ++ log = File.read(log_file) + log.should include('simple puts', 'STDERR.puts', 'STDOUT.puts') +- +- File.delete 'daemon_test.log' ++ ++ server.kill + end + + it 'should change privilege' do +- @pid = fork do +- @server.daemonize +- @server.change_privilege('root', 'admin') ++ pid = fork do ++ subject.daemonize ++ subject.change_privilege('root', 'admin') + end +- Process.wait(@pid) +- $?.should be_a_success ++ ++ _, status = Process.wait2(pid) ++ ++ status.should be_a_success + end + + it 'should kill process in pid file' do +- File.exist?(@server.pid_file).should be_falsey +- +- @pid = fork do +- @server.daemonize +- loop { sleep 3 } ++ File.exist?(subject.pid_file).should be_falsey ++ ++ fork do ++ subject.daemonize ++ sleep + end +- ++ + wait_for_server_to_start +- +- Timeout.timeout(10) do +- silence_stream STDOUT do +- TestServer.kill(@server.pid_file, 1) +- end ++ ++ File.exist?(subject.pid_file).should be_truthy ++ ++ silence_stream STDOUT do ++ subject.kill(1) + end +- +- Process.wait(@pid) +- +- File.exist?(@server.pid_file).should be_falsey ++ ++ File.exist?(subject.pid_file).should be_falsey + end + + it 'should force kill process in pid file' do +- @pid = fork do +- @server.daemonize +- loop { sleep 3 } ++ fork do ++ subject.daemonize ++ sleep + end +- ++ + wait_for_server_to_start +- +- Timeout.timeout(10) do +- silence_stream STDOUT do +- TestServer.kill(@server.pid_file, 0) +- end +- end +- +- Process.wait(@pid) +- +- File.exist?(@server.pid_file).should be_falsey ++ ++ subject.kill(0) ++ ++ File.exist?(subject.pid_file).should be_falsey + end + + it 'should send kill signal if timeout' do +- @pid = fork do +- @server.should_receive(:stop) # pretend we cannot handle the INT signal +- @server.daemonize +- sleep 5 ++ fork do ++ subject.daemonize ++ sleep + end +- ++ + wait_for_server_to_start +- +- silence_stream STDOUT do +- TestServer.kill(@server.pid_file, 1) +- end +- +- Process.wait(@pid) +- +- File.exist?(@server.pid_file).should be_falsey +- Process.running?(@pid).should be_falsey ++ ++ pid = subject.pid ++ ++ subject.kill(1) ++ ++ File.exist?(subject.pid_file).should be_falsey ++ Process.running?(pid).should be_falsey + end + + it "should restart" do +- @pid = fork do +- @server.on_restart {} +- @server.daemonize ++ fork do ++ subject.on_restart {} ++ subject.daemonize + sleep 5 + end +- ++ + wait_for_server_to_start +- ++ + silence_stream STDOUT do +- TestServer.restart(@server.pid_file) ++ TestServer.restart(subject.pid_file) + end +- +- Process.wait(@pid) +- +- proc { sleep 0.1 while File.exist?(@server.pid_file) }.should take_less_then(20) ++ ++ proc { sleep 0.1 while File.exist?(subject.pid_file) }.should take_less_then(20) + end + + it "should ignore if no restart block specified" do +- @server.restart ++ subject.restart + end + + it "should not restart when not running" do + silence_stream STDOUT do +- @server.restart ++ subject.restart + end + end + + it "should exit and raise if pid file already exist" do +- @pid = fork do +- @server.daemonize ++ fork do ++ subject.daemonize + sleep 5 + end ++ + wait_for_server_to_start +- +- @pid = @server.pid + +- proc { @server.daemonize }.should raise_error(PidFileExist) +- +- File.exist?(@server.pid_file).should be_truthy ++ proc { subject.daemonize }.should raise_error(PidFileExist) ++ ++ File.exist?(subject.pid_file).should be_truthy + end +- ++ + it "should raise if no pid file" do + proc do + TestServer.kill("donotexist", 0) + end.should raise_error(PidFileNotFound) + end +- ++ + it "should should delete pid file if stale" do + # Create a file w/ a PID that does not exist +- File.open(@server.pid_file, 'w') { |f| f << 999999999 } ++ File.open(subject.pid_file, 'w') { |f| f << 999999999 } + +- @server.send(:remove_stale_pid_file) ++ subject.send(:remove_stale_pid_file) + +- File.exist?(@server.pid_file).should be_falsey ++ File.exist?(subject.pid_file).should be_falsey + end +- +- after do +- Process.kill(9, @pid.to_i) if @pid && Process.running?(@pid.to_i) +- Process.kill(9, @server.pid) if @server.pid && Process.running?(@server.pid) +- File.delete(@server.pid_file) rescue nil +- end +- ++ + private +- def wait_for_server_to_start +- proc { sleep 0.1 until File.exist?(@server.pid_file) }.should take_less_then(30) +- end ++ ++ def wait_for_server_to_start ++ proc{sleep 0.1 until File.exist?(subject.pid_file)}.should take_less_then(10) ++ end + end +diff --git a/spec/logging_spec.rb b/spec/logging_spec.rb +index a24f71d..3d2fdc0 100644 +--- a/spec/logging_spec.rb ++++ b/spec/logging_spec.rb +@@ -12,8 +12,8 @@ describe Logging do + + after do + Logging.silent = true +- Logging.debug = false +- Logging.trace = false ++ Logging.debug = false ++ Logging.trace = false + end + + describe "when setting a custom logger" do +diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb +index a09a2d7..d031177 100644 +--- a/spec/spec_helper.rb ++++ b/spec/spec_helper.rb +@@ -253,6 +253,10 @@ module Helpers + end + + RSpec.configure do |config| ++ config.expect_with(:rspec) do |c| ++ c.syntax = :should ++ end ++ + config.include Matchers + config.include Helpers + end +-- +2.26.2 + diff --git a/rubygem-thin-1.7.2-Isolate-daemonization-specs.patch b/rubygem-thin-1.7.2-Isolate-daemonization-specs.patch new file mode 100644 index 0000000..19b2c68 --- /dev/null +++ b/rubygem-thin-1.7.2-Isolate-daemonization-specs.patch @@ -0,0 +1,60 @@ +From 1d48444420df67aa7538c1687ca1aa32cb5273fe Mon Sep 17 00:00:00 2001 +From: Samuel Williams +Date: Tue, 4 Aug 2020 15:38:15 +1200 +Subject: [PATCH] Isolate daemonization specs. + +--- + lib/thin/daemonizing.rb | 25 ++++- + 4 files changed, 126 insertions(+), 123 deletions(-) + +diff --git a/lib/thin/daemonizing.rb b/lib/thin/daemonizing.rb +index aa0dbfe..8814a36 100644 +--- a/lib/thin/daemonizing.rb ++++ b/lib/thin/daemonizing.rb +@@ -30,11 +30,17 @@ module Thin + def self.included(base) + base.extend ClassMethods + end +- ++ + def pid + File.exist?(pid_file) && !File.zero?(pid_file) ? open(pid_file).read.to_i : nil + end +- ++ ++ def kill(timeout = 60) ++ if File.exist?(@pid_file) ++ self.class.kill(@pid_file, timeout) ++ end ++ end ++ + # Turns the current script into a daemon process that detaches from the console. + def daemonize + raise PlatformNotSupported, 'Daemonizing is not supported on Windows' if Thin.win? +@@ -116,14 +122,23 @@ module Thin + def restart(pid_file) + send_signal('HUP', pid_file) + end +- ++ ++ def monotonic_time ++ Process.clock_gettime(Process::CLOCK_MONOTONIC) ++ end ++ + # Send a +signal+ to the process which PID is stored in +pid_file+. + def send_signal(signal, pid_file, timeout=60) + if pid = read_pid_file(pid_file) + Logging.log_info "Sending #{signal} signal to process #{pid} ... " ++ + Process.kill(signal, pid) +- Timeout.timeout(timeout) do +- sleep 0.1 while Process.running?(pid) ++ ++ # This loop seems kind of racy to me... ++ started_at = monotonic_time ++ while Process.running?(pid) ++ sleep 0.1 ++ raise Timeout::Error if (monotonic_time - started_at) > timeout + end + else + raise PidFileNotFound, "Can't stop process, no PID found in #{pid_file}" diff --git a/rubygem-thin-1.7.2-Remove-unused-argument-daemonizing-test.patch b/rubygem-thin-1.7.2-Remove-unused-argument-daemonizing-test.patch new file mode 100644 index 0000000..9dcaeda --- /dev/null +++ b/rubygem-thin-1.7.2-Remove-unused-argument-daemonizing-test.patch @@ -0,0 +1,70 @@ +From a441671e8b645062e1ba0903d45f52dec12ee63c Mon Sep 17 00:00:00 2001 +From: Samuel Williams +Date: Mon, 3 Aug 2020 19:43:58 +1200 +Subject: [PATCH 2/7] Remove unused argument. + +--- + spec/daemonizing_spec.rb | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) + +diff --git a/spec/daemonizing_spec.rb b/spec/daemonizing_spec.rb +index 38ef00a..efeef08 100644 +--- a/spec/daemonizing_spec.rb ++++ b/spec/daemonizing_spec.rb +@@ -87,7 +87,7 @@ describe 'Daemonizing' do + loop { sleep 3 } + end + +- server_should_start_in_less_then 3 ++ wait_for_server_to_start + + Timeout.timeout(10) do + silence_stream STDOUT do +@@ -106,7 +106,7 @@ describe 'Daemonizing' do + loop { sleep 3 } + end + +- server_should_start_in_less_then 3 ++ wait_for_server_to_start + + Timeout.timeout(10) do + silence_stream STDOUT do +@@ -126,7 +126,7 @@ describe 'Daemonizing' do + sleep 5 + end + +- server_should_start_in_less_then 10 ++ wait_for_server_to_start + + silence_stream STDOUT do + TestServer.kill(@server.pid_file, 1) +@@ -145,7 +145,7 @@ describe 'Daemonizing' do + sleep 5 + end + +- server_should_start_in_less_then 10 ++ wait_for_server_to_start + + silence_stream STDOUT do + TestServer.restart(@server.pid_file) +@@ -171,7 +171,7 @@ describe 'Daemonizing' do + @server.daemonize + sleep 5 + end +- server_should_start_in_less_then 10 ++ wait_for_server_to_start + + @pid = @server.pid + +@@ -202,7 +202,7 @@ describe 'Daemonizing' do + end + + private +- def server_should_start_in_less_then(sec=10) ++ def wait_for_server_to_start + proc { sleep 0.1 until File.exist?(@server.pid_file) }.should take_less_then(10) + end + end +-- +2.26.2 + diff --git a/rubygem-thin-1.7.2-Wait-for-child-process-daemonizing-test.patch b/rubygem-thin-1.7.2-Wait-for-child-process-daemonizing-test.patch new file mode 100644 index 0000000..ddc6fe8 --- /dev/null +++ b/rubygem-thin-1.7.2-Wait-for-child-process-daemonizing-test.patch @@ -0,0 +1,107 @@ +From a7daa9748b7d4d521b07fa954aed2dbc3c7b1541 Mon Sep 17 00:00:00 2001 +From: Samuel Williams +Date: Mon, 3 Aug 2020 19:23:28 +1200 +Subject: [PATCH 1/7] Wait for child process (state contamination between + specs). + +--- + spec/daemonizing_spec.rb | 34 +++++++++++++++++----------------- + 1 file changed, 17 insertions(+), 17 deletions(-) + +diff --git a/spec/daemonizing_spec.rb b/spec/daemonizing_spec.rb +index 50e906a..38ef00a 100644 +--- a/spec/daemonizing_spec.rb ++++ b/spec/daemonizing_spec.rb +@@ -1,5 +1,7 @@ + require 'spec_helper' + ++require 'timeout' ++ + class TestServer + include Logging # Daemonizable should include this? + include Daemonizable +@@ -84,17 +86,17 @@ describe 'Daemonizing' do + @server.daemonize + loop { sleep 3 } + end +- ++ + server_should_start_in_less_then 3 + +- @pid = @server.pid +- +- timeout(10) do ++ Timeout.timeout(10) do + silence_stream STDOUT do + TestServer.kill(@server.pid_file, 1) + end + end +- ++ ++ Process.wait(@pid) ++ + File.exist?(@server.pid_file).should be_false + end + +@@ -103,17 +105,17 @@ describe 'Daemonizing' do + @server.daemonize + loop { sleep 3 } + end +- ++ + server_should_start_in_less_then 3 + +- @pid = @server.pid +- +- timeout(10) do ++ Timeout.timeout(10) do + silence_stream STDOUT do + TestServer.kill(@server.pid_file, 0) + end + end +- ++ ++ Process.wait(@pid) ++ + File.exist?(@server.pid_file).should be_false + end + +@@ -123,17 +125,15 @@ describe 'Daemonizing' do + @server.daemonize + sleep 5 + end +- ++ + server_should_start_in_less_then 10 + +- @pid = @server.pid +- + silence_stream STDOUT do + TestServer.kill(@server.pid_file, 1) + end + +- sleep 1 +- ++ Process.wait(@pid) ++ + File.exist?(@server.pid_file).should be_false + Process.running?(@pid).should be_false + end +@@ -147,12 +147,12 @@ describe 'Daemonizing' do + + server_should_start_in_less_then 10 + +- @pid = @server.pid +- + silence_stream STDOUT do + TestServer.restart(@server.pid_file) + end + ++ Process.wait(@pid) ++ + proc { sleep 0.1 while File.exist?(@server.pid_file) }.should take_less_then(10) + end + +-- +2.26.2 + diff --git a/rubygem-thin-1.7.2-dont-wait-for-daemon-daemonizing-test.patch b/rubygem-thin-1.7.2-dont-wait-for-daemon-daemonizing-test.patch new file mode 100644 index 0000000..cd80b3c --- /dev/null +++ b/rubygem-thin-1.7.2-dont-wait-for-daemon-daemonizing-test.patch @@ -0,0 +1,33 @@ +From 11c322efc6c8bf405d7e1babe970af24ed1273c2 Mon Sep 17 00:00:00 2001 +From: Samuel Williams +Date: Mon, 3 Aug 2020 22:14:27 +1200 +Subject: [PATCH 5/7] Don't wait for `daemon_test.log` to exist, just assume it + does after server is finished. + +--- + spec/daemonizing_spec.rb | 9 +++------ + 1 file changed, 3 insertions(+), 6 deletions(-) + +diff --git a/spec/daemonizing_spec.rb b/spec/daemonizing_spec.rb +index 1ef8f02..2458398 100644 +--- a/spec/daemonizing_spec.rb ++++ b/spec/daemonizing_spec.rb +@@ -57,12 +57,9 @@ describe 'Daemonizing' do + STDERR.puts "STDERR.puts" + STDOUT.puts "STDOUT.puts" + end +- Process.wait(@pid) +- # Wait for the file to close and magical stuff to happen +- proc { sleep 0.1 until File.exist?('daemon_test.log') }.should take_less_then(20) +- sleep 0.5 +- +- @pid = @server.pid ++ ++ _, status = Process.wait2(@pid) ++ pp status + + log = File.read('daemon_test.log') + log.should include('simple puts', 'STDERR.puts', 'STDOUT.puts') +-- +2.26.2 + diff --git a/rubygem-thin-1.7.2-fix-rspec3-undefined-method-expect.patch b/rubygem-thin-1.7.2-fix-rspec3-undefined-method-expect.patch new file mode 100644 index 0000000..bf3ed1e --- /dev/null +++ b/rubygem-thin-1.7.2-fix-rspec3-undefined-method-expect.patch @@ -0,0 +1,27 @@ +From f05e3b9c2cd68dde46bac1a10ffd7cbc28d17407 Mon Sep 17 00:00:00 2001 +From: Samuel Williams +Date: Tue, 4 Aug 2020 15:40:48 +1200 +Subject: [PATCH] asdf + +--- + spec/spec_helper.rb | 4 ---- + 1 file changed, 4 deletions(-) + +diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb +index d031177..a09a2d7 100644 +--- a/spec/spec_helper.rb ++++ b/spec/spec_helper.rb +@@ -253,10 +253,6 @@ module Helpers + end + + RSpec.configure do |config| +- config.expect_with(:rspec) do |c| +- c.syntax = :should +- end +- + config.include Matchers + config.include Helpers + end +-- +2.26.2 + diff --git a/rubygem-thin-1.7.2-support-rspec3-tidy.patch b/rubygem-thin-1.7.2-support-rspec3-tidy.patch new file mode 100644 index 0000000..ea84b08 --- /dev/null +++ b/rubygem-thin-1.7.2-support-rspec3-tidy.patch @@ -0,0 +1,185 @@ +From 86e21f334894a8398ad195fe467046ee9c6ba8a5 Mon Sep 17 00:00:00 2001 +From: Samuel Williams +Date: Tue, 4 Aug 2020 14:06:07 +1200 +Subject: [PATCH 7/7] Tidy up RSpec 3 migration. + +--- + spec/daemonizing_spec.rb | 3 +-- + spec/logging_spec.rb | 25 +++++++++++-------------- + spec/server/stopping_spec.rb | 4 +++- + spec/spec_helper.rb | 9 ++++----- + 4 files changed, 19 insertions(+), 22 deletions(-) + +diff --git a/spec/daemonizing_spec.rb b/spec/daemonizing_spec.rb +index 05f03fa..81a8c8f 100644 +--- a/spec/daemonizing_spec.rb ++++ b/spec/daemonizing_spec.rb +@@ -58,8 +58,7 @@ describe 'Daemonizing' do + STDOUT.puts "STDOUT.puts" + end + +- _, status = Process.wait2(@pid) +- pp status ++ Process.wait(@pid) + + log = File.read('daemon_test.log') + log.should include('simple puts', 'STDERR.puts', 'STDOUT.puts') +diff --git a/spec/logging_spec.rb b/spec/logging_spec.rb +index 9510c1f..a24f71d 100644 +--- a/spec/logging_spec.rb ++++ b/spec/logging_spec.rb +@@ -8,12 +8,9 @@ class TestLogging + end + + describe Logging do ++ subject {TestLogging.new} + +- before :all do +- @object = TestLogging.new +- end +- +- after(:all) do ++ after do + Logging.silent = true + Logging.debug = false + Logging.trace = false +@@ -50,7 +47,7 @@ describe Logging do + # + it "at log level DEBUG should output logs at debug level" do + Logging.debug = true +- @object.log_debug("hi") ++ subject.log_debug("hi") + + str = nil + expect { str = @readpipe.read_nonblock(512) }.to_not raise_error +@@ -61,7 +58,7 @@ describe Logging do + # + it "at log level NOT DEBUG should NOT output logs at debug level" do + Logging.debug = false +- @object.log_debug("hiya") ++ subject.log_debug("hiya") + + expect do + @readpipe.read_nonblock(512) +@@ -79,7 +76,7 @@ describe Logging do + # + it "should not log messages if silenced via module method" do + Logging.silent = true +- @object.log_info("hola") ++ subject.log_info("hola") + expect do + @readpipe.read_nonblock(512) + end.to raise_error(IO::EAGAINWaitReadable) +@@ -94,8 +91,8 @@ describe Logging do + end + + it "should not log anything if silenced via instance methods" do +- @object.silent = true +- @object.log_info("hello") ++ subject.silent = true ++ subject.log_info("hello") + expect do + @readpipe.read_nonblock(512) + end.to raise_error(IO::EAGAINWaitReadable) +@@ -108,7 +105,7 @@ describe Logging do + it "should log at debug level if debug logging is enabled " do + Logging.debug = true + out = with_redirected_stdout do +- @object.log_debug("Hey") ++ subject.log_debug("Hey") + end + + out.include?("Hey").should be_truthy +@@ -135,14 +132,14 @@ describe Logging do + it "should NOT emit trace messages if tracing is disabled" do + Logging.trace = false + @custom_tracer.should_not_receive(:info) +- @object.trace("howdy") ++ subject.trace("howdy") + end + + it "should emit trace messages when tracing is enabled" do + Logging.trace = true + @custom_tracer.should_receive(:info) + +- @object.trace("aloha") ++ subject.trace("aloha") + end + + end # Tracer tests (with custom tracer) +@@ -152,7 +149,7 @@ describe Logging do + it "should emit trace messages if tracing is enabled " do + Logging.trace = true + out = with_redirected_stdout do +- @object.trace("Hey") ++ subject.trace("Hey") + end + + out.include?("Hey").should be_truthy +diff --git a/spec/server/stopping_spec.rb b/spec/server/stopping_spec.rb +index b284cf7..5baa2b2 100644 +--- a/spec/server/stopping_spec.rb ++++ b/spec/server/stopping_spec.rb +@@ -1,5 +1,7 @@ + require 'spec_helper' + ++require 'timeout' ++ + describe Server, "stopping" do + before do + start_server do |env| +@@ -17,7 +19,7 @@ describe Server, "stopping" do + @done = true + end + +- timeout(2) do ++ Timeout.timeout(2) do + Thread.pass until @done + end + +diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb +index 5a29ea9..a09a2d7 100644 +--- a/spec/spec_helper.rb ++++ b/spec/spec_helper.rb +@@ -22,7 +22,6 @@ end + module Matchers + class BeFasterThen + def initialize(max_time) +- require 'benchmark_unit' + @max_time = max_time + end + +@@ -31,7 +30,7 @@ module Matchers + @time, multiplier = 0, 1 + + while (@time < 0.01) do +- @time = Benchmark::Unit.measure do ++ @time = Benchmark.realtime do + multiplier.times &proc + end + multiplier *= 10 +@@ -39,10 +38,10 @@ module Matchers + + multiplier /= 10 + +- iterations = (Benchmark::Unit::CLOCK_TARGET / @time).to_i * multiplier ++ iterations = (@time * multiplier).to_i + iterations = 1 if iterations < 1 + +- total = Benchmark::Unit.measure do ++ total = Benchmark.realtime do + iterations.times &proc + end + +@@ -52,7 +51,7 @@ module Matchers + end + + def failure_message(less_more=:less) +- "took <#{@time.inspect} RubySeconds>, should take #{less_more} than #{@max_time} RubySeconds." ++ "took <#{@time.inspect}s>, should take #{less_more} than #{@max_time}s." + end + + def negative_failure_message +-- +2.26.2 + diff --git a/rubygem-thin-1.7.2-support-rspec3.patch b/rubygem-thin-1.7.2-support-rspec3.patch new file mode 100644 index 0000000..577d1b1 --- /dev/null +++ b/rubygem-thin-1.7.2-support-rspec3.patch @@ -0,0 +1,575 @@ +From 7bcda8c49f45b9514a5cc89163bc8e934e13a046 Mon Sep 17 00:00:00 2001 +From: Jun Aruga +Date: Thu, 2 Mar 2017 21:15:35 +0100 +Subject: [PATCH 6/7] Support RSpec 3 + +--- + Gemfile | 2 +- + spec/backends/swiftiply_client_spec.rb | 12 +++++------ + spec/backends/unix_server_spec.rb | 4 ++-- + spec/connection_spec.rb | 30 ++++++++++++++------------ + spec/controllers/controller_spec.rb | 8 +++---- + spec/controllers/service_spec.rb | 8 +++---- + spec/daemonizing_spec.rb | 16 +++++++------- + spec/logging_spec.rb | 30 ++++++++++++++++---------- + spec/request/processing_spec.rb | 14 ++++++------ + spec/runner_spec.rb | 26 +++++++++++----------- + spec/server/unix_socket_spec.rb | 4 ++-- + spec/spec_helper.rb | 2 +- + tasks/spec.rake | 9 ++++---- + thin.gemspec | 2 +- + 14 files changed, 88 insertions(+), 79 deletions(-) + +diff --git a/spec/backends/swiftiply_client_spec.rb b/spec/backends/swiftiply_client_spec.rb +index 036a6a8..97e493d 100644 +--- a/spec/backends/swiftiply_client_spec.rb ++++ b/spec/backends/swiftiply_client_spec.rb +@@ -3,7 +3,7 @@ require 'spec_helper' + describe Backends::SwiftiplyClient do + before do + @backend = Backends::SwiftiplyClient.new('0.0.0.0', 3333) +- @backend.server = mock('server').as_null_object ++ @backend.server = double('server').as_null_object + end + + it "should connect" do +@@ -26,7 +26,7 @@ describe SwiftiplyConnection do + before do + @connection = SwiftiplyConnection.new(nil) + @connection.backend = Backends::SwiftiplyClient.new('0.0.0.0', 3333) +- @connection.backend.server = mock('server').as_null_object ++ @connection.backend.server = double('server').as_null_object + end + + it do +@@ -39,8 +39,8 @@ describe SwiftiplyConnection do + end + + it "should reconnect on unbind" do +- @connection.backend.stub!(:running?).and_return(true) +- @connection.stub!(:rand).and_return(0) # Make sure we don't wait ++ allow(@connection.backend).to receive(:running?) { true } ++ allow(@connection).to receive(:rand) { 0 } # Make sure we don't wait + + @connection.should_receive(:reconnect).with('0.0.0.0', 3333) + +@@ -51,7 +51,7 @@ describe SwiftiplyConnection do + end + + it "should not reconnect when not running" do +- @connection.backend.stub!(:running?).and_return(false) ++ allow(@connection.backend).to receive(:running?) { false } + EventMachine.should_not_receive(:add_timer) + @connection.unbind + end +@@ -63,4 +63,4 @@ describe SwiftiplyConnection do + it "should generate swiftiply_handshake based on key" do + @connection.send(:swiftiply_handshake, 'key').should == 'swiftclient000000000d0503key' + end +-end +\ No newline at end of file ++end +diff --git a/spec/backends/unix_server_spec.rb b/spec/backends/unix_server_spec.rb +index b007d7a..e1f436e 100644 +--- a/spec/backends/unix_server_spec.rb ++++ b/spec/backends/unix_server_spec.rb +@@ -22,7 +22,7 @@ describe Backends::UnixServer do + + it "should remove socket file on close" do + @backend.close +- File.exist?('/tmp/thin-test.sock').should be_false ++ File.exist?('/tmp/thin-test.sock').should be_falsey + end + end + +@@ -34,4 +34,4 @@ describe UnixConnection do + it "should return 127.0.0.1 as remote_address" do + @connection.remote_address.should == '127.0.0.1' + end +-end +\ No newline at end of file ++end +diff --git a/spec/connection_spec.rb b/spec/connection_spec.rb +index 54b6e0a..8fc24a3 100644 +--- a/spec/connection_spec.rb ++++ b/spec/connection_spec.rb +@@ -2,10 +2,10 @@ require 'spec_helper' + + describe Connection do + before do +- EventMachine.stub(:send_data) +- @connection = Connection.new(mock('EM').as_null_object) ++ allow(EventMachine).to receive(:send_data) ++ @connection = Connection.new(double('EM').as_null_object) + @connection.post_init +- @connection.backend = mock("backend", :ssl? => false) ++ @connection.backend = double("backend", :ssl? => false) + @connection.app = proc do |env| + [200, {}, ['body']] + end +@@ -17,14 +17,14 @@ describe Connection do + end + + it "should make a valid response on bad request" do +- @connection.request.stub!(:parse).and_raise(InvalidRequest) ++ allow(@connection.request).to receive(:parse).and_raise(InvalidRequest) + @connection.should_receive(:post_process).with(Response::BAD_REQUEST) + @connection.receive_data('') + end + + it "should close connection on InvalidRequest error in receive_data" do +- @connection.request.stub!(:parse).and_raise(InvalidRequest) +- @connection.response.stub!(:persistent?).and_return(false) ++ allow(@connection.request).to receive(:parse).and_raise(InvalidRequest) ++ allow(@connection.response).to receive(:persistent?) { false } + @connection.can_persist! + @connection.should_receive(:terminate_request) + @connection.receive_data('') +@@ -42,7 +42,7 @@ describe Connection do + + it "should rescue error in process" do + @connection.app.should_receive(:call).and_raise(StandardError) +- @connection.response.stub!(:persistent?).and_return(false) ++ allow(@connection.response).to receive(:persistent?) { false } + @connection.should_receive(:terminate_request) + @connection.process + end +@@ -55,7 +55,7 @@ describe Connection do + + it "should not close persistent connection on error" do + @connection.app.should_receive(:call).and_raise(StandardError) +- @connection.response.stub!(:persistent?).and_return(true) ++ allow(@connection.response).to receive(:persistent?) { true } + @connection.can_persist! + @connection.should_receive(:teminate_request).never + @connection.process +@@ -68,27 +68,29 @@ describe Connection do + + it "should not return HTTP_X_FORWARDED_FOR as remote_address" do + @connection.request.env['HTTP_X_FORWARDED_FOR'] = '1.2.3.4' +- @connection.stub!(:socket_address).and_return("127.0.0.1") ++ allow(@connection).to receive(:socket_address) { "127.0.0.1" } + @connection.remote_address.should == "127.0.0.1" + end + + it "should return nil on error retreiving remote_address" do +- @connection.stub!(:get_peername).and_raise(RuntimeError) ++ allow(@connection).to receive(:get_peername).and_raise(RuntimeError) + @connection.remote_address.should be_nil + end + + it "should return nil on nil get_peername" do +- @connection.stub!(:get_peername).and_return(nil) ++ allow(@connection).to receive(:get_peername) { nil } + @connection.remote_address.should be_nil + end + + it "should return nil on empty get_peername" do +- @connection.stub!(:get_peername).and_return('') ++ allow(@connection).to receive(:get_peername) { '' } + @connection.remote_address.should be_nil + end + + it "should return remote_address" do +- @connection.stub!(:get_peername).and_return(Socket.pack_sockaddr_in(3000, '127.0.0.1')) ++ allow(@connection).to receive(:get_peername) do ++ Socket.pack_sockaddr_in(3000, '127.0.0.1') ++ end + @connection.remote_address.should == '127.0.0.1' + end + +@@ -97,7 +99,7 @@ describe Connection do + end + + it "should be persistent when response is and allowed" do +- @connection.response.stub!(:persistent?).and_return(true) ++ allow(@connection.response).to receive(:persistent?) { true } + @connection.can_persist! + @connection.should be_persistent + end +diff --git a/spec/controllers/controller_spec.rb b/spec/controllers/controller_spec.rb +index f0ec609..e31fb95 100644 +--- a/spec/controllers/controller_spec.rb ++++ b/spec/controllers/controller_spec.rb +@@ -18,7 +18,7 @@ describe Controller, 'start' do + + Server.should_receive(:new).with('0.0.0.0', 3000, @controller.options).and_return(@server) + @server.should_receive(:config) +- Rack::Adapter::Rails.stub!(:new).and_return(@adapter) ++ allow(Rack::Adapter::Rails).to receive(:new) { @adapter } + end + + it "should configure server" do +@@ -87,7 +87,7 @@ describe Controller, 'start' do + @controller.options[:threaded] = true + @controller.start + +- @server.threaded.should be_true ++ @server.threaded.should be_truthy + end + + it "should set RACK_ENV" do +@@ -103,7 +103,7 @@ end + describe Controller do + before do + @controller = Controller.new(:pid => 'thin.pid', :timeout => 10) +- @controller.stub!(:wait_for_file) ++ allow(@controller).to receive(:wait_for_file) + end + + it "should stop" do +@@ -126,4 +126,4 @@ describe Controller do + + File.delete('test.yml') + end +-end +\ No newline at end of file ++end +diff --git a/spec/controllers/service_spec.rb b/spec/controllers/service_spec.rb +index 1164bb6..bab2dcd 100644 +--- a/spec/controllers/service_spec.rb ++++ b/spec/controllers/service_spec.rb +@@ -10,7 +10,7 @@ describe Service do + end + + before do +- Thin.stub!(:linux?).and_return(true) ++ allow(Thin).to receive(:linux?) { true } + FileUtils.mkdir_p 'tmp/sandbox' + + @service = Service.new(:all => 'spec/configs') +@@ -27,7 +27,7 @@ describe Service do + it "should create /etc/init.d/thin file when calling install" do + @service.install + +- File.exist?(Service::INITD_PATH).should be_true ++ File.exist?(Service::INITD_PATH).should be_truthy + script_name = File.directory?('/etc/rc.d') ? + '/etc/rc.d/thin' : '/etc/init.d/thin' + File.read(Service::INITD_PATH).should include('CONFIG_PATH=tmp/sandbox/etc/thin', +@@ -38,7 +38,7 @@ describe Service do + it "should create /etc/thin dir when calling install" do + @service.install + +- File.directory?(Service::DEFAULT_CONFIG_PATH).should be_true ++ File.directory?(Service::DEFAULT_CONFIG_PATH).should be_truthy + end + + it "should include specified path in /etc/init.d/thin script" do +@@ -50,4 +50,4 @@ describe Service do + after do + FileUtils.rm_rf 'tmp/sandbox' + end +-end +\ No newline at end of file ++end +diff --git a/spec/daemonizing_spec.rb b/spec/daemonizing_spec.rb +index 2458398..05f03fa 100644 +--- a/spec/daemonizing_spec.rb ++++ b/spec/daemonizing_spec.rb +@@ -42,7 +42,7 @@ describe 'Daemonizing' do + + sleep 1 + Process.wait(@pid) +- File.exist?(@server.pid_file).should be_true ++ File.exist?(@server.pid_file).should be_truthy + @pid = @server.pid + + proc { sleep 0.1 while File.exist?(@server.pid_file) }.should take_less_then(20) +@@ -77,7 +77,7 @@ describe 'Daemonizing' do + end + + it 'should kill process in pid file' do +- File.exist?(@server.pid_file).should be_false ++ File.exist?(@server.pid_file).should be_falsey + + @pid = fork do + @server.daemonize +@@ -94,7 +94,7 @@ describe 'Daemonizing' do + + Process.wait(@pid) + +- File.exist?(@server.pid_file).should be_false ++ File.exist?(@server.pid_file).should be_falsey + end + + it 'should force kill process in pid file' do +@@ -113,7 +113,7 @@ describe 'Daemonizing' do + + Process.wait(@pid) + +- File.exist?(@server.pid_file).should be_false ++ File.exist?(@server.pid_file).should be_falsey + end + + it 'should send kill signal if timeout' do +@@ -131,8 +131,8 @@ describe 'Daemonizing' do + + Process.wait(@pid) + +- File.exist?(@server.pid_file).should be_false +- Process.running?(@pid).should be_false ++ File.exist?(@server.pid_file).should be_falsey ++ Process.running?(@pid).should be_falsey + end + + it "should restart" do +@@ -174,7 +174,7 @@ describe 'Daemonizing' do + + proc { @server.daemonize }.should raise_error(PidFileExist) + +- File.exist?(@server.pid_file).should be_true ++ File.exist?(@server.pid_file).should be_truthy + end + + it "should raise if no pid file" do +@@ -189,7 +189,7 @@ describe 'Daemonizing' do + + @server.send(:remove_stale_pid_file) + +- File.exist?(@server.pid_file).should be_false ++ File.exist?(@server.pid_file).should be_falsey + end + + after do +diff --git a/spec/logging_spec.rb b/spec/logging_spec.rb +index 59699e4..9510c1f 100644 +--- a/spec/logging_spec.rb ++++ b/spec/logging_spec.rb +@@ -22,7 +22,7 @@ describe Logging do + describe "when setting a custom logger" do + + it "should not accept a logger object that is not sane" do +- expect { Logging.logger = "" }.to raise_error ++ expect { Logging.logger = "" }.to raise_error(ArgumentError) + end + + it "should accept a legit custom logger object" do +@@ -54,7 +54,7 @@ describe Logging do + + str = nil + expect { str = @readpipe.read_nonblock(512) }.to_not raise_error +- str.should_not be_nil ++ expect(str).not_to be_nil + end + + # +@@ -63,7 +63,9 @@ describe Logging do + Logging.debug = false + @object.log_debug("hiya") + +- expect { @readpipe.read_nonblock(512) }.to raise_error ++ expect do ++ @readpipe.read_nonblock(512) ++ end.to raise_error(IO::EAGAINWaitReadable) + end + + # +@@ -78,19 +80,25 @@ describe Logging do + it "should not log messages if silenced via module method" do + Logging.silent = true + @object.log_info("hola") +- expect { @readpipe.read_nonblock(512) }.to raise_error() ++ expect do ++ @readpipe.read_nonblock(512) ++ end.to raise_error(IO::EAGAINWaitReadable) + end + + it "should not log anything if silenced via module methods" do + Logging.silent = true + Logging.log_msg("hi") +- expect { @readpipe.read_nonblock(512) }.to raise_error() ++ expect do ++ @readpipe.read_nonblock(512) ++ end.to raise_error(IO::EAGAINWaitReadable) + end + + it "should not log anything if silenced via instance methods" do + @object.silent = true + @object.log_info("hello") +- expect { @readpipe.read_nonblock(512) }.to raise_error() ++ expect do ++ @readpipe.read_nonblock(512) ++ end.to raise_error(IO::EAGAINWaitReadable) + end + + end # Logging tests (with custom logger) +@@ -103,8 +111,8 @@ describe Logging do + @object.log_debug("Hey") + end + +- out.include?("Hey").should be_true +- out.include?("DEBUG").should be_true ++ out.include?("Hey").should be_truthy ++ out.include?("DEBUG").should be_truthy + end + + it "should be usable (at the module level) for logging" do +@@ -112,7 +120,7 @@ describe Logging do + Logging.log_msg("Hey") + end + +- out.include?("Hey").should be_true ++ out.include?("Hey").should be_truthy + end + + end +@@ -147,7 +155,7 @@ describe Logging do + @object.trace("Hey") + end + +- out.include?("Hey").should be_true ++ out.include?("Hey").should be_truthy + end + + it "should be usable (at the module level) for logging" do +@@ -156,7 +164,7 @@ describe Logging do + Logging.trace_msg("hey") + end + +- out.include?("hey").should be_true ++ out.include?("hey").should be_truthy + end + + end # tracer tests (no custom logger) +diff --git a/spec/request/processing_spec.rb b/spec/request/processing_spec.rb +index a915ba6..336bd05 100644 +--- a/spec/request/processing_spec.rb ++++ b/spec/request/processing_spec.rb +@@ -3,11 +3,11 @@ require 'spec_helper' + describe Request, 'processing' do + it 'should parse in chunks' do + request = Request.new +- request.parse("POST / HTTP/1.1\r\n").should be_false +- request.parse("Host: localhost\r\n").should be_false +- request.parse("Content-Length: 9\r\n").should be_false +- request.parse("\r\nvery ").should be_false +- request.parse("cool").should be_true ++ request.parse("POST / HTTP/1.1\r\n").should be_falsey ++ request.parse("Host: localhost\r\n").should be_falsey ++ request.parse("Content-Length: 9\r\n").should be_falsey ++ request.parse("\r\nvery ").should be_falsey ++ request.parse("cool").should be_truthy + + request.env['CONTENT_LENGTH'].should == '9' + request.body.read.should == 'very cool' +@@ -46,9 +46,9 @@ describe Request, 'processing' do + request.parse("Content-Length: #{body.size}\r\n\r\n") + request.parse(body) + +- request.body.closed?.should be_false ++ request.body.closed?.should be_falsey + request.close +- request.body.closed?.should be_true ++ request.body.closed?.should be_truthy + end + + it "should raise error when header is too big" do +diff --git a/spec/runner_spec.rb b/spec/runner_spec.rb +index cee6b91..1ff680f 100644 +--- a/spec/runner_spec.rb ++++ b/spec/runner_spec.rb +@@ -35,7 +35,7 @@ describe Runner do + it "should use Controller when controlling a single server" do + runner = Runner.new(%w(start)) + +- controller = mock('controller') ++ controller = double('controller') + controller.should_receive(:start) + Controllers::Controller.should_receive(:new).and_return(controller) + +@@ -45,7 +45,7 @@ describe Runner do + it "should use Cluster controller when controlling multiple servers" do + runner = Runner.new(%w(start --servers 3)) + +- controller = mock('cluster') ++ controller = double('cluster') + controller.should_receive(:start) + Controllers::Cluster.should_receive(:new).and_return(controller) + +@@ -86,16 +86,16 @@ describe Runner do + + it "should remember debug options" do + runner = Runner.new(%w(start -D -q -V)) +- runner.options[:debug].should be_true +- runner.options[:quiet].should be_true +- runner.options[:trace].should be_true ++ runner.options[:debug].should be_truthy ++ runner.options[:quiet].should be_truthy ++ runner.options[:trace].should be_truthy + end + + it "should default debug, silent and trace to false" do + runner = Runner.new(%w(start)) +- runner.options[:debug].should_not be_true +- runner.options[:quiet].should_not be_true +- runner.options[:trace].should_not be_true ++ runner.options[:debug].should_not be_truthy ++ runner.options[:quiet].should_not be_truthy ++ runner.options[:trace].should_not be_truthy + end + end + +@@ -125,7 +125,7 @@ describe Runner, 'with config file' do + it "should change directory after loading config" do + @orig_dir = Dir.pwd + +- controller = mock('controller') ++ controller = double('controller') + controller.should_receive(:respond_to?).with('start').and_return(true) + controller.should_receive(:start) + Controllers::Cluster.should_receive(:new).and_return(controller) +@@ -147,10 +147,10 @@ end + + describe Runner, "service" do + before do +- Thin.stub!(:linux?).and_return(true) ++ allow(Thin).to receive(:linux?) { true } + +- @controller = mock('service') +- Controllers::Service.stub!(:new).and_return(@controller) ++ @controller = double('service') ++ allow(Controllers::Service).to receive(:new) { @controller } + end + + it "should use Service controller when controlling all servers" do +@@ -172,7 +172,7 @@ describe Runner, "service" do + it "should call install without arguments" do + runner = Runner.new(%w(install)) + +- @controller.should_receive(:install).with() ++ @controller.should_receive(:install).with(no_args) + + runner.run! + end +diff --git a/spec/server/unix_socket_spec.rb b/spec/server/unix_socket_spec.rb +index a7287f3..ecc3d4a 100644 +--- a/spec/server/unix_socket_spec.rb ++++ b/spec/server/unix_socket_spec.rb +@@ -17,10 +17,10 @@ describe Server, "on UNIX domain socket" do + + it "should remove socket file after server stops" do + @server.stop! +- File.exist?('/tmp/thin_test.sock').should be_false ++ File.exist?('/tmp/thin_test.sock').should be_falsey + end + + after do + stop_server + end +-end +\ No newline at end of file ++end +diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb +index 398c3e5..5a29ea9 100644 +--- a/spec/spec_helper.rb ++++ b/spec/spec_helper.rb +@@ -253,7 +253,7 @@ module Helpers + end + end + +-Spec::Runner.configure do |config| ++RSpec.configure do |config| + config.include Matchers + config.include Helpers + end diff --git a/rubygem-thin.spec b/rubygem-thin.spec index c4d0c95..f94da54 100644 --- a/rubygem-thin.spec +++ b/rubygem-thin.spec @@ -2,7 +2,7 @@ Name: rubygem-%{gem_name} Version: 1.7.2 -Release: 14%{?dist} +Release: 15%{?dist} Summary: A thin and fast web server # lib/thin/stats.html.erb: BSD # spec/rails_app/public/javascripts/*.js: MIT @@ -19,13 +19,43 @@ Patch0: rubygem-thin-1.7.2-Mock-Kernel.warn-in-Ruby-2.5-compatible-way.patch # error caused probably by change of RLIMIT_NOFILE in Kernel or systemd. # https://github.com/macournoyer/thin/pull/360 Patch1: rubygem-thin-1.7.2-Fix-maximum_connections-limiting-test.patch +# The following *-daemonizing-test.patch for spec/daemonizing_spec.rb needs to apply +# the patches to support RSpec 3. +# Wait for child process +# https://github.com/macournoyer/thin/commit/6c5ba95f60d3d0d476595571ae2e54b28272cac0 +Patch2: rubygem-thin-1.7.2-Wait-for-child-process-daemonizing-test.patch +# Remove unused argument. +# https://github.com/macournoyer/thin/commit/f5229f3ae2ce084d0152787b12a59774ed67af8a +Patch3: rubygem-thin-1.7.2-Remove-unused-argument-daemonizing-test.patch +# Extend startup time. +# https://github.com/macournoyer/thin/commit/4e8d1c452acbbb90f2ba15b6c0f6f6537a6b7ea6 +Patch4: rubygem-thin-1.7.2-Extend-startup-time-daemonizing-test.patch +# Increase timeouts. +# https://github.com/macournoyer/thin/commit/90b8021d91aec69e424d7db5d543756fa45d50da +Patch5: rubygem-thin-1.7.2-Increase-timeouts-daemonizing-test.patch +# Don't wait for `daemon_test.log` to exist. +# https://github.com/macournoyer/thin/commit/c0e1266b3f51905d53643f8dcb018674530d19b4 +Patch6: rubygem-thin-1.7.2-dont-wait-for-daemon-daemonizing-test.patch +# Support RSpec 3 +# https://github.com/macournoyer/thin/commit/bfb2969392d8abf0444805740db38d8339125cab +Patch7: rubygem-thin-1.7.2-support-rspec3.patch +# Tidy up RSpec 3 migration. +# https://github.com/macournoyer/thin/commit/e97a71ab16570ba5604cdf35bfe736e218bab1b7 +Patch8: rubygem-thin-1.7.2-support-rspec3-tidy.patch +# Isolate daemonization specs fixing lib/thin/daemonizing.rb. +# https://github.com/macournoyer/thin/commit/8ac3b8e53072e504183ebd01e820d71e574d1a07 +Patch9: rubygem-thin-1.7.2-Isolate-daemonization-specs.patch +Patch10: rubygem-thin-1.7.2-Isolate-daemonization-specs-tests.patch +# Fix "undefined method `expect'" errors by removing the expect syntax "should". +# https://github.com/macournoyer/thin/commit/4e2c6f25685726f8c1e4d64ccca33f21bac10c05 +Patch11: rubygem-thin-1.7.2-fix-rspec3-undefined-method-expect.patch BuildRequires: ruby(release) BuildRequires: rubygems-devel BuildRequires: ruby-devel # Compiler is required for build of gem binary extension. # https://fedoraproject.org/wiki/Packaging:C_and_C++#BuildRequires_and_Requires BuildRequires: gcc -BuildRequires: rubygem(rspec2) +BuildRequires: rubygem(rspec) BuildRequires: rubygem(eventmachine) >= 1.0.4 BuildRequires: rubygem(daemons) >= 1.0.9 BuildRequires: rubygem(rack) >= 1.0.0 @@ -48,9 +78,19 @@ Documentation for %{name}. %prep %setup -q -n %{gem_name}-%{version} -b 1 +%patch9 -p1 pushd %{_builddir} %patch0 -p1 %patch1 -p1 +%patch2 -p1 +%patch3 -p1 +%patch4 -p1 +%patch5 -p1 +%patch6 -p1 +%patch7 -p1 +%patch8 -p1 +%patch10 -p1 +%patch11 -p1 popd %build @@ -90,25 +130,11 @@ pushd .%{gem_instdir} cp -a %{_builddir}/spec spec -# Depends on rubygem-benchmark_unit, not available in Fedora yet. -find spec/perf -name "*_spec.rb" -exec \ - sed -i '/be_faster_then/ i \ pending' {} \; - -# The 'should force kill process in pid file' spec is not compatible with RSpec2. -# https://github.com/rspec/rspec-core/issues/520 -sed -i -r "/'should (force )?kill process in pid file'/a \ pending" \ - spec/daemonizing_spec.rb - -# To prevent timeout error on ppc64 arch. -sed -i '/^ def server_should_start_in_less_then/,/^ end/ s/(10)/(20)/' \ +# To prevent timeout error on koji build. +sed -i '/^ def wait_for_server_to_start$/,/^ end$/ s/(10)/(30)/' \ spec/daemonizing_spec.rb -# These 2 tests are passing independently, but fails when running with the -# whole testsuite. -sed -i '/"tracing routines (with NO custom logger)"/a \ before { pending }' \ - spec/logging_spec.rb - -rspec2 -I$(dirs +1)%{gem_extdir_mri} spec +rspec -I$(dirs +1)%{gem_extdir_mri} spec popd @@ -129,6 +155,9 @@ popd %{gem_instdir}/Rakefile %changelog +* Tue Oct 27 2020 Jun Aruga - 1.7.2-15 +- Fix to run the tests on RSpec 3. + * Wed Jul 29 2020 Fedora Release Engineering - 1.7.2-14 - Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild