Experimental build && test tasks

This commit is contained in:
Lourens Naude 2008-09-05 18:23:47 +01:00
parent 02e8481161
commit 58d416e929
5 changed files with 64 additions and 8 deletions

52
Rakefile Normal file
View File

@ -0,0 +1,52 @@
require 'rake'
require 'rake/testtask'
desc 'Default: build and install.'
task :default => :build
desc 'Run performance tests.'
Rake::TestTask.new(:test) do |t|
t.libs = [] #reference the installed gem instead
t.pattern = 'test/*_test.rb'
t.verbose = true
end
task :build do |t|
configure
install
end
def configure
puts "** building gem"
puts %x{gem build mysqlplus.gemspec}
end
def install
puts "** installing gem"
_mysql_config = mysql_config
puts "** using mysql_config: #{_mysql_config}"
puts %x{sudo gem install mysqlplus-#{version}.gem -- --with-mysql-config=#{_mysql_config}}
end
def gem_spec
@gem_spec ||= eval( IO.read( 'mysqlplus.gemspec') )
end
def version
gem_spec.version.to_s
end
def mysql_configs
%w(mysql_config mysql_config5)
end
def mysql_config
mysql_configs.each do |config|
path = mysql_config!( config )
return path unless path.empty?
end
end
def mysql_config!( config )
%x{which #{config}}
end

View File

@ -12,9 +12,12 @@ Gem::Specification.new do |s|
s.files = [ s.files = [
"mysqlplus.gemspec", "mysqlplus.gemspec",
"README", "README",
"Rakefile",
"lib/mysqlplus.rb", "lib/mysqlplus.rb",
"test/test_threaded.rb", "test/test_helper.rb",
"test/test_evented.rb", "test/threaded_test.rb",
"test/evented_test.rb",
"ext/error_const.h",
"ext/extconf.rb", "ext/extconf.rb",
"ext/mysql.c" "ext/mysql.c"
] ]

View File

@ -1,10 +1,9 @@
require 'mysqlplus' require File.dirname(__FILE__) + '/test_helper'
@count = 10 @count = 10
@connections = {} @connections = {}
@count.times do @count.times do
c = Mysql.real_connect('localhost','root',nil) c = Mysql.real_connect('localhost','root','3421260')
@connections[IO.new(c.socket)] = c @connections[IO.new(c.socket)] = c
end end

2
test/test_helper.rb Normal file
View File

@ -0,0 +1,2 @@
require 'rubygems'
require 'mysqlplus'

View File

@ -1,4 +1,4 @@
require 'mysqlplus' require File.dirname(__FILE__) + '/test_helper'
$count = 10 $count = 10
@ -6,7 +6,7 @@ $start = Time.now
$connections = [] $connections = []
$count.times do $count.times do
$connections << Mysql.real_connect('localhost','root') $connections << Mysql.real_connect('localhost','root','3421260')
end end
puts 'connection pool ready' puts 'connection pool ready'