diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..c9ebcad --- /dev/null +++ b/Rakefile @@ -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 \ No newline at end of file diff --git a/mysqlplus.gemspec b/mysqlplus.gemspec index 8771f8e..9d8c492 100755 --- a/mysqlplus.gemspec +++ b/mysqlplus.gemspec @@ -12,9 +12,12 @@ Gem::Specification.new do |s| s.files = [ "mysqlplus.gemspec", "README", + "Rakefile", "lib/mysqlplus.rb", - "test/test_threaded.rb", - "test/test_evented.rb", + "test/test_helper.rb", + "test/threaded_test.rb", + "test/evented_test.rb", + "ext/error_const.h", "ext/extconf.rb", "ext/mysql.c" ] diff --git a/test/test_evented.rb b/test/evented_test.rb similarity index 80% rename from test/test_evented.rb rename to test/evented_test.rb index 3b4feea..83ddf14 100644 --- a/test/test_evented.rb +++ b/test/evented_test.rb @@ -1,10 +1,9 @@ -require 'mysqlplus' - +require File.dirname(__FILE__) + '/test_helper' @count = 10 @connections = {} @count.times do - c = Mysql.real_connect('localhost','root',nil) + c = Mysql.real_connect('localhost','root','3421260') @connections[IO.new(c.socket)] = c end @@ -28,4 +27,4 @@ loop do end end end -end +end \ No newline at end of file diff --git a/test/test_helper.rb b/test/test_helper.rb new file mode 100644 index 0000000..b257359 --- /dev/null +++ b/test/test_helper.rb @@ -0,0 +1,2 @@ +require 'rubygems' +require 'mysqlplus' \ No newline at end of file diff --git a/test/test_threaded.rb b/test/threaded_test.rb similarity index 73% rename from test/test_threaded.rb rename to test/threaded_test.rb index 91f72a9..3bc75c3 100644 --- a/test/test_threaded.rb +++ b/test/threaded_test.rb @@ -1,4 +1,4 @@ -require 'mysqlplus' +require File.dirname(__FILE__) + '/test_helper' $count = 10 @@ -6,7 +6,7 @@ $start = Time.now $connections = [] $count.times do - $connections << Mysql.real_connect('localhost','root') + $connections << Mysql.real_connect('localhost','root','3421260') end puts 'connection pool ready'