Class: Rote::RCovTask

Inherits:
Rake::TaskLib
  • Object
show all
Defined in:
lib/rote/extratasks.rb

Overview

Rake task library that allows code-coverage reports to be generated using RCov (eigenclass.org/hiki.rb?rcov).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = :rcov, failonerror = true) {|_self| ... } ⇒ RCovTask

Create a new RCovTask, using the supplied block for configuration, and define tasks with the specified base-name within Rake.

Note that the named task just invokes a file task for the output directory, which is dependent on test (and source, if specified) file changes.

Yields:

  • (_self)

Yield Parameters:



61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/rote/extratasks.rb', line 61

def initialize(name = :rcov, failonerror = true) # :yield: self if block_given?      
  @taskname = name
  @rcov_cmd = 'rcov'
  @test_files = Rake::FileList.new
  @source_files = Rake::FileList.new
  @load_paths = []
  @excludes = []      
  @output_dir = './coverage'
  @failonerror = true
  
  yield self if block_given?

  define(name)
end

Instance Attribute Details

#excludesObject

Set of glob patterns that should be excluded from the test run. [none]



44
45
46
# File 'lib/rote/extratasks.rb', line 44

def excludes
  @excludes
end

#failonerrorObject

If false, the task will emit a warning rather than failing when Rcov command fails. [true]



53
54
55
# File 'lib/rote/extratasks.rb', line 53

def failonerror
  @failonerror
end

#load_pathsObject

Extra load-paths that should be appended to $: when running the test cases. [none]



37
38
39
# File 'lib/rote/extratasks.rb', line 37

def load_paths
  @load_paths
end

#no_colorObject

If true, RCov will generate colorblind-safe output. [false]



40
41
42
# File 'lib/rote/extratasks.rb', line 40

def no_color
  @no_color
end

#output_dirObject

The path to which RCov should generate output [./coverage]



33
34
35
# File 'lib/rote/extratasks.rb', line 33

def output_dir
  @output_dir
end

#profileObject

Determines whether bogo-profiling is enabled [false]



47
48
49
# File 'lib/rote/extratasks.rb', line 47

def profile
  @profile
end

#rangeObject

The color scale range for profiling output (dB) [not used]



50
51
52
# File 'lib/rote/extratasks.rb', line 50

def range
  @range
end

#rcov_cmdObject

The command that runs RCov [‘rcov’]



19
20
21
# File 'lib/rote/extratasks.rb', line 19

def rcov_cmd
  @rcov_cmd
end

#source_filesObject

A Rake::FileList holding Ruby source filenames that are included in the coverage report. This is optional - RCov finds sources by running them. However, if you do specify your files here then the coverage report will only be generated when they change.



30
31
32
# File 'lib/rote/extratasks.rb', line 30

def source_files
  @source_files
end

#tasknameObject (readonly)

The base name for the generated task [:rcov]



16
17
18
# File 'lib/rote/extratasks.rb', line 16

def taskname
  @taskname
end

#test_filesObject

A Rake::FileList holding unit-test filenames and globs. RCov will execute these to generate the report.



23
24
25
# File 'lib/rote/extratasks.rb', line 23

def test_files
  @test_files
end