mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Revert "Merge pull request #14940 from arunagw/hbakhtiyor-test-db-namespaces-ar"
This reverts commitfe98596008
, reversing changes made toadd9560643
.
This commit is contained in:
parent
fe98596008
commit
b231825f3e
4 changed files with 102 additions and 114 deletions
|
@ -38,16 +38,15 @@ namespace :test do
|
|||
end
|
||||
end
|
||||
|
||||
desc 'Build MySQL and PostgreSQL test databases'
|
||||
namespace :db do
|
||||
task :create => ['mysql:db:build', 'postgresql:db:build']
|
||||
task :drop => ['mysql:db:drop', 'postgresql:db:drop']
|
||||
desc 'Build MySQL and PostgreSQL test databases'
|
||||
task create: ['mysql:build_databases', 'postgresql:build_databases']
|
||||
desc 'Drop MySQL and PostgreSQL test databases'
|
||||
task drop: ['mysql:drop_databases', 'postgresql:drop_databases']
|
||||
end
|
||||
|
||||
%w( mysql mysql2 postgresql sqlite3 sqlite3_mem firebird db2 oracle sybase openbase frontbase jdbcmysql jdbcpostgresql jdbcsqlite3 jdbcderby jdbch2 jdbchsqldb ).each do |adapter|
|
||||
namespace :test do
|
||||
namespace :db do
|
||||
Rake::TestTask.new(adapter) { |t|
|
||||
Rake::TestTask.new("test_#{adapter}") { |t|
|
||||
adapter_short = adapter == 'db2' ? adapter : adapter[/^[a-z0-9]+/]
|
||||
t.libs << 'test'
|
||||
t.test_files = (Dir.glob( "test/cases/**/*_test.rb" ).reject {
|
||||
|
@ -58,8 +57,7 @@ end
|
|||
t.verbose = true
|
||||
}
|
||||
|
||||
namespace :isolated do
|
||||
task adapter do
|
||||
task "isolated_test_#{adapter}" do
|
||||
adapter_short = adapter == 'db2' ? adapter : adapter[/^[a-z0-9]+/]
|
||||
puts [adapter, adapter_short].inspect
|
||||
(Dir["test/cases/**/*_test.rb"].reject {
|
||||
|
@ -68,9 +66,6 @@ end
|
|||
sh(Gem.ruby, '-w' ,"-Itest", file)
|
||||
end or raise "Failures"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
namespace adapter do
|
||||
task :test => "test_#{adapter}"
|
||||
|
@ -81,8 +76,8 @@ end
|
|||
end
|
||||
|
||||
# Make sure the adapter test evaluates the env setting task
|
||||
task "test_#{adapter}" => ["#{adapter}:env", "test:db:#{adapter}"]
|
||||
task "isolated_test_#{adapter}" => ["#{adapter}:env", "test:db:isolated:#{adapter}"]
|
||||
task "test_#{adapter}" => "#{adapter}:env"
|
||||
task "isolated_test_#{adapter}" => "#{adapter}:env"
|
||||
end
|
||||
|
||||
rule '.sqlite3' do |t|
|
||||
|
@ -95,70 +90,64 @@ task :test_sqlite3 => [
|
|||
]
|
||||
|
||||
namespace :mysql do
|
||||
namespace :db do
|
||||
desc 'Build the MySQL test databases'
|
||||
task :build do
|
||||
task :build_databases do
|
||||
config = ARTest.config['connections']['mysql']
|
||||
%x( mysql --user=#{config['arunit']['username']} -e "create DATABASE #{config['arunit']['database']} DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci ")
|
||||
%x( mysql --user=#{config['arunit2']['username']} -e "create DATABASE #{config['arunit2']['database']} DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci ")
|
||||
end
|
||||
|
||||
desc 'Drop the MySQL test databases'
|
||||
task :drop do
|
||||
task :drop_databases do
|
||||
config = ARTest.config['connections']['mysql']
|
||||
%x( mysqladmin --user=#{config['arunit']['username']} -f drop #{config['arunit']['database']} )
|
||||
%x( mysqladmin --user=#{config['arunit2']['username']} -f drop #{config['arunit2']['database']} )
|
||||
end
|
||||
|
||||
desc 'Rebuild the MySQL test databases'
|
||||
task :rebuild => [:drop, :build]
|
||||
end
|
||||
task :rebuild_databases => [:drop_databases, :build_databases]
|
||||
end
|
||||
|
||||
task :build_mysql_databases => 'mysql:db:build'
|
||||
task :drop_mysql_databases => 'mysql:db:drop'
|
||||
task :rebuild_mysql_databases => 'mysql:db:rebuild'
|
||||
task :build_mysql_databases => 'mysql:build_databases'
|
||||
task :drop_mysql_databases => 'mysql:drop_databases'
|
||||
task :rebuild_mysql_databases => 'mysql:rebuild_databases'
|
||||
|
||||
|
||||
namespace :postgresql do
|
||||
# notify about preparing hstore
|
||||
namespace :db do
|
||||
desc 'Build the PostgreSQL test databases'
|
||||
task :build do
|
||||
task :build_databases do
|
||||
config = ARTest.config['connections']['postgresql']
|
||||
%x( createdb -E UTF8 -T template0 #{config['arunit']['database']} )
|
||||
%x( createdb -E UTF8 -T template0 #{config['arunit2']['database']} )
|
||||
|
||||
# prepare hstore
|
||||
# notify about preparing hstore
|
||||
if %x( createdb --version ).strip.gsub(/(.*)(\d\.\d\.\d)$/, "\\2") < "9.1.0"
|
||||
puts "Please prepare hstore data type. See http://www.postgresql.org/docs/9.0/static/hstore.html"
|
||||
end
|
||||
end
|
||||
|
||||
desc 'Drop the PostgreSQL test databases'
|
||||
task :drop do
|
||||
task :drop_databases do
|
||||
config = ARTest.config['connections']['postgresql']
|
||||
%x( dropdb #{config['arunit']['database']} )
|
||||
%x( dropdb #{config['arunit2']['database']} )
|
||||
end
|
||||
|
||||
desc 'Rebuild the PostgreSQL test databases'
|
||||
task :rebuild => [:drop, :build]
|
||||
end
|
||||
task :rebuild_databases => [:drop_databases, :build_databases]
|
||||
end
|
||||
|
||||
task :build_postgresql_databases => 'postgresql:db:build'
|
||||
task :drop_postgresql_databases => 'postgresql:db:drop'
|
||||
task :rebuild_postgresql_databases => 'postgresql:db:rebuild'
|
||||
task :build_postgresql_databases => 'postgresql:build_databases'
|
||||
task :drop_postgresql_databases => 'postgresql:drop_databases'
|
||||
task :rebuild_postgresql_databases => 'postgresql:rebuild_databases'
|
||||
|
||||
|
||||
namespace :frontbase do
|
||||
namespace :db do
|
||||
desc 'Build the FrontBase test databases'
|
||||
task :build => :rebuild_frontbase_databases
|
||||
task :build_databases => :rebuild_frontbase_databases
|
||||
|
||||
desc 'Rebuild the FrontBase test databases'
|
||||
task :rebuild do
|
||||
task :rebuild_databases do
|
||||
build_frontbase_database = Proc.new do |db_name, sql_definition_file|
|
||||
%(
|
||||
STOP DATABASE #{db_name};
|
||||
|
@ -194,10 +183,9 @@ namespace :frontbase do
|
|||
execute_frontbase_sql[create_activerecord_unittest2]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
task :build_frontbase_databases => 'frontbase:db:build'
|
||||
task :rebuild_frontbase_databases => 'frontbase:db:rebuild'
|
||||
task :build_frontbase_databases => 'frontbase:build_databases'
|
||||
task :rebuild_frontbase_databases => 'frontbase:rebuild_databases'
|
||||
|
||||
spec = eval(File.read('activerecord.gemspec'))
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ class Build
|
|||
|
||||
def tasks
|
||||
if activerecord?
|
||||
['mysql:db:rebuild', "#{adapter}:#{'isolated_' if isolated?}test"]
|
||||
['mysql:rebuild_databases', "#{adapter}:#{'isolated_' if isolated?}test"]
|
||||
else
|
||||
["test#{':isolated' if isolated?}"]
|
||||
end
|
||||
|
|
|
@ -265,15 +265,15 @@ This is how you run the Active Record test suite only for SQLite3:
|
|||
|
||||
```bash
|
||||
$ cd activerecord
|
||||
$ bundle exec rake test:db:sqlite3
|
||||
$ bundle exec rake test_sqlite3
|
||||
```
|
||||
|
||||
You can now run the tests as you did for `sqlite3`. The tasks are respectively
|
||||
|
||||
```bash
|
||||
test:db:mysql
|
||||
test:db:mysql2
|
||||
test:db:postgresql
|
||||
test_mysql
|
||||
test_mysql2
|
||||
test_postgresql
|
||||
```
|
||||
|
||||
Finally,
|
||||
|
|
|
@ -249,7 +249,7 @@ and create the test databases:
|
|||
|
||||
```bash
|
||||
$ cd activerecord
|
||||
$ bundle exec rake mysql:db:build
|
||||
$ bundle exec rake mysql:build_databases
|
||||
```
|
||||
|
||||
PostgreSQL's authentication works differently. A simple way to set up the development environment for example is to run with your development account
|
||||
|
@ -267,7 +267,7 @@ and then create the test databases with
|
|||
|
||||
```bash
|
||||
$ cd activerecord
|
||||
$ bundle exec rake postgresql:db:build
|
||||
$ bundle exec rake postgresql:build_databases
|
||||
```
|
||||
|
||||
It is possible to build databases for both PostgreSQL and MySQL with
|
||||
|
|
Loading…
Reference in a new issue