blythedunham-ar_test_runner 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/Manifest +12 -0
- data/README.rdoc +77 -0
- data/Rakefile +39 -0
- data/ar_test_runner.gemspec +33 -0
- data/bin/ar_test_runner +21 -0
- data/gem_install.rb +92 -0
- data/init.rb +1 -0
- data/lib/ar_test_runner.rb +190 -0
- data/lib/ar_test_runner_includes.rb +17 -0
- data/tasks/ar_test_runner_tasks.rake +19 -0
- data/uninstall.rb +1 -0
- metadata +73 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Blythe Dunham snowgiraffe.com
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Manifest
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
= ArTestRunner
|
2
|
+
Run the ActiveRecord test suite with your gem/module/plugin loaded. Choose the ActiveRecord version and database.
|
3
|
+
|
4
|
+
== Install
|
5
|
+
Install as either a gem or a plugin.
|
6
|
+
=== Gem
|
7
|
+
gem sources -a http://gems.github.com
|
8
|
+
sudo gem install blythedunham-ar_test_runner
|
9
|
+
|
10
|
+
=== Plugin
|
11
|
+
script/plugin install git://github.com/blythedunham/ar_test_runner
|
12
|
+
|
13
|
+
== Run
|
14
|
+
Run either of these from the RAILS_ROOT of your application
|
15
|
+
|
16
|
+
=== ar_test_runner
|
17
|
+
|
18
|
+
Run all plugins and lib files against sqlite for app version
|
19
|
+
ar_test_runner DB=sqlite
|
20
|
+
|
21
|
+
Test 2.3.2 with <tt>rails_devs_for_data_integrity</tt> plugin loaded on mysql (default)
|
22
|
+
ar_test_runner PLUGIN=rails_devs_for_data_integrity AR_DIR=/Library/Ruby/Gems/1.8/gems/activerecord-2.3.2
|
23
|
+
|
24
|
+
If installed as a gem, the executable is copied to your bin. With a plugin, you should invoke the file directly
|
25
|
+
vendor/plugins/ar_test_runner/bin/ar_test_runner
|
26
|
+
|
27
|
+
=== Rake task
|
28
|
+
Run all plugins and lib files against sqlite for app version
|
29
|
+
rake test:activerecord:sqlite
|
30
|
+
|
31
|
+
Test 2.3.2 with <tt>rails_devs_for_data_integrity</tt> plugin loaded on mysql
|
32
|
+
rake test:activerecord:mysql PLUGIN=rails_devs_for_data_integrity AR_DIR=/Library/Ruby/Gems/1.8/gems/activerecord-2.3.2
|
33
|
+
|
34
|
+
With a plugin, rake tasks will automatically appear. If installed as a gem, please require 'ar_test_runner' in the Rakefile
|
35
|
+
require 'ar_test_runner'
|
36
|
+
|
37
|
+
=== Parameters
|
38
|
+
* <tt>AR_DIR</tt> - ActiveRecord directory. Works with frozen rails directories and gem locations. Defaults to the apps version of ActiveRecord
|
39
|
+
* <tt>PLUGIN</tt> - specify a plugin to use
|
40
|
+
* <tt>FILE</tt> - files to load separated with commas. Create a file that requires everything you need loaded for super detailed configurations. Relative and full paths are fine.
|
41
|
+
* <tt>REQUIRE</tt> - like FILE but does not expand the path. Use for gems and requiring file that are not relative to RAILS_ROOT</tt>.
|
42
|
+
* <tt>SKIP</tt> - list of directories or file names separated by commas to exclude.
|
43
|
+
* <tt>DRY_RUN</tt> - prints out list of files to loaded but does not run the tests
|
44
|
+
* <tt>AR_RUN_DEFAULT</tt> - set to true to include all files in the lib directory and plugins. These are run when <tt>REQUIRE</tt>,<tt>FILE</tt>, and <tt>PLUGIN</tt> is not specified
|
45
|
+
* <tt>DB</tt> - specify the db name (ex: +sqlite+ or +mysql+) with +DB+ when using this with +ar_test_runner+ ruby script. The database is specified in the task when run as a rake task. Example: <tt> rake test:activerecord:mysql</tt>
|
46
|
+
|
47
|
+
|
48
|
+
If <tt>REQUIRE</tt>,<tt>FILE</tt>, and <tt>PLUGIN</tt> are not specified, or <tt>AR_RUN_DEFAULT</tt> is set, all plugins(<tt>vendor/plugins/**/init.rb</tt>) and lib files(<tt>lib/*.rb</tt>) are loaded. Use <tt>SKIP</tt> to exclude directories. Plugins referencing <tt>ActionController</tt> are automatically disabled.
|
49
|
+
|
50
|
+
=== Examples
|
51
|
+
|
52
|
+
<b>Run default</b>
|
53
|
+
Run (plugins and libs) on postgre
|
54
|
+
rake activerecord:test:postgresql
|
55
|
+
|
56
|
+
<b>Skip</b>
|
57
|
+
Load everything in lib and all of the plugins but skip <tt>smsonrails</tt> using a frozen version of 2.2.2
|
58
|
+
rake test:activerecord:sqlite3 AR_DIR=/Users/blythedunham/projects/arversions/AR2.2.2/vendor/rails/activerecord SKIP=smsonrails
|
59
|
+
|
60
|
+
<b>Custom File </b>
|
61
|
+
If there are a lot of files to load, or for super custom requires, create a file and require everything there. Will use which ever version of <tt>ActiveRecord</tt> your app uses (loaded in <tt>config/boot.rb</tt>)
|
62
|
+
|
63
|
+
<tt>ar_requires.rb</tt>
|
64
|
+
might look like:
|
65
|
+
require File.dirname(__FILE__) + '../../models/awesome.rb'
|
66
|
+
require 'supergemthing'
|
67
|
+
|
68
|
+
Then run it:
|
69
|
+
rake activerecord:test:mysql FILES=config/ar_regression_requires.rb
|
70
|
+
|
71
|
+
== Developers
|
72
|
+
* Blythe Dunham http://snowgiraffe.com
|
73
|
+
|
74
|
+
== Homepage
|
75
|
+
* Project Site: http://github.com/blythedunham/ar_test_runner
|
76
|
+
|
77
|
+
Copyright (c) 2009 Blythe Dunham, released under the MIT license
|
data/Rakefile
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rake/rdoctask'
|
4
|
+
require 'echoe'
|
5
|
+
desc 'Default: run unit tests.'
|
6
|
+
task :default => :test
|
7
|
+
|
8
|
+
desc 'Test the ar_test_runner plugin.'
|
9
|
+
Rake::TestTask.new(:test) do |t|
|
10
|
+
t.libs << 'lib'
|
11
|
+
t.libs << 'test'
|
12
|
+
t.pattern = 'test/**/*_test.rb'
|
13
|
+
t.verbose = true
|
14
|
+
end
|
15
|
+
|
16
|
+
desc 'Generate documentation for the ar_regress_test plugin.'
|
17
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
18
|
+
rdoc.rdoc_dir = 'rdoc'
|
19
|
+
rdoc.title = 'ArTestRunner'
|
20
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
21
|
+
rdoc.rdoc_files.include('README')
|
22
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
23
|
+
end
|
24
|
+
|
25
|
+
desc "Install the application"
|
26
|
+
task :install do
|
27
|
+
ruby "gem_install.rb"
|
28
|
+
end
|
29
|
+
|
30
|
+
Echoe.new('ar_test_runner', '0.1.1') do |p|
|
31
|
+
p.description = "Run ActiveRecord core regression tests with your code/gem/plugin/module loaded"
|
32
|
+
p.url = "http://github.com/blythedunham/ar_test_runner"
|
33
|
+
p.author = "Blythe Dunham"
|
34
|
+
p.email = "blythe@snowgiraffe.com"
|
35
|
+
p.ignore_pattern = ["tmp/*", "script/*"]
|
36
|
+
p.development_dependencies = []
|
37
|
+
end
|
38
|
+
|
39
|
+
Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{ar_test_runner}
|
5
|
+
s.version = "0.1.1"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Blythe Dunham"]
|
9
|
+
s.date = %q{2009-05-15}
|
10
|
+
s.default_executable = %q{ar_test_runner}
|
11
|
+
s.description = %q{Run ActiveRecord core regression tests with your code/gem/plugin/module loaded}
|
12
|
+
s.email = %q{blythe@snowgiraffe.com}
|
13
|
+
s.executables = ["ar_test_runner"]
|
14
|
+
s.extra_rdoc_files = ["bin/ar_test_runner", "lib/ar_test_runner.rb", "lib/ar_test_runner_includes.rb", "README.rdoc", "tasks/ar_test_runner_tasks.rake"]
|
15
|
+
s.files = ["ar_test_runner.gemspec", "bin/ar_test_runner", "gem_install.rb", "init.rb", "lib/ar_test_runner.rb", "lib/ar_test_runner_includes.rb", "Manifest", "MIT-LICENSE", "Rakefile", "README.rdoc", "tasks/ar_test_runner_tasks.rake", "uninstall.rb"]
|
16
|
+
s.has_rdoc = true
|
17
|
+
s.homepage = %q{http://github.com/blythedunham/ar_test_runner}
|
18
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Ar_test_runner", "--main", "README.rdoc"]
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
s.rubyforge_project = %q{ar_test_runner}
|
21
|
+
s.rubygems_version = %q{1.3.1}
|
22
|
+
s.summary = %q{Run ActiveRecord core regression tests with your code/gem/plugin/module loaded}
|
23
|
+
|
24
|
+
if s.respond_to? :specification_version then
|
25
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
26
|
+
s.specification_version = 2
|
27
|
+
|
28
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
29
|
+
else
|
30
|
+
end
|
31
|
+
else
|
32
|
+
end
|
33
|
+
end
|
data/bin/ar_test_runner
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'config/boot'
|
3
|
+
ENV['AR_RUN_CMD'] = 'true'
|
4
|
+
begin
|
5
|
+
puts "SET ENV1"
|
6
|
+
require 'ar_test_runner'
|
7
|
+
rescue LoadError => exc
|
8
|
+
puts "SET ENV2"
|
9
|
+
file = File.dirname(__FILE__)+'/../lib/ar_test_runner.rb'
|
10
|
+
if File.exists?(file)
|
11
|
+
require file
|
12
|
+
else
|
13
|
+
puts "Cannot load ar_test_runner. Is the gem or plugin installed?"
|
14
|
+
exit
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
puts "SET ENV"
|
19
|
+
|
20
|
+
|
21
|
+
ArTestRunner.run!
|
data/gem_install.rb
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
puts "INSTALL RUNNING"
|
2
|
+
|
3
|
+
if false
|
4
|
+
require 'rbconfig'
|
5
|
+
require 'find'
|
6
|
+
require 'ftools'
|
7
|
+
|
8
|
+
include Config
|
9
|
+
|
10
|
+
$ruby = CONFIG['ruby_install_name']
|
11
|
+
|
12
|
+
##
|
13
|
+
# Install a binary file. We patch in on the way through to
|
14
|
+
# insert a #! line. If this is a Unix install, we name
|
15
|
+
# the command (for example) 'ar_test_runner' and let the shebang line
|
16
|
+
# handle running it. Under windows, we add a '.rb' extension
|
17
|
+
# and let file associations to their stuff
|
18
|
+
#
|
19
|
+
|
20
|
+
def installBIN(from, opfile)
|
21
|
+
|
22
|
+
tmp_dir = nil
|
23
|
+
for t in [".", "/tmp", "c:/temp", $bindir]
|
24
|
+
stat = File.stat(t) rescue next
|
25
|
+
if stat.directory? and stat.writable?
|
26
|
+
tmp_dir = t
|
27
|
+
break
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
fail "Cannot find a temporary directory" unless tmp_dir
|
32
|
+
tmp_file = File.join(tmp_dir, "_tmp")
|
33
|
+
|
34
|
+
File.open(from) do |ip|
|
35
|
+
File.open(tmp_file, "w") do |op|
|
36
|
+
ruby = File.join($realbindir, $ruby)
|
37
|
+
op.puts "#!#{ruby} -w"
|
38
|
+
op.write ip.read
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
opfile += ".rb" if CONFIG["target_os"] =~ /mswin/i
|
43
|
+
File::install(tmp_file, File.join($bindir, opfile), 0755, true)
|
44
|
+
File::unlink(tmp_file)
|
45
|
+
end
|
46
|
+
|
47
|
+
$sitedir = CONFIG["sitelibdir"]
|
48
|
+
unless $sitedir
|
49
|
+
version = CONFIG["MAJOR"]+"."+CONFIG["MINOR"]
|
50
|
+
$libdir = File.join(CONFIG["libdir"], "ruby", version)
|
51
|
+
$sitedir = $:.find {|x| x =~ /site_ruby/}
|
52
|
+
if !$sitedir
|
53
|
+
$sitedir = File.join($libdir, "site_ruby")
|
54
|
+
elsif $sitedir !~ Regexp.quote(version)
|
55
|
+
$sitedir = File.join($sitedir, version)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
$bindir = CONFIG["bindir"]
|
60
|
+
|
61
|
+
$realbindir = $bindir
|
62
|
+
|
63
|
+
bindir = CONFIG["bindir"]
|
64
|
+
if (destdir = ENV['DESTDIR'])
|
65
|
+
$bindir = destdir + $bindir
|
66
|
+
$sitedir = destdir + $sitedir
|
67
|
+
|
68
|
+
File::makedirs($bindir)
|
69
|
+
File::makedirs($sitedir)
|
70
|
+
end
|
71
|
+
|
72
|
+
ar_test_runner_dest = File.join($sitedir, "ar_test_runner")
|
73
|
+
File::makedirs(ar_test_runner_dest, true)
|
74
|
+
File::chmod(0755, ar_test_runner_dest)
|
75
|
+
|
76
|
+
# The library files
|
77
|
+
|
78
|
+
files = Dir.chdir('lib') { Dir['**/*.rb'] }
|
79
|
+
|
80
|
+
for fn in files
|
81
|
+
fn_dir = File.dirname(fn)
|
82
|
+
target_dir = File.join($sitedir, fn_dir)
|
83
|
+
if ! File.exist?(target_dir)
|
84
|
+
File.makedirs(target_dir)
|
85
|
+
end
|
86
|
+
File::install(File.join('lib', fn), File.join($sitedir, fn), 0644, true)
|
87
|
+
end
|
88
|
+
|
89
|
+
# and the executable
|
90
|
+
|
91
|
+
installBIN("bin/ar_test_runner", "ar_test_runner")
|
92
|
+
end
|
data/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Include hook code here
|
@@ -0,0 +1,190 @@
|
|
1
|
+
|
2
|
+
class ArTestRunner
|
3
|
+
|
4
|
+
attr_reader :auto_skip
|
5
|
+
|
6
|
+
unless defined? ADAPTERS
|
7
|
+
ADAPTERS = %w( mysql postgresql sqlite sqlite3 firebird db2 oracle sybase openbase frontbase jdbcmysql jdbcpostgresql jdbcsqlite3 jdbcderby jdbch2 jdbchsqldb )
|
8
|
+
REQUIRE_ALL_GLOB= %w(vendor/plugins/*/init.rb lib/*.rb)
|
9
|
+
DEFAULT_REQUIRES = [File.expand_path(File.join(File.dirname(__FILE__), 'ar_test_runner_includes.rb'))]
|
10
|
+
end
|
11
|
+
|
12
|
+
#run the whole thing
|
13
|
+
def self.run!
|
14
|
+
new.run
|
15
|
+
end
|
16
|
+
|
17
|
+
# Run the unit tests
|
18
|
+
def run
|
19
|
+
old_dir, old_env = Dir.pwd, ENV['RUBYOPT']
|
20
|
+
print_info
|
21
|
+
return true if ENV['DRY_RUN'] == 'true'
|
22
|
+
|
23
|
+
Dir.chdir( activerecord_dir )
|
24
|
+
ENV['RUBYOPT'] = required_files.collect{ |f| "-r#{f}" }.join(' ')#"-r rubygems -ractiverecord.rb -r#{init_file}"
|
25
|
+
load File.join( activerecord_dir, "Rakefile" )
|
26
|
+
Rake::Task[ "test_#{adapter}" ].invoke
|
27
|
+
Dir.chdir( old_dir )
|
28
|
+
ENV['RUBYOPT'] = old_env
|
29
|
+
end
|
30
|
+
|
31
|
+
#a list of files to require run running the ActiveRecord test suite
|
32
|
+
def required_files
|
33
|
+
return @required_files unless @required_files.nil?
|
34
|
+
@required_files = DEFAULT_REQUIRES.dup
|
35
|
+
@required_files.concat(requires)
|
36
|
+
@required_files.concat(plugins)
|
37
|
+
@required_files.concat(expanded_files)
|
38
|
+
@required_files.concat(default_app_files) if use_all_app_files?
|
39
|
+
skip_files!(@required_files)
|
40
|
+
@required_files
|
41
|
+
end
|
42
|
+
|
43
|
+
# the database adapter to use
|
44
|
+
def adapter
|
45
|
+
@adapter ||= begin
|
46
|
+
adpt = ENV['DB']||'mysql'
|
47
|
+
error_and_exit("Database type not supported #{@adapter}") unless ADAPTERS.include?(adpt)
|
48
|
+
adpt
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# The default activerecord directory used by the app (in LOADPATH)
|
53
|
+
def default_activerecord_dir
|
54
|
+
@default_activerecord_dir ||= if (activerecord_lib_dir = $LOAD_PATH.detect {|f| f =~ /activerecord/})
|
55
|
+
File.expand_path(File.dirname(activerecord_lib_dir))
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
# Get the activerecord from AR_DIR or default to app's LOADPATH
|
60
|
+
# ENV['AR_DIR'] should be set
|
61
|
+
def activerecord_dir
|
62
|
+
@activerecord_dir ||= begin
|
63
|
+
ar_dir = (ENV['AR_DIR']||= default_activerecord_dir)
|
64
|
+
error_and_exit "Pass in the path to ActiveRecord. Eg: AR_DIR=/Library/Ruby/Gems/1.8/gems/activerecord-2.3.2" if ar_dir.nil?
|
65
|
+
error_and_exit "Invalid ActiveRecord directory: #{ar_dir}" unless File.directory?(ar_dir)
|
66
|
+
ar_dir
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
# list of files to include absolute or relative to RAILS_ROOT
|
71
|
+
# an expression sent to Dir.glob is ok
|
72
|
+
# FILE=config/ar_test_runner_init.rb,model/*.rb
|
73
|
+
#
|
74
|
+
# Create a file like ar_test_runner_init.rb and include custom files
|
75
|
+
# require 'mygem'
|
76
|
+
# require '../../blah.rb'
|
77
|
+
def expanded_files
|
78
|
+
@expanded_files ||= split_file_names('FILE').inject([]) do |files, file|
|
79
|
+
files.concat Dir.glob(file)
|
80
|
+
files
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
# list of comma delimited plugins (relative to RAILS_ROOT) to include
|
85
|
+
# PLUGIN=smsonrails
|
86
|
+
def plugins
|
87
|
+
@plugins ||= split_file_names 'PLUGIN' do |p|
|
88
|
+
File.join('vendor/plugins', p, 'init.rb')
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
# list of strings to require. Similar to FILES but
|
93
|
+
# does not expand the path. Use with gems
|
94
|
+
# REQUIRE=mygem/gem, gemsuper
|
95
|
+
def requires
|
96
|
+
@requires ||= split_input 'REQUIRE'
|
97
|
+
end
|
98
|
+
# list of file names and dirs to skip over
|
99
|
+
def skipped_files
|
100
|
+
@skipped_files ||= split_input 'SKIP'
|
101
|
+
end
|
102
|
+
|
103
|
+
# Gather the default files
|
104
|
+
def default_app_files
|
105
|
+
@default_app_files ||= REQUIRE_ALL_GLOB.inject([]) do |list, files|
|
106
|
+
list.concat Dir.glob(files).collect{ |f| File.expand_path(f) }
|
107
|
+
list
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
# update orig_files to skip the files we want to exclude
|
112
|
+
# Note: this is not the best way. Loads this under the context of
|
113
|
+
# the activerecord version of the app
|
114
|
+
def skip_files!(orig_files)
|
115
|
+
return orig_files if skipped_files.empty? && !use_all_app_files?
|
116
|
+
|
117
|
+
#include activerecord
|
118
|
+
require File.join(activerecord_dir, 'lib', 'activerecord.rb')
|
119
|
+
|
120
|
+
#load each file now to see if it fails.
|
121
|
+
orig_files.collect! { |f| require_file?(f) ? f : nil }.compact!
|
122
|
+
end
|
123
|
+
|
124
|
+
def use_all_app_files?
|
125
|
+
if ENV['AR_RUN_DEFAULT'].nil?
|
126
|
+
ENV['AR_RUN_DEFAULT'] = (plugins.empty? && requires.empty? && expanded_files.empty?).to_s
|
127
|
+
end
|
128
|
+
ENV['AR_RUN_DEFAULT']
|
129
|
+
end
|
130
|
+
|
131
|
+
protected
|
132
|
+
|
133
|
+
# Return true if the file should be required.
|
134
|
+
# The file is not skipped and can be loaded (required now)
|
135
|
+
def require_file?(file_name)
|
136
|
+
return false if skip_file?(file_name)
|
137
|
+
require file_name unless skip_validation?
|
138
|
+
true
|
139
|
+
rescue NameError => exc
|
140
|
+
error_and_exit(exc.to_s) unless exc.to_s == 'uninitialized constant ActionController'
|
141
|
+
@auto_skip ||= []
|
142
|
+
@auto_skip << file_name
|
143
|
+
false
|
144
|
+
end
|
145
|
+
|
146
|
+
# Skip the file if it matches skipped_files (SKIP)
|
147
|
+
def skip_file?(file_name)
|
148
|
+
skipped_files.detect {|sf| file_name =~ Regexp.new("/#{sf}($|/)") }
|
149
|
+
end
|
150
|
+
|
151
|
+
def skip_validation?
|
152
|
+
ENV['SKIP_VALIDATION'] == 'true'
|
153
|
+
end
|
154
|
+
|
155
|
+
#splite the comma delimited input
|
156
|
+
def split_input(parameter, &block)
|
157
|
+
args = ENV[parameter] ? ENV[parameter].split(/,\s*/) : []
|
158
|
+
args.collect!{|a| yield a } if block
|
159
|
+
args
|
160
|
+
end
|
161
|
+
|
162
|
+
#split the comma delimited input into expanded file names
|
163
|
+
def split_file_names(parameter, &block)
|
164
|
+
split_input(parameter) do |f|
|
165
|
+
f = yield f if block
|
166
|
+
error_and_exit("File does not exist: #{f}") unless File.exists?(f)
|
167
|
+
File.expand_path f
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
# Print the error and exit
|
172
|
+
def error_and_exit(msg)
|
173
|
+
STDERR.puts "ERROR: #{msg}"
|
174
|
+
exit
|
175
|
+
end
|
176
|
+
|
177
|
+
def print_list(msg, file_list)
|
178
|
+
STDOUT.puts "#{msg}:\n #{ [file_list].flatten.join("\n ") }" unless file_list.nil? || file_list == ''
|
179
|
+
end
|
180
|
+
|
181
|
+
def print_info
|
182
|
+
print_list 'Adapter', adapter
|
183
|
+
print_list 'ActiveRecord Directory', activerecord_dir
|
184
|
+
print_list 'Loaded Files', required_files
|
185
|
+
print_list 'Skipped Files', skipped_files
|
186
|
+
print_list 'Automatically Skipped Files (references ActionController)', auto_skip
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
load "#{File.dirname(__FILE__)}/../tasks/ar_test_runner_tasks.rake" unless ENV['AR_RUN_CMD'] == 'true'
|
@@ -0,0 +1,17 @@
|
|
1
|
+
ar_dir_name = File.basename(ENV['AR_DIR'])
|
2
|
+
|
3
|
+
# If we are inside a gem, activesupport is located back a directory
|
4
|
+
# with the version name. Add this to the LOAD_PATH
|
5
|
+
# Example: ../activesupport-2.3.2
|
6
|
+
if (match = ar_dir_name.match(/activerecord-([\d\.]*)$/)) && match[1]
|
7
|
+
ext = match[1]
|
8
|
+
dirs = %w(active_support active_record).each do |f|
|
9
|
+
dir = f.gsub('_', '') + '-' + ext
|
10
|
+
$LOAD_PATH << File.join(ENV['AR_DIR'], '..', dir , 'lib')
|
11
|
+
file = File.join(ENV['AR_DIR'], '..', dir , 'lib', f)
|
12
|
+
#require file
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
#always require active_record
|
17
|
+
require 'active_record'
|
@@ -0,0 +1,19 @@
|
|
1
|
+
|
2
|
+
unless defined?(ArTestRunner)
|
3
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'ar_test_runner')
|
4
|
+
end
|
5
|
+
|
6
|
+
|
7
|
+
# define a rake task for each adapter
|
8
|
+
# rake test:activerecord:mysql
|
9
|
+
namespace :test do
|
10
|
+
namespace :activerecord do
|
11
|
+
ArTestRunner::ADAPTERS.each do |adapter|
|
12
|
+
desc "runs ActiveRecord regression unit tests for #{adapter}"
|
13
|
+
task adapter.to_sym do |t|
|
14
|
+
ENV['DB'] = adapter
|
15
|
+
ArTestRunner.run!
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/uninstall.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Uninstall hook code here
|
metadata
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: blythedunham-ar_test_runner
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Blythe Dunham
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-05-15 00:00:00 -07:00
|
13
|
+
default_executable: ar_test_runner
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Run ActiveRecord core regression tests with your code/gem/plugin/module loaded
|
17
|
+
email: blythe@snowgiraffe.com
|
18
|
+
executables:
|
19
|
+
- ar_test_runner
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- bin/ar_test_runner
|
24
|
+
- lib/ar_test_runner.rb
|
25
|
+
- lib/ar_test_runner_includes.rb
|
26
|
+
- README.rdoc
|
27
|
+
- tasks/ar_test_runner_tasks.rake
|
28
|
+
files:
|
29
|
+
- ar_test_runner.gemspec
|
30
|
+
- bin/ar_test_runner
|
31
|
+
- gem_install.rb
|
32
|
+
- init.rb
|
33
|
+
- lib/ar_test_runner.rb
|
34
|
+
- lib/ar_test_runner_includes.rb
|
35
|
+
- Manifest
|
36
|
+
- MIT-LICENSE
|
37
|
+
- Rakefile
|
38
|
+
- README.rdoc
|
39
|
+
- tasks/ar_test_runner_tasks.rake
|
40
|
+
- uninstall.rb
|
41
|
+
has_rdoc: true
|
42
|
+
homepage: http://github.com/blythedunham/ar_test_runner
|
43
|
+
post_install_message:
|
44
|
+
rdoc_options:
|
45
|
+
- --line-numbers
|
46
|
+
- --inline-source
|
47
|
+
- --title
|
48
|
+
- Ar_test_runner
|
49
|
+
- --main
|
50
|
+
- README.rdoc
|
51
|
+
require_paths:
|
52
|
+
- lib
|
53
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: "0"
|
58
|
+
version:
|
59
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: "1.2"
|
64
|
+
version:
|
65
|
+
requirements: []
|
66
|
+
|
67
|
+
rubyforge_project: ar_test_runner
|
68
|
+
rubygems_version: 1.2.0
|
69
|
+
signing_key:
|
70
|
+
specification_version: 2
|
71
|
+
summary: Run ActiveRecord core regression tests with your code/gem/plugin/module loaded
|
72
|
+
test_files: []
|
73
|
+
|