oldmoe / mysqlplus

An enhanced mysql driver with an async interface and threaded access support

This URL has Read+Write access

mysqlplus / test / connect_failure2_test.rb
100644 23 lines (20 sloc) 0.572 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# If this script returns without the word pass
# you may have compiled mysqlplus using ruby and
# run it using a different version of ruby
 
if RUBY_VERSION >= "1.9.1"
 require 'mysqlplus'
 require 'socket'
 require 'timeout'
 TCPServer.new '0.0.0.0', 8002
 Thread.new {
  sleep 2
  print "pass"
  system("kill -9 #{Process.pid}")
 }
 Timeout::timeout(1) {
  # uncomment this line to do the 'real' test
  # which hangs otherwise (blows up if code is bad, otherwise hangs)
  Mysql.real_connect '127.0.0.1', 'root', 'pass', 'db', 8002
 }
 raise 'should never get here'
end