From 3b2e7602a0baaf8381a44b52a3858a570cb2cb5c Mon Sep 17 00:00:00 2001 From: Brian Lopez Date: Tue, 24 Aug 2010 09:27:29 -0700 Subject: [PATCH] formatting fix so I collapse in TM --- spec/mysql2/client_spec.rb | 46 ++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/spec/mysql2/client_spec.rb b/spec/mysql2/client_spec.rb index 936e1ea..cad599e 100644 --- a/spec/mysql2/client_spec.rb +++ b/spec/mysql2/client_spec.rb @@ -105,30 +105,32 @@ describe Mysql2::Client do # XXX this test is not deterministic (because Unix signal handling is not) # and may fail on a loaded system - it "should run signal handlers while waiting for a response" do - mark = {} - trap(:USR1) { mark[:USR1] = Time.now } - begin - mark[:START] = Time.now - pid = fork do - sleep 1 # wait for client "SELECT sleep(2)" query to start - Process.kill(:USR1, Process.ppid) - sleep # wait for explicit kill to prevent GC disconnect + if RUBY_PLATFORM !~ /mingw|mswin/ + it "should run signal handlers while waiting for a response" do + mark = {} + trap(:USR1) { mark[:USR1] = Time.now } + begin + mark[:START] = Time.now + pid = fork do + sleep 1 # wait for client "SELECT sleep(2)" query to start + Process.kill(:USR1, Process.ppid) + sleep # wait for explicit kill to prevent GC disconnect + end + @client.query("SELECT sleep(2)") + mark[:END] = Time.now + mark.include?(:USR1).should be_true + (mark[:USR1] - mark[:START]).should >= 1 + (mark[:USR1] - mark[:START]).should < 1.1 + (mark[:END] - mark[:USR1]).should > 0.9 + (mark[:END] - mark[:START]).should >= 2 + (mark[:END] - mark[:START]).should < 2.1 + Process.kill(:TERM, pid) + Process.waitpid2(pid) + ensure + trap(:USR1, 'DEFAULT') end - @client.query("SELECT sleep(2)") - mark[:END] = Time.now - mark.include?(:USR1).should be_true - (mark[:USR1] - mark[:START]).should >= 1 - (mark[:USR1] - mark[:START]).should < 1.1 - (mark[:END] - mark[:USR1]).should > 0.9 - (mark[:END] - mark[:START]).should >= 2 - (mark[:END] - mark[:START]).should < 2.1 - Process.kill(:TERM, pid) - Process.waitpid2(pid) - ensure - trap(:USR1, 'DEFAULT') end - end if RUBY_PLATFORM !~ /mingw|mswin/ + end end it "should respond to #escape" do