test:uncommitted didn't work, so I wrote test:svn_recent

3 views
Skip to first unread message

Phlip

unread,
Jul 12, 2007, 10:19:06 AM7/12/07
to rubyonra...@googlegroups.com
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/
"Test Driven Ajax (on Rails)"
assert_xpath, assert_javascript, & assert_ajax

Phlip

unread,
Jul 13, 2007, 8:13:46 AM7/13/07
to rubyonra...@googlegroups.com
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.

Reply all
Reply to author
Forward
0 new messages