diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-09-03 15:13:06 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-09-03 15:13:06 +0000 |
commit | bc011df210e9cb56e1c4f2cc61dce002861201ef (patch) | |
tree | 085b6cf1de972663c84233e9296ccb1d780a97f1 /railties/lib/tasks/testing.rake | |
parent | 9bbb195c038e2c4967daaed5efb192ce51e58103 (diff) | |
download | rails-bc011df210e9cb56e1c4f2cc61dce002861201ef.tar.gz rails-bc011df210e9cb56e1c4f2cc61dce002861201ef.tar.bz2 rails-bc011df210e9cb56e1c4f2cc61dce002861201ef.zip |
Moved all the shared tasks from Rakefile into Rails, so that the Rakefile is empty and doesn't require updating. Added Rails::Initializer and Rails::Configuration to abstract all of the common setup out of config/environment.rb (uses config/boot.rb to bootstrap the initializer and paths)
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2115 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties/lib/tasks/testing.rake')
-rw-r--r-- | railties/lib/tasks/testing.rake | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/railties/lib/tasks/testing.rake b/railties/lib/tasks/testing.rake new file mode 100644 index 0000000000..3542b74763 --- /dev/null +++ b/railties/lib/tasks/testing.rake @@ -0,0 +1,40 @@ +TEST_CHANGES_SINCE = Time.now - 600 + +# Look up tests for recently modified sources. +def recent_tests(source_pattern, test_path, touched_since = 10.minutes.ago) + FileList[source_pattern].map do |path| + if File.mtime(path) > touched_since + test = "#{test_path}/#{File.basename(path, '.rb')}_test.rb" + test if File.exists?(test) + end + end.compact +end + +desc 'Test recent changes.' +Rake::TestTask.new(:recent => [ :clone_structure_to_test ]) do |t| + since = TEST_CHANGES_SINCE + touched = FileList['test/**/*_test.rb'].select { |path| File.mtime(path) > since } + + recent_tests('app/models/*.rb', 'test/unit', since) + + recent_tests('app/controllers/*.rb', 'test/functional', since) + + t.libs << 'test' + t.verbose = true + t.test_files = touched.uniq +end +task :test_recent => [ :clone_structure_to_test ] + +desc "Run the unit tests in test/unit" +Rake::TestTask.new("test_units") { |t| + t.libs << "test" + t.pattern = 'test/unit/**/*_test.rb' + t.verbose = true +} +task :test_units => [ :clone_structure_to_test ] + +desc "Run the functional tests in test/functional" +Rake::TestTask.new("test_functional") { |t| + t.libs << "test" + t.pattern = 'test/functional/**/*_test.rb' + t.verbose = true +} +task :test_functional => [ :clone_structure_to_test ]
\ No newline at end of file |