Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 227 lines (180 sloc) 7.082 kb
db045db @dhh Initial
dhh authored
1 require 'rubygems'
2 require 'rake'
3 require 'rake/testtask'
4 require 'rake/rdoctask'
5 require 'rake/packagetask'
6 require 'rake/gempackagetask'
39814fc @jeremy Merge branch 'ar-test-cleanup' of git://git.geeksomnia.com/rails
jeremy authored
7
8 require File.expand_path(File.dirname(__FILE__)) + "/test/config"
db045db @dhh Initial
dhh authored
9
f386676 @ssoroka Use the rails user when creating and dropping the database rather than f...
ssoroka authored
10 MYSQL_DB_USER = 'rails'
11
c10396b @packagethief When running multiple test tasks, don't abort early if one produces fail...
packagethief authored
12 def run_without_aborting(*tasks)
13 errors = []
14
15 tasks.each do |task|
16 begin
17 Rake::Task[task].invoke
18 rescue Exception
19 errors << task
20 end
21 end
22
23 abort "Errors running #{errors.join(', ')}" if errors.any?
24 end
db045db @dhh Initial
dhh authored
25
bfe85ae @jeremy Add explicit test task
jeremy authored
26 desc 'Run mysql, sqlite, and postgresql tests by default'
27 task :default => :test
db045db @dhh Initial
dhh authored
28
bfe85ae @jeremy Add explicit test task
jeremy authored
29 desc 'Run mysql, sqlite, and postgresql tests'
c10396b @packagethief When running multiple test tasks, don't abort early if one produces fail...
packagethief authored
30 task :test do
31 tasks = defined?(JRUBY_VERSION) ?
32 %w(test_jdbcmysql test_jdbcsqlite3 test_jdbcpostgresql) :
33 %w(test_mysql test_sqlite3 test_postgresql)
34 run_without_aborting(*tasks)
35 end
36
bbb3e5a @jeremy Unify test:isolated across components and run by default at toplevel
jeremy authored
37 namespace :test do
38 task :isolated do
39 tasks = defined?(JRUBY_VERSION) ?
40 %w(isolated_test_jdbcmysql isolated_test_jdbcsqlite3 isolated_test_jdbcpostgresql) :
41 %w(isolated_test_mysql isolated_test_sqlite3 isolated_test_postgresql)
42 run_without_aborting(*tasks)
43 end
c10396b @packagethief When running multiple test tasks, don't abort early if one produces fail...
packagethief authored
44 end
db045db @dhh Initial
dhh authored
45
25e5b0c @lifo Remove support for SQLite 2.
lifo authored
46 %w( mysql postgresql sqlite3 firebird db2 oracle sybase openbase frontbase jdbcmysql jdbcpostgresql jdbcsqlite3 jdbcderby jdbch2 jdbchsqldb ).each do |adapter|
04c7e82 @dhh Made ready for the release of 0.11.1
dhh authored
47 Rake::TestTask.new("test_#{adapter}") { |t|
fa5da8a @jeremy isolated_test task
jeremy authored
48 connection_path = "test/connections/#{adapter =~ /jdbc/ ? 'jdbc' : 'native'}_#{adapter}"
a722b48 @NZKoz Ensure copy table test runs for sqlite and sqlite3. [mislav] Cllosoes #8...
NZKoz authored
49 adapter_short = adapter == 'db2' ? adapter : adapter[/^[a-z]+/]
fa5da8a @jeremy isolated_test task
jeremy authored
50 t.libs << "test" << connection_path
029fc2f @NZKoz Sort test cases to make test runs deterministic
NZKoz authored
51 t.test_files=Dir.glob( "test/cases/**/*_test{,_#{adapter_short}}.rb" ).sort
04c7e82 @dhh Made ready for the release of 0.11.1
dhh authored
52 t.verbose = true
f46dc9b @tenderlove clear the rest of the warnings, run with warnings turned on [#4332 state...
tenderlove authored
53 t.warning = true
04c7e82 @dhh Made ready for the release of 0.11.1
dhh authored
54 }
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
55
fa5da8a @jeremy isolated_test task
jeremy authored
56 task "isolated_test_#{adapter}" do
57 connection_path = "test/connections/#{adapter =~ /jdbc/ ? 'jdbc' : 'native'}_#{adapter}"
58 adapter_short = adapter == 'db2' ? adapter : adapter[/^[a-z]+/]
59 puts [adapter, adapter_short, connection_path].inspect
60 ruby = File.join(*RbConfig::CONFIG.values_at('bindir', 'RUBY_INSTALL_NAME'))
61 Dir["test/cases/**/*_test{,_#{adapter_short}}.rb"].all? do |file|
62 system(ruby, "-Ilib:test:#{connection_path}", file)
63 end or raise "Failures"
64 end
65
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
66 namespace adapter do
67 task :test => "test_#{adapter}"
fa5da8a @jeremy isolated_test task
jeremy authored
68 task :isolated_test => "isolated_test_#{adapter}"
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
69 end
04c7e82 @dhh Made ready for the release of 0.11.1
dhh authored
70 end
336c2cb @dhh Added an Oracle adapter that works with the Oracle bindings by Yoshida (...
dhh authored
71
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
72 namespace :mysql do
73 desc 'Build the MySQL test databases'
74 task :build_databases do
d804153 @hugopeixoto MySQL: fix diacritic uniqueness test by setting the default character se...
hugopeixoto authored
75 %x( echo "create DATABASE activerecord_unittest DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci " | mysql --user=#{MYSQL_DB_USER})
76 %x( echo "create DATABASE activerecord_unittest2 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci " | mysql --user=#{MYSQL_DB_USER})
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
77 end
78
79 desc 'Drop the MySQL test databases'
80 task :drop_databases do
f386676 @ssoroka Use the rails user when creating and dropping the database rather than f...
ssoroka authored
81 %x( mysqladmin --user=#{MYSQL_DB_USER} -f drop activerecord_unittest )
82 %x( mysqladmin --user=#{MYSQL_DB_USER} -f drop activerecord_unittest2 )
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
83 end
f18463f Add tasks to create, drop and rebuild the MySQL and PostgreSQL test dat...
Marcel Molina authored
84
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
85 desc 'Rebuild the MySQL test databases'
86 task :rebuild_databases => [:drop_databases, :build_databases]
f18463f Add tasks to create, drop and rebuild the MySQL and PostgreSQL test dat...
Marcel Molina authored
87 end
88
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
89 task :build_mysql_databases => 'mysql:build_databases'
90 task :drop_mysql_databases => 'mysql:drop_databases'
5d3e724 @jeremy Add build/drop/rebuild tasks for SQL Server. Closes #9588 [lawrence]
jeremy authored
91 task :rebuild_mysql_databases => 'mysql:rebuild_databases'
f18463f Add tasks to create, drop and rebuild the MySQL and PostgreSQL test dat...
Marcel Molina authored
92
93
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
94 namespace :postgresql do
95 desc 'Build the PostgreSQL test databases'
96 task :build_databases do
76335c2 @jeremy Bump pg gem requirement to 0.8.0. Build psql db with UTF8 encoding.
jeremy authored
97 %x( createdb -E UTF8 activerecord_unittest )
98 %x( createdb -E UTF8 activerecord_unittest2 )
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
99 end
100
101 desc 'Drop the PostgreSQL test databases'
102 task :drop_databases do
921752c @NZKoz Remove reference to 'postgres' user in the connection and Rakefiles. Al...
NZKoz authored
103 %x( dropdb activerecord_unittest )
104 %x( dropdb activerecord_unittest2 )
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
105 end
106
107 desc 'Rebuild the PostgreSQL test databases'
108 task :rebuild_databases => [:drop_databases, :build_databases]
f18463f Add tasks to create, drop and rebuild the MySQL and PostgreSQL test dat...
Marcel Molina authored
109 end
110
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
111 task :build_postgresql_databases => 'postgresql:build_databases'
112 task :drop_postgresql_databases => 'postgresql:drop_databases'
5d3e724 @jeremy Add build/drop/rebuild tasks for SQL Server. Closes #9588 [lawrence]
jeremy authored
113 task :rebuild_postgresql_databases => 'postgresql:rebuild_databases'
10d458b @dhh Added a OCI8-based Oracle adapter that has been verified to work with Or...
dhh authored
114
b2c0ddf Add support for FrontBase (http://www.frontbase.com/) with a new adapter...
Marcel Molina authored
115
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
116 namespace :frontbase do
117 desc 'Build the FrontBase test databases'
118 task :build_databases => :rebuild_frontbase_databases
b2c0ddf Add support for FrontBase (http://www.frontbase.com/) with a new adapter...
Marcel Molina authored
119
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
120 desc 'Rebuild the FrontBase test databases'
121 task :rebuild_databases do
122 build_frontbase_database = Proc.new do |db_name, sql_definition_file|
123 %(
124 STOP DATABASE #{db_name};
125 DELETE DATABASE #{db_name};
126 CREATE DATABASE #{db_name};
b2c0ddf Add support for FrontBase (http://www.frontbase.com/) with a new adapter...
Marcel Molina authored
127
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
128 CONNECT TO #{db_name} AS SESSION_NAME USER _SYSTEM;
129 SET COMMIT FALSE;
b2c0ddf Add support for FrontBase (http://www.frontbase.com/) with a new adapter...
Marcel Molina authored
130
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
131 CREATE USER RAILS;
132 CREATE SCHEMA RAILS AUTHORIZATION RAILS;
133 COMMIT;
b2c0ddf Add support for FrontBase (http://www.frontbase.com/) with a new adapter...
Marcel Molina authored
134
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
135 SET SESSION AUTHORIZATION RAILS;
136 SCRIPT '#{sql_definition_file}';
b2c0ddf Add support for FrontBase (http://www.frontbase.com/) with a new adapter...
Marcel Molina authored
137
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
138 COMMIT;
139
140 DISCONNECT ALL;
141 )
142 end
39814fc @jeremy Merge branch 'ar-test-cleanup' of git://git.geeksomnia.com/rails
jeremy authored
143 create_activerecord_unittest = build_frontbase_database['activerecord_unittest', File.join(SCHEMA_ROOT, 'frontbase.sql')]
144 create_activerecord_unittest2 = build_frontbase_database['activerecord_unittest2', File.join(SCHEMA_ROOT, 'frontbase2.sql')]
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
145 execute_frontbase_sql = Proc.new do |sql|
146 system(<<-SHELL)
147 /Library/FrontBase/bin/sql92 <<-SQL
148 #{sql}
149 SQL
150 SHELL
151 end
152 execute_frontbase_sql[create_activerecord_unittest]
153 execute_frontbase_sql[create_activerecord_unittest2]
b2c0ddf Add support for FrontBase (http://www.frontbase.com/) with a new adapter...
Marcel Molina authored
154 end
155 end
156
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
157 task :build_frontbase_databases => 'frontbase:build_databases'
158 task :rebuild_frontbase_databases => 'frontbase:rebuild_databases'
159
160
db045db @dhh Initial
dhh authored
161 # Generate the RDoc documentation
162
163 Rake::RDocTask.new { |rdoc|
164 rdoc.rdoc_dir = 'doc'
165 rdoc.title = "Active Record -- Object-relation mapping put on rails"
0e37e66 @dhh Documentation fixes (closes #3838)
dhh authored
166 rdoc.options << '--line-numbers' << '--inline-source' << '-A cattr_accessor=object'
d8b67f7 @jeremy Generate rdoc with utf-8 charset. Closes #7188 [manfred, jferris]
jeremy authored
167 rdoc.options << '--charset' << 'utf-8'
a02d672 @jeremy Horo rdoc template
jeremy authored
168 rdoc.template = ENV['template'] ? "#{ENV['template']}.rb" : '../doc/template/horo'
db045db @dhh Initial
dhh authored
169 rdoc.rdoc_files.include('README', 'RUNNING_UNIT_TESTS', 'CHANGELOG')
170 rdoc.rdoc_files.include('lib/**/*.rb')
171 rdoc.rdoc_files.exclude('lib/active_record/vendor/*')
172 rdoc.rdoc_files.include('dev-utils/*.rb')
173 }
174
b921b5d @dhh Fixed association picture reference
dhh authored
175 # Enhance rdoc task to copy referenced images also
176 task :rdoc do
177 FileUtils.mkdir_p "doc/files/examples/"
178 FileUtils.copy "examples/associations.png", "doc/files/examples/associations.png"
179 end
180
db045db @dhh Initial
dhh authored
181
f430d6b @josh Make gemspecs the authoritative source instead of generating them from t...
josh authored
182 spec = eval(File.read('activerecord.gemspec'))
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
183
db045db @dhh Initial
dhh authored
184 Rake::GemPackageTask.new(spec) do |p|
185 p.gem_spec = spec
186 end
187
e0a2dab @dhh Added KLOC counter for AR and AP. Combined theyre at ~9KLOC
dhh authored
188 task :lines do
189 lines, codelines, total_lines, total_codelines = 0, 0, 0, 0
190
191 for file_name in FileList["lib/active_record/**/*.rb"]
192 next if file_name =~ /vendor/
193 f = File.open(file_name)
194
195 while line = f.gets
196 lines += 1
197 next if line =~ /^\s*$/
198 next if line =~ /^\s*#/
199 codelines += 1
200 end
201 puts "L: #{sprintf("%4d", lines)}, LOC #{sprintf("%4d", codelines)} | #{file_name}"
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
202
e0a2dab @dhh Added KLOC counter for AR and AP. Combined theyre at ~9KLOC
dhh authored
203 total_lines += lines
204 total_codelines += codelines
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
205
e0a2dab @dhh Added KLOC counter for AR and AP. Combined theyre at ~9KLOC
dhh authored
206 lines, codelines = 0, 0
207 end
208
209 puts "Total: Lines #{total_lines}, LOC #{total_codelines}"
210 end
211
db045db @dhh Initial
dhh authored
212
065cb2a @dhh Made ready for better release automation
dhh authored
213 # Publishing ------------------------------------------------------
db045db @dhh Initial
dhh authored
214
c1785f3 @jeremy Release using gemcutter gem:push tasks
jeremy authored
215 desc "Release to gemcutter"
459ecaf @jeremy Submarine the rake-gemcutter dep in Rakefiles
jeremy authored
216 task :release => :package do
217 require 'rake/gemcutter'
218 Rake::Gemcutter::Tasks.new(spec).define
219 Rake::Task['gem:push'].invoke
220 end
065cb2a @dhh Made ready for better release automation
dhh authored
221
222 desc "Publish the API documentation"
346d36b @jeremy Namespace the internal Rakefile tasks. Closes #8850 [drnic]
jeremy authored
223 task :pdoc => [:rdoc] do
dc9f53b @jeremy Selectively require rake sshpublisher so full gem isn't required
jeremy authored
224 require 'rake/contrib/sshpublisher'
231c2c5 @jeremy Update Rakefiles to connect to wrath as current user. Use ssh config to ...
jeremy authored
225 Rake::SshDirPublisher.new("wrath.rubyonrails.org", "public_html/ar", "doc").upload
db045db @dhh Initial
dhh authored
226 end
Something went wrong with that request. Please try again.