# Test:uncommitted didn't work, so I wrote test:svn\_recent

**URL:** <https://www.ruby-forum.com/t/test-uncommitted-didnt-work-so-i-wrote-test-svn-recent/109232>\
**Category:** Rails\
**Created:** [July 12, 2007, 4:20pm UTC](https://www.ruby-forum.com/t/test-uncommitted-didnt-work-so-i-wrote-test-svn-recent/109232 "2007-07-12T16:20:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Phlip](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ed8c4c/32.png) [@Phlip](https://www.ruby-forum.com/u/Phlip)\
**Post date:** [July 12, 2007, 4:20pm UTC](https://www.ruby-forum.com/t/test-uncommitted-didnt-work-so-i-wrote-test-svn-recent/109232/1 "2007-07-12T16:20:22Z")

</div>

Railsters:

Put this into a \*.rake file, and invoke it from a command line as  
“rake test:svn\_recent”:

require ‘fileutils’

task ‘test:svn\_recent’ do  
`svn status`.  
split(“\n”).  
map{|f| f =~ /^M\s+(.\*\_test.rb)/; $1 }.  
compact.  
each do |uncommitted|  
FileUtils.touch uncommitted  
end

Rake::Task[‘test:recent’].invoke  
end

It finds every SVN file with a status of M (due to Subversion’s stated  
goal to support absurdly easy grep-based scripting), and touches this  
file. Then it invokes the normal test:recent run, which adds files to  
the test list if their modification time is newer than 10 minutes ago.

For a good time, we could also add the ability to find every modified  
source file, find its matching \*\_test.rb, and trigger it. That  
behavior is allegedly in test:recent too, but I have never seen it  
working. It should be very easy to add to this system.

–  
Phlip  
[http://www.oreilly.com/catalog/9780596510657/](http://www.oreilly.com/catalog/9780596510657/)  
“Test Driven Ajax (on Rails)”  
assert\_xpath, assert\_javascript, & assert\_ajax

---

<div class="post-metadata">

**Author:** ![Phlip](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ed8c4c/32.png) [@Phlip](https://www.ruby-forum.com/u/Phlip)\
**Post date:** [July 13, 2007, 2:15pm UTC](https://www.ruby-forum.com/t/test-uncommitted-didnt-work-so-i-wrote-test-svn-recent/109232/2 "2007-07-13T14:15:19Z")

</div>

Railsters:

Here’s an upgrade to my former attempt, this time using the  
rake-internal  
mechanisms, instead of touching files.

Put this into a \*.rake file, and invoke it from a command line as  
“rake test:svn\_modified”:

namespace :test do  
Rake::TestTask.new(:svn\_modified =\> “db:test:prepare”) do |t|  
t.libs \<\< ‘test’  
t.verbose = true

```
t.test_files = `svn status test`.
                 split("\n").
                   map{|f| f =~ /^M\s+(.*_test.rb)/; $1 }.
                     compact.
                       uniq

```

end  
end

It finds every SVN file in the test folder with a status of M (due to  
Subversion’s stated  
goal to support absurdly easy grep-based scripting). Then it passes  
these  
files to the ‘test’ task.

This works better than test:recent because (even while practicing  
Continuous  
Integration), files may stay modified for longer than 10 minutes between  
integrations.

–  
Phlip  
[Test Driven Ajax (on Rails) [Book]](http://www.oreilly.com/catalog/9780596510657/)  
“Test Driven Ajax (on Rails)”  
assert\_xpath, assert\_javascript, & assert\_ajax
