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
|
@ -38,38 +38,33 @@ namespace :test do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
desc 'Build MySQL and PostgreSQL test databases'
|
|
||||||
namespace :db do
|
namespace :db do
|
||||||
task :create => ['mysql:db:build', 'postgresql:db:build']
|
desc 'Build MySQL and PostgreSQL test databases'
|
||||||
task :drop => ['mysql:db:drop', 'postgresql:db:drop']
|
task create: ['mysql:build_databases', 'postgresql:build_databases']
|
||||||
|
desc 'Drop MySQL and PostgreSQL test databases'
|
||||||
|
task drop: ['mysql:drop_databases', 'postgresql:drop_databases']
|
||||||
end
|
end
|
||||||
|
|
||||||
%w( mysql mysql2 postgresql sqlite3 sqlite3_mem firebird db2 oracle sybase openbase frontbase jdbcmysql jdbcpostgresql jdbcsqlite3 jdbcderby jdbch2 jdbchsqldb ).each do |adapter|
|
%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
|
Rake::TestTask.new("test_#{adapter}") { |t|
|
||||||
namespace :db do
|
adapter_short = adapter == 'db2' ? adapter : adapter[/^[a-z0-9]+/]
|
||||||
Rake::TestTask.new(adapter) { |t|
|
t.libs << 'test'
|
||||||
adapter_short = adapter == 'db2' ? adapter : adapter[/^[a-z0-9]+/]
|
t.test_files = (Dir.glob( "test/cases/**/*_test.rb" ).reject {
|
||||||
t.libs << 'test'
|
|x| x =~ /\/adapters\//
|
||||||
t.test_files = (Dir.glob( "test/cases/**/*_test.rb" ).reject {
|
} + Dir.glob("test/cases/adapters/#{adapter_short}/**/*_test.rb")).sort
|
||||||
|x| x =~ /\/adapters\//
|
|
||||||
} + Dir.glob("test/cases/adapters/#{adapter_short}/**/*_test.rb")).sort
|
|
||||||
|
|
||||||
t.warning = true
|
t.warning = true
|
||||||
t.verbose = true
|
t.verbose = true
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace :isolated do
|
task "isolated_test_#{adapter}" do
|
||||||
task adapter do
|
adapter_short = adapter == 'db2' ? adapter : adapter[/^[a-z0-9]+/]
|
||||||
adapter_short = adapter == 'db2' ? adapter : adapter[/^[a-z0-9]+/]
|
puts [adapter, adapter_short].inspect
|
||||||
puts [adapter, adapter_short].inspect
|
(Dir["test/cases/**/*_test.rb"].reject {
|
||||||
(Dir["test/cases/**/*_test.rb"].reject {
|
|x| x =~ /\/adapters\//
|
||||||
|x| x =~ /\/adapters\//
|
} + Dir["test/cases/adapters/#{adapter_short}/**/*_test.rb"]).all? do |file|
|
||||||
} + Dir["test/cases/adapters/#{adapter_short}/**/*_test.rb"]).all? do |file|
|
sh(Gem.ruby, '-w' ,"-Itest", file)
|
||||||
sh(Gem.ruby, '-w' ,"-Itest", file)
|
end or raise "Failures"
|
||||||
end or raise "Failures"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
namespace adapter do
|
namespace adapter do
|
||||||
|
@ -81,8 +76,8 @@ end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Make sure the adapter test evaluates the env setting task
|
# Make sure the adapter test evaluates the env setting task
|
||||||
task "test_#{adapter}" => ["#{adapter}:env", "test:db:#{adapter}"]
|
task "test_#{adapter}" => "#{adapter}:env"
|
||||||
task "isolated_test_#{adapter}" => ["#{adapter}:env", "test:db:isolated:#{adapter}"]
|
task "isolated_test_#{adapter}" => "#{adapter}:env"
|
||||||
end
|
end
|
||||||
|
|
||||||
rule '.sqlite3' do |t|
|
rule '.sqlite3' do |t|
|
||||||
|
@ -95,109 +90,102 @@ task :test_sqlite3 => [
|
||||||
]
|
]
|
||||||
|
|
||||||
namespace :mysql do
|
namespace :mysql do
|
||||||
namespace :db do
|
desc 'Build the MySQL test databases'
|
||||||
desc 'Build the MySQL test databases'
|
task :build_databases do
|
||||||
task :build do
|
config = ARTest.config['connections']['mysql']
|
||||||
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['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 ")
|
||||||
%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
|
|
||||||
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
|
end
|
||||||
|
|
||||||
|
desc 'Drop the MySQL test databases'
|
||||||
|
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_databases => [:drop_databases, :build_databases]
|
||||||
end
|
end
|
||||||
|
|
||||||
task :build_mysql_databases => 'mysql:db:build'
|
task :build_mysql_databases => 'mysql:build_databases'
|
||||||
task :drop_mysql_databases => 'mysql:db:drop'
|
task :drop_mysql_databases => 'mysql:drop_databases'
|
||||||
task :rebuild_mysql_databases => 'mysql:db:rebuild'
|
task :rebuild_mysql_databases => 'mysql:rebuild_databases'
|
||||||
|
|
||||||
|
|
||||||
namespace :postgresql do
|
namespace :postgresql do
|
||||||
|
desc 'Build the PostgreSQL test databases'
|
||||||
|
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']} )
|
||||||
|
|
||||||
# notify about preparing hstore
|
# notify about preparing hstore
|
||||||
namespace :db do
|
if %x( createdb --version ).strip.gsub(/(.*)(\d\.\d\.\d)$/, "\\2") < "9.1.0"
|
||||||
desc 'Build the PostgreSQL test databases'
|
puts "Please prepare hstore data type. See http://www.postgresql.org/docs/9.0/static/hstore.html"
|
||||||
task :build 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
|
|
||||||
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
|
end
|
||||||
|
|
||||||
desc 'Drop the PostgreSQL test databases'
|
|
||||||
task :drop 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
|
end
|
||||||
|
|
||||||
|
desc 'Drop the PostgreSQL test databases'
|
||||||
|
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_databases => [:drop_databases, :build_databases]
|
||||||
end
|
end
|
||||||
|
|
||||||
task :build_postgresql_databases => 'postgresql:db:build'
|
task :build_postgresql_databases => 'postgresql:build_databases'
|
||||||
task :drop_postgresql_databases => 'postgresql:db:drop'
|
task :drop_postgresql_databases => 'postgresql:drop_databases'
|
||||||
task :rebuild_postgresql_databases => 'postgresql:db:rebuild'
|
task :rebuild_postgresql_databases => 'postgresql:rebuild_databases'
|
||||||
|
|
||||||
|
|
||||||
namespace :frontbase do
|
namespace :frontbase do
|
||||||
namespace :db do
|
desc 'Build the FrontBase test databases'
|
||||||
desc 'Build the FrontBase test databases'
|
task :build_databases => :rebuild_frontbase_databases
|
||||||
task :build => :rebuild_frontbase_databases
|
|
||||||
|
|
||||||
desc 'Rebuild the FrontBase test 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|
|
build_frontbase_database = Proc.new do |db_name, sql_definition_file|
|
||||||
%(
|
%(
|
||||||
STOP DATABASE #{db_name};
|
STOP DATABASE #{db_name};
|
||||||
DELETE DATABASE #{db_name};
|
DELETE DATABASE #{db_name};
|
||||||
CREATE DATABASE #{db_name};
|
CREATE DATABASE #{db_name};
|
||||||
|
|
||||||
CONNECT TO #{db_name} AS SESSION_NAME USER _SYSTEM;
|
CONNECT TO #{db_name} AS SESSION_NAME USER _SYSTEM;
|
||||||
SET COMMIT FALSE;
|
SET COMMIT FALSE;
|
||||||
|
|
||||||
CREATE USER RAILS;
|
CREATE USER RAILS;
|
||||||
CREATE SCHEMA RAILS AUTHORIZATION RAILS;
|
CREATE SCHEMA RAILS AUTHORIZATION RAILS;
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|
||||||
SET SESSION AUTHORIZATION RAILS;
|
SET SESSION AUTHORIZATION RAILS;
|
||||||
SCRIPT '#{sql_definition_file}';
|
SCRIPT '#{sql_definition_file}';
|
||||||
|
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|
||||||
DISCONNECT ALL;
|
DISCONNECT ALL;
|
||||||
)
|
)
|
||||||
end
|
|
||||||
config = ARTest.config['connections']['frontbase']
|
|
||||||
create_activerecord_unittest = build_frontbase_database[config['arunit']['database'], File.join(SCHEMA_ROOT, 'frontbase.sql')]
|
|
||||||
create_activerecord_unittest2 = build_frontbase_database[config['arunit2']['database'], File.join(SCHEMA_ROOT, 'frontbase2.sql')]
|
|
||||||
execute_frontbase_sql = Proc.new do |sql|
|
|
||||||
system(<<-SHELL)
|
|
||||||
/Library/FrontBase/bin/sql92 <<-SQL
|
|
||||||
#{sql}
|
|
||||||
SQL
|
|
||||||
SHELL
|
|
||||||
end
|
|
||||||
execute_frontbase_sql[create_activerecord_unittest]
|
|
||||||
execute_frontbase_sql[create_activerecord_unittest2]
|
|
||||||
end
|
end
|
||||||
|
config = ARTest.config['connections']['frontbase']
|
||||||
|
create_activerecord_unittest = build_frontbase_database[config['arunit']['database'], File.join(SCHEMA_ROOT, 'frontbase.sql')]
|
||||||
|
create_activerecord_unittest2 = build_frontbase_database[config['arunit2']['database'], File.join(SCHEMA_ROOT, 'frontbase2.sql')]
|
||||||
|
execute_frontbase_sql = Proc.new do |sql|
|
||||||
|
system(<<-SHELL)
|
||||||
|
/Library/FrontBase/bin/sql92 <<-SQL
|
||||||
|
#{sql}
|
||||||
|
SQL
|
||||||
|
SHELL
|
||||||
|
end
|
||||||
|
execute_frontbase_sql[create_activerecord_unittest]
|
||||||
|
execute_frontbase_sql[create_activerecord_unittest2]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
task :build_frontbase_databases => 'frontbase:db:build'
|
task :build_frontbase_databases => 'frontbase:build_databases'
|
||||||
task :rebuild_frontbase_databases => 'frontbase:db:rebuild'
|
task :rebuild_frontbase_databases => 'frontbase:rebuild_databases'
|
||||||
|
|
||||||
spec = eval(File.read('activerecord.gemspec'))
|
spec = eval(File.read('activerecord.gemspec'))
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ class Build
|
||||||
|
|
||||||
def tasks
|
def tasks
|
||||||
if activerecord?
|
if activerecord?
|
||||||
['mysql:db:rebuild', "#{adapter}:#{'isolated_' if isolated?}test"]
|
['mysql:rebuild_databases', "#{adapter}:#{'isolated_' if isolated?}test"]
|
||||||
else
|
else
|
||||||
["test#{':isolated' if isolated?}"]
|
["test#{':isolated' if isolated?}"]
|
||||||
end
|
end
|
||||||
|
|
|
@ -265,15 +265,15 @@ This is how you run the Active Record test suite only for SQLite3:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ cd activerecord
|
$ 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
|
You can now run the tests as you did for `sqlite3`. The tasks are respectively
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
test:db:mysql
|
test_mysql
|
||||||
test:db:mysql2
|
test_mysql2
|
||||||
test:db:postgresql
|
test_postgresql
|
||||||
```
|
```
|
||||||
|
|
||||||
Finally,
|
Finally,
|
||||||
|
|
|
@ -249,7 +249,7 @@ and create the test databases:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ cd activerecord
|
$ 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
|
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
|
```bash
|
||||||
$ cd activerecord
|
$ 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
|
It is possible to build databases for both PostgreSQL and MySQL with
|
||||||
|
|
Loading…
Reference in New Issue