Forum: Ruby on Rails test:uncommitted didn't work, so I wrote test:svn_recent

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Aafa8848c4b764f080b1b31a51eab73d?d=identicon&s=25 Phlip (Guest)
on 2007-07-12 16:20
(Received via mailing list)
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
Aafa8848c4b764f080b1b31a51eab73d?d=identicon&s=25 Phlip (Guest)
on 2007-07-13 14:15
(Received via mailing list)
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
  http://www.oreilly.com/catalog/9780596510657/
  "Test Driven Ajax (on Rails)"
  assert_xpath, assert_javascript, & assert_ajax
This topic is locked and can not be replied to.