1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Make rake test:uncommitted work with Git.

Note : rake test:uncommitted is considering only unstaged files.

Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
This commit is contained in:
Tim Pope 2008-04-19 00:42:26 -05:00 committed by Pratik Naik
parent f5052dd8a3
commit 3a95ee73cf
2 changed files with 12 additions and 4 deletions

View file

@ -1,5 +1,7 @@
*Edge* *Edge*
* Make rake test:uncommitted work with Git. [Tim Pope]
* Added Thin support to script/server. #488 [Bob Klosinski] * Added Thin support to script/server. #488 [Bob Klosinski]
* Fix script/about in production mode. #370 [Cheah Chu Yeow, Xavier Noria, David Krmpotic] * Fix script/about in production mode. #370 [Cheah Chu Yeow, Xavier Noria, David Krmpotic]

View file

@ -66,10 +66,16 @@ namespace :test do
Rake::TestTask.new(:uncommitted => "db:test:prepare") do |t| Rake::TestTask.new(:uncommitted => "db:test:prepare") do |t|
def t.file_list def t.file_list
if File.directory?(".svn")
changed_since_checkin = silence_stderr { `svn status` }.map { |path| path.chomp[7 .. -1] } changed_since_checkin = silence_stderr { `svn status` }.map { |path| path.chomp[7 .. -1] }
elsif File.directory?(".git")
changed_since_checkin = silence_stderr { `git ls-files --modified --others` }.map { |path| path.chomp }
else
abort "Not a Subversion or Git checkout."
end
models = changed_since_checkin.select { |path| path =~ /app[\\\/]models[\\\/].*\.rb/ } models = changed_since_checkin.select { |path| path =~ /app[\\\/]models[\\\/].*\.rb$/ }
controllers = changed_since_checkin.select { |path| path =~ /app[\\\/]controllers[\\\/].*\.rb/ } controllers = changed_since_checkin.select { |path| path =~ /app[\\\/]controllers[\\\/].*\.rb$/ }
unit_tests = models.map { |model| "test/unit/#{File.basename(model, '.rb')}_test.rb" } unit_tests = models.map { |model| "test/unit/#{File.basename(model, '.rb')}_test.rb" }
functional_tests = controllers.map { |controller| "test/functional/#{File.basename(controller, '.rb')}_test.rb" } functional_tests = controllers.map { |controller| "test/functional/#{File.basename(controller, '.rb')}_test.rb" }
@ -80,7 +86,7 @@ namespace :test do
t.libs << 'test' t.libs << 'test'
t.verbose = true t.verbose = true
end end
Rake::Task['test:uncommitted'].comment = "Test changes since last checkin (only Subversion)" Rake::Task['test:uncommitted'].comment = "Test changes since last checkin (only Subversion and Git)"
Rake::TestTask.new(:units => "db:test:prepare") do |t| Rake::TestTask.new(:units => "db:test:prepare") do |t|
t.libs << "test" t.libs << "test"