Skip to content

HTTPS clone URL

Subversion checkout URL

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