-
Notifications
You must be signed in to change notification settings - Fork 14
/
Rakefile
62 lines (49 loc) · 1.71 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
require "bundler/gem_tasks"
require 'rake/testtask'
require File.expand_path(File.dirname(__FILE__)) + "/test/config"
require File.expand_path(File.dirname(__FILE__)) + "/test/support/config"
desc 'Run mysql2 tests by default'
task :default => :test
desc 'Run mysql2 tests'
task :test => :test_mysql2
desc 'Build MySQL test databases'
namespace :db do
task :create => ['db:mysql:build']
task :drop => ['db:mysql:drop']
end
%w( mysql mysql2 ).each do |adapter|
namespace :test do
Rake::TestTask.new(adapter => "#{adapter}:env") { |t|
t.libs << 'test'
t.test_files = Dir.glob( "test/cases/**/*_test.rb" ).sort
t.warning = true
t.verbose = true
}
end
namespace adapter do
task :test => "test_#{adapter}"
# Set the connection environment for the adapter
task(:env) { ENV['ARCONN'] = adapter }
end
# Make sure the adapter test evaluates the env setting task
task "test_#{adapter}" => ["#{adapter}:env", "test:#{adapter}"]
end
namespace :db do
namespace :mysql do
desc 'Build the MySQL test databases'
task :build do
config = ARTest.config['connections']['mysql']
%x( mysql --user=#{config['arunit']['username']} -e "create DATABASE #{config['arunit']['database']} DEFAULT CHARACTER SET utf8" )
end
desc 'Drop the MySQL test databases'
task :drop do
config = ARTest.config['connections']['mysql']
%x( mysqladmin --user=#{config['arunit']['username']} -f drop #{config['arunit']['database']} )
end
desc 'Rebuild the MySQL test databases'
task :rebuild => [:drop, :build]
end
end
task :build_mysql_databases => 'db:mysql:build'
task :drop_mysql_databases => 'db:mysql:drop'
task :rebuild_mysql_databases => 'db:mysql:rebuild'