Skip to content

Commit c7725e6

Browse files
committed
pending, not skip
1 parent a94eac1 commit c7725e6

File tree

3 files changed

+252
-254
lines changed

3 files changed

+252
-254
lines changed

spec/mysql2/client_spec.rb

Lines changed: 64 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,20 @@
2727
}.to raise_error(Mysql2::Error)
2828
end
2929

30-
if defined? Encoding
31-
it "should raise an exception on create for invalid encodings" do
32-
expect {
33-
Mysql2::Client.new(DatabaseCredentials['root'].merge(:encoding => "fake"))
34-
}.to raise_error(Mysql2::Error)
35-
end
30+
it "should raise an exception on create for invalid encodings" do
31+
expect {
32+
Mysql2::Client.new(DatabaseCredentials['root'].merge(:encoding => "fake"))
33+
}.to raise_error(Mysql2::Error)
34+
end
3635

37-
it "should not raise an exception on create for a valid encoding" do
38-
expect {
39-
Mysql2::Client.new(DatabaseCredentials['root'].merge(:encoding => "utf8"))
40-
}.not_to raise_error
36+
it "should not raise an exception on create for a valid encoding" do
37+
expect {
38+
Mysql2::Client.new(DatabaseCredentials['root'].merge(:encoding => "utf8"))
39+
}.not_to raise_error
4140

42-
expect {
43-
Mysql2::Client.new(DatabaseCredentials['root'].merge(:encoding => "big5"))
44-
}.not_to raise_error
45-
end
41+
expect {
42+
Mysql2::Client.new(DatabaseCredentials['root'].merge(:encoding => "big5"))
43+
}.not_to raise_error
4644
end
4745

4846
it "should accept connect flags and pass them to #connect" do
@@ -119,9 +117,9 @@ def connect *args
119117
it "should be able to connect via SSL options" do
120118
ssl = @client.query "SHOW VARIABLES LIKE 'have_ssl'"
121119
ssl_uncompiled = ssl.any? {|x| x['Value'] == 'OFF'}
122-
skip("DON'T WORRY, THIS TEST PASSES - but SSL is not compiled into your MySQL daemon.") if ssl_uncompiled
120+
pending("DON'T WORRY, THIS TEST PASSES - but SSL is not compiled into your MySQL daemon.") if ssl_uncompiled
123121
ssl_disabled = ssl.any? {|x| x['Value'] == 'DISABLED'}
124-
skip("DON'T WORRY, THIS TEST PASSES - but SSL is not enabled in your MySQL daemon.") if ssl_disabled
122+
pending("DON'T WORRY, THIS TEST PASSES - but SSL is not enabled in your MySQL daemon.") if ssl_disabled
125123

126124
# You may need to adjust the lines below to match your SSL certificate paths
127125
ssl_client = nil
@@ -150,13 +148,15 @@ def connect *args
150148
end
151149

152150
def run_gc
153-
GC.start
154-
sleep(1) if defined?(Rubinius) # Let the Rubinius GC thread do its work
151+
if defined?(Rubinius)
152+
GC.run(true)
153+
else
154+
GC.start
155+
end
156+
sleep(0.5)
155157
end
156158

157159
it "should not leave dangling connections after garbage collection" do
158-
skip('Rubinius misbehaves') if defined?(Rubinius)
159-
160160
run_gc
161161

162162
client = Mysql2::Client.new(DatabaseCredentials['root'])
@@ -173,23 +173,22 @@ def run_gc
173173
expect(final_count).to eq(before_count)
174174
end
175175

176-
if Process.respond_to?(:fork)
177-
it "should not close connections when running in a child process" do
178-
run_gc
179-
client = Mysql2::Client.new(DatabaseCredentials['root'])
180176

181-
fork do
182-
client.query('SELECT 1')
183-
client = nil
184-
run_gc
185-
end
186-
187-
Process.wait
177+
it "should not close connections when running in a child process" do
178+
run_gc
179+
client = Mysql2::Client.new(DatabaseCredentials['root'])
188180

189-
# this will throw an error if the underlying socket was shutdown by the
190-
# child's GC
191-
expect { client.query('SELECT 1') }.to_not raise_exception
181+
fork do
182+
client.query('SELECT 1')
183+
client = nil
184+
run_gc
192185
end
186+
187+
Process.wait
188+
189+
# this will throw an error if the underlying socket was shutdown by the
190+
# child's GC
191+
expect { client.query('SELECT 1') }.to_not raise_exception
193192
end
194193

195194
it "should be able to connect to database with numeric-only name" do
@@ -272,7 +271,7 @@ def run_gc
272271
@client_i = Mysql2::Client.new DatabaseCredentials['root'].merge(:local_infile => true)
273272
local = @client_i.query "SHOW VARIABLES LIKE 'local_infile'"
274273
local_enabled = local.any? {|x| x['Value'] == 'ON'}
275-
skip("DON'T WORRY, THIS TEST PASSES - but LOCAL INFILE is not enabled in your MySQL daemon.") unless local_enabled
274+
pending("DON'T WORRY, THIS TEST PASSES - but LOCAL INFILE is not enabled in your MySQL daemon.") unless local_enabled
276275

277276
@client_i.query %[
278277
CREATE TABLE IF NOT EXISTS infileTest (
@@ -418,7 +417,6 @@ def run_gc
418417
# XXX this test is not deterministic (because Unix signal handling is not)
419418
# and may fail on a loaded system
420419
it "should run signal handlers while waiting for a response" do
421-
skip('Rubinius misbehaves') if defined?(Rubinius)
422420
mark = {}
423421
trap(:USR1) { mark[:USR1] = Time.now }
424422
begin
@@ -703,25 +701,25 @@ def run_gc
703701
expect(info[:version].class).to eql(String)
704702
end
705703

706-
if defined? Encoding
707-
context "strings returned by #info" do
708-
it "should default to the connection's encoding if Encoding.default_internal is nil" do
709-
with_internal_encoding nil do
710-
expect(@client.info[:version].encoding).to eql(Encoding.find('utf-8'))
704+
context "strings returned by #info" do
705+
before { pending('Encoding is undefined') unless defined?(Encoding) }
711706

712-
client2 = Mysql2::Client.new(DatabaseCredentials['root'].merge(:encoding => 'ascii'))
713-
expect(client2.info[:version].encoding).to eql(Encoding.find('us-ascii'))
714-
end
707+
it "should default to the connection's encoding if Encoding.default_internal is nil" do
708+
with_internal_encoding nil do
709+
expect(@client.info[:version].encoding).to eql(Encoding.find('utf-8'))
710+
711+
client2 = Mysql2::Client.new(DatabaseCredentials['root'].merge(:encoding => 'ascii'))
712+
expect(client2.info[:version].encoding).to eql(Encoding.find('us-ascii'))
715713
end
714+
end
716715

717-
it "should use Encoding.default_internal" do
718-
with_internal_encoding 'utf-8' do
719-
expect(@client.info[:version].encoding).to eql(Encoding.default_internal)
720-
end
716+
it "should use Encoding.default_internal" do
717+
with_internal_encoding 'utf-8' do
718+
expect(@client.info[:version].encoding).to eql(Encoding.default_internal)
719+
end
721720

722-
with_internal_encoding 'us-ascii' do
723-
expect(@client.info[:version].encoding).to eql(Encoding.default_internal)
724-
end
721+
with_internal_encoding 'us-ascii' do
722+
expect(@client.info[:version].encoding).to eql(Encoding.default_internal)
725723
end
726724
end
727725
end
@@ -746,25 +744,25 @@ def run_gc
746744
}.to raise_error(Mysql2::Error)
747745
end
748746

749-
if defined? Encoding
750-
context "strings returned by #server_info" do
751-
it "should default to the connection's encoding if Encoding.default_internal is nil" do
752-
with_internal_encoding nil do
753-
expect(@client.server_info[:version].encoding).to eql(Encoding.find('utf-8'))
747+
context "strings returned by #server_info" do
748+
before { pending('Encoding is undefined') unless defined?(Encoding) }
754749

755-
client2 = Mysql2::Client.new(DatabaseCredentials['root'].merge(:encoding => 'ascii'))
756-
expect(client2.server_info[:version].encoding).to eql(Encoding.find('us-ascii'))
757-
end
750+
it "should default to the connection's encoding if Encoding.default_internal is nil" do
751+
with_internal_encoding nil do
752+
expect(@client.server_info[:version].encoding).to eql(Encoding.find('utf-8'))
753+
754+
client2 = Mysql2::Client.new(DatabaseCredentials['root'].merge(:encoding => 'ascii'))
755+
expect(client2.server_info[:version].encoding).to eql(Encoding.find('us-ascii'))
758756
end
757+
end
759758

760-
it "should use Encoding.default_internal" do
761-
with_internal_encoding 'utf-8' do
762-
expect(@client.server_info[:version].encoding).to eql(Encoding.default_internal)
763-
end
759+
it "should use Encoding.default_internal" do
760+
with_internal_encoding 'utf-8' do
761+
expect(@client.server_info[:version].encoding).to eql(Encoding.default_internal)
762+
end
764763

765-
with_internal_encoding 'us-ascii' do
766-
expect(@client.server_info[:version].encoding).to eql(Encoding.default_internal)
767-
end
764+
with_internal_encoding 'us-ascii' do
765+
expect(@client.server_info[:version].encoding).to eql(Encoding.default_internal)
768766
end
769767
end
770768
end

0 commit comments

Comments
 (0)