mirror of
https://github.com/TracksApp/tracks.git
synced 2026-01-04 16:28:50 +01:00
Removed rails_rcov plugin to avoidforcing a dependency on the rcov gem for users of rake db:migrate. For developers, I recommend you install the plugin but don't commit it.
git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@547 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
parent
4650361c17
commit
1fe9d808d0
3 changed files with 0 additions and 256 deletions
20
tracks/vendor/plugins/rails_rcov/MIT-LICENSE
vendored
20
tracks/vendor/plugins/rails_rcov/MIT-LICENSE
vendored
|
|
@ -1,20 +0,0 @@
|
|||
Copyright (c) 2006 Coda Hale
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
86
tracks/vendor/plugins/rails_rcov/README
vendored
86
tracks/vendor/plugins/rails_rcov/README
vendored
|
|
@ -1,86 +0,0 @@
|
|||
= rails_rcov plugin for Rails
|
||||
|
||||
rails_rcov provides easy-to-use Rake tasks to determine the code coverage of
|
||||
your unit, functional, and integration tests using Mauricio Fernandez's rcov
|
||||
tool.
|
||||
|
||||
== Installation
|
||||
|
||||
First, install rcov from Mauricio's web site
|
||||
[http://eigenclass.org/hiki.rb?rcov]. Make sure it's on your system path, so
|
||||
that typing +rcov+ on the command line actually runs it. THIS PLUGIN DOESN'T DO
|
||||
ANYTHING BESIDES GENERATE ERRORS UNLESS YOU INSTALL RCOV FIRST. RCOV CONTAINS
|
||||
ALL THE MAGIC, THIS PLUGIN JUST RUNS IT.
|
||||
|
||||
Second, install this plugin. If your project is source-controlled by Subversion
|
||||
(which it should be, really), the easiest way to install this is via Rails'
|
||||
plugin script:
|
||||
|
||||
./script/plugin install -x http://svn.codahale.com/rails_rcov
|
||||
|
||||
If you're not using Subversion, or if you don't want it adding
|
||||
<tt>svn:externals</tt> in your project, remove the <tt>-x</tt> switch:
|
||||
|
||||
./script/plugin install http://svn.codahale.com/rails_rcov
|
||||
|
||||
== Usage
|
||||
|
||||
For each <tt>test:blah</tt> task you have for your Rails project, rails_rcov
|
||||
adds two more: <tt>test:blah:rcov</tt> and <tt>test:blah:clobber_rcov</tt>.
|
||||
|
||||
Running <tt>rake test:units:rcov</tt>, for example, will run your unit tests
|
||||
through rcov and write the code coverage reports to
|
||||
<tt>your_rails_app/coverage/units</tt>.
|
||||
|
||||
Running <tt>test:units:clobber_rcov</tt> will erase the generated report for the
|
||||
unit tests.
|
||||
|
||||
Each rcov task takes two optional parameters: RCOV_PARAMS, whose argument is
|
||||
passed along to rcov, and SHOW_ONLY, which limits the files displayed in the
|
||||
report.
|
||||
|
||||
RCOV_PARAMS:
|
||||
# sort by coverage
|
||||
rake test:units:rcov RCOV_PARAMS="--sort=coverage"
|
||||
|
||||
# show callsites and hide fully covered files
|
||||
rake test:units:rcov RCOV_PARAMS="--callsites --only-uncovered"
|
||||
|
||||
Check the rcov documentation for more details.
|
||||
|
||||
SHOW_ONLY is a comma-separated list of the files you'd like to see. Right now
|
||||
there are four types of files rake_rcov recognizes: models, helpers,
|
||||
controllers, and lib. These can be abbreviated to their first letters:
|
||||
|
||||
# only show files from app/models
|
||||
rake test:units:rcov SHOW_ONLY=models
|
||||
|
||||
# only show files from app/helpers and app/controllers
|
||||
rake test:units:rcov SHOW_ONLY=helpers,controllers
|
||||
|
||||
# only show files from app/helpers and app/controllers, with less typing
|
||||
rake test:units:rcov SHOW_ONLY=h,c
|
||||
|
||||
Please note that rails_rcov has only been tested with a Bash shell, and any
|
||||
other environment could well explode in your face. If you're having trouble
|
||||
getting this to work on Windows, please take the time to figure out what's not
|
||||
working. Most of the time it boils down to the different ways the Window shell
|
||||
and the Bash shell escape metacharacters. Play around with the way rcov_rake
|
||||
escapes data (like on line 73, or 78) and send me a fix. I don't have a working
|
||||
Windows environment anymore, so leaving it up to me won't solve anything. ;-)
|
||||
|
||||
== Resources
|
||||
|
||||
=== Subversion
|
||||
|
||||
* http://svn.codahale.com/rails_rcov
|
||||
|
||||
=== Blog
|
||||
|
||||
* http://blog.codahale.com
|
||||
|
||||
== Credits
|
||||
|
||||
Written by Coda Hale <coda.hale@gmail.com>. Thanks to Nils Franzen for a Win32
|
||||
escaping patch. Thanks to Alex Wayne for suggesting how to make SHOW_ONLY not be
|
||||
useless.
|
||||
|
|
@ -1,150 +0,0 @@
|
|||
# This File Uses Magic
|
||||
# ====================
|
||||
# Here's an example of how this file works. As an example, let's say you typed
|
||||
# this into your terminal:
|
||||
#
|
||||
# $ rake --tasks
|
||||
#
|
||||
# The rake executable goes through all the various places .rake files can be,
|
||||
# accumulates them all, and then runs them. When this file is loaded by Rake,
|
||||
# it iterates through all the tasks, and for each task named 'test:blah' adds
|
||||
# test:blah:rcov and test:blah:rcov_clobber.
|
||||
#
|
||||
# So you've seen all the tasks, and you type this into your terminal:
|
||||
#
|
||||
# $ rake test:units:rcov
|
||||
#
|
||||
# Rake does the same thing as above, but it runs the test:units:rcov task, which
|
||||
# pretty much just does this:
|
||||
#
|
||||
# $ ruby [this file] [the test you want to run] [some options]
|
||||
#
|
||||
# Now this file is run via the Ruby interpreter, and after glomming up the
|
||||
# options, it acts just like the Rake executable, with a slight difference: it
|
||||
# passes all the arguments to rcov, not ruby, so all your unit tests get some
|
||||
# rcov sweet loving.
|
||||
|
||||
if ARGV.grep(/--run-rake-task=/).empty?
|
||||
# Define all our Rake tasks
|
||||
|
||||
require 'rake/clean'
|
||||
require 'rcov/rcovtask'
|
||||
|
||||
def to_rcov_task_sym(s)
|
||||
s = s.gsub(/(test:)/,'')
|
||||
s.empty? ? nil : s.intern
|
||||
end
|
||||
|
||||
def to_rcov_task_name(s)
|
||||
s = s.gsub(/(test:)/,'')
|
||||
s =~ /s$/i ? s[0..-2] : s
|
||||
end
|
||||
|
||||
def new_rcov_task(test_name)
|
||||
output_dir = "./coverage/#{test_name.gsub('test:','')}"
|
||||
CLOBBER.include(output_dir)
|
||||
|
||||
# Add a task to run the rcov process
|
||||
desc "Run all #{to_rcov_task_name(test_name)} tests with Rcov to measure coverage"
|
||||
task :rcov => [:clobber_rcov] do |t|
|
||||
run_code = '"' << File.expand_path(__FILE__) << '"'
|
||||
run_code << " --run-rake-task=#{test_name}"
|
||||
|
||||
params = String.new
|
||||
if ENV['RCOV_PARAMS']
|
||||
params << ENV['RCOV_PARAMS']
|
||||
end
|
||||
|
||||
# rake test:units:rcov SHOW_ONLY=models,controllers,lib,helpers
|
||||
# rake test:units:rcov SHOW_ONLY=m,c,l,h
|
||||
if ENV['SHOW_ONLY']
|
||||
show_only = ENV['SHOW_ONLY'].to_s.split(',').map{|x|x.strip}
|
||||
if show_only.any?
|
||||
reg_exp = []
|
||||
for show_type in show_only
|
||||
reg_exp << case show_type
|
||||
when 'm', 'models' : 'app\/models'
|
||||
when 'c', 'controllers' : 'app\/controllers'
|
||||
when 'h', 'helpers' : 'app\/helpers'
|
||||
when 'l', 'lib' : 'lib'
|
||||
else
|
||||
show_type
|
||||
end
|
||||
end
|
||||
reg_exp.map!{ |m| "(#{m})" }
|
||||
params << " -x \\\"^(?!#{reg_exp.join('|')})\\\""
|
||||
end
|
||||
end
|
||||
|
||||
unless params.empty?
|
||||
run_code << " --rcov-params=\"#{params}\""
|
||||
end
|
||||
|
||||
ruby run_code
|
||||
end
|
||||
|
||||
# Add a task to clean up after ourselves
|
||||
desc "Remove Rcov reports for #{to_rcov_task_name(test_name)} tests"
|
||||
task :clobber_rcov do |t|
|
||||
rm_r output_dir, :force => true
|
||||
end
|
||||
|
||||
# Link our clobber task to the main one
|
||||
task :clobber => [:clobber_rcov]
|
||||
end
|
||||
|
||||
test_tasks = Rake::Task.tasks.select{ |t| t.comment && t.name =~ /^test/ }
|
||||
for test_task in test_tasks
|
||||
namespace :test do
|
||||
if sym = to_rcov_task_sym(test_task.name)
|
||||
namespace sym do
|
||||
new_rcov_task(test_task.name)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
# Load rake tasks, hijack ruby, and redirect the task through rcov
|
||||
require 'rubygems'
|
||||
require 'rake'
|
||||
|
||||
module RcovTestSettings
|
||||
class << self
|
||||
attr_accessor :output_dir, :options
|
||||
def to_params
|
||||
"-o \"#{@output_dir}\" -T -x \"rubygems/*,rcov*\" --rails #{@options}"
|
||||
end
|
||||
end
|
||||
|
||||
# load options and arguments from command line
|
||||
unless (cmd_line = ARGV.grep(/--rcov-params=/)).empty?
|
||||
@options = cmd_line.first.gsub(/--rcov-params=/, '')
|
||||
end
|
||||
end
|
||||
|
||||
def is_windows?
|
||||
processor, platform, *rest = RUBY_PLATFORM.split("-")
|
||||
platform == 'mswin32'
|
||||
end
|
||||
|
||||
# intercept what Rake *would* be doing with Ruby, and send it through Rcov instead
|
||||
module RakeFileUtils
|
||||
alias :ruby_without_rcov :ruby
|
||||
def ruby(*args, &block)
|
||||
cmd = (is_windows? ? 'rcov.cmd' : 'rcov') << " #{RcovTestSettings.to_params} #{args}"
|
||||
status = sh(cmd, {}, &block)
|
||||
puts "View the full results at <file://#{RcovTestSettings.output_dir}/index.html>"
|
||||
return status
|
||||
end
|
||||
end
|
||||
|
||||
# read the test name and execute it (through Rcov)
|
||||
unless (cmd_line = ARGV.grep(/--run-rake-task=/)).empty?
|
||||
test_name = cmd_line.first.gsub(/--run-rake-task=/,'')
|
||||
ARGV.clear; ARGV << test_name
|
||||
RcovTestSettings.output_dir = File.expand_path("./coverage/#{test_name.gsub('test:','')}")
|
||||
Rake.application.run
|
||||
else
|
||||
raise "No test to execute!"
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue