pg 0.11.0 → 0.12.0pre258

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,152 +0,0 @@
1
- #
2
- # Rake tasklib for testing tasks
3
-
4
- #
5
- # Authors:
6
- # * Michael Granger <ged@FaerieMUD.org>
7
- #
8
-
9
- unless defined?( COVERAGE_MINIMUM )
10
- if ENV['COVVERAGE_MINIMUM']
11
- COVERAGE_MINIMUM = Float( ENV['COVERAGE_MINIMUM'] )
12
- else
13
- COVERAGE_MINIMUM = 85.0
14
- end
15
- end
16
- SPEC_FILES = [] unless defined?( SPEC_FILES )
17
- TEST_FILES = [] unless defined?( TEST_FILES )
18
-
19
- COMMON_RSPEC_OPTS = [] unless defined?( COMMON_RSPEC_OPTS )
20
-
21
- COVERAGE_TARGETDIR = BASEDIR + 'coverage' unless defined?( COVERAGE_TARGETDIR )
22
- RCOV_EXCLUDES = 'spec,tests,/Library/Ruby,/var/lib,/usr/local/lib' unless
23
- defined?( RCOV_EXCLUDES )
24
-
25
-
26
- desc "Run all defined tests"
27
- task :test do
28
- unless SPEC_FILES.empty?
29
- log "Running specs"
30
- Rake::Task['spec:quiet'].invoke
31
- end
32
-
33
- unless TEST_FILES.empty?
34
- log "Running unit tests"
35
- Rake::Task[:unittests].invoke
36
- end
37
- end
38
-
39
-
40
- ### RSpec specifications
41
- begin
42
- gem 'rspec', '>= 2.0.0'
43
-
44
- require 'rspec'
45
- require 'rspec/core/rake_task'
46
-
47
- ### Task: spec
48
- desc "Run specs"
49
- task :spec => 'spec:doc'
50
- task :specs => :spec
51
-
52
- namespace :spec do
53
- desc "Run rspec every time there's a change to one of the files"
54
- task :autotest do
55
- require 'autotest'
56
- Autotest.add_discovery { "rspec2" }
57
- Autotest.run
58
- end
59
-
60
- desc "Generate regular color 'doc' spec output"
61
- RSpec::Core::RakeTask.new( :doc ) do |task|
62
- task.rspec_opts = COMMON_RSPEC_OPTS + ['-f', 'd', '-c']
63
- end
64
-
65
- desc "Generate spec output with profiling"
66
- RSpec::Core::RakeTask.new( :profile ) do |task|
67
- task.rspec_opts = COMMON_RSPEC_OPTS + ['-f', 'p', '-p']
68
- end
69
-
70
- desc "Generate quiet non-colored plain-text output"
71
- RSpec::Core::RakeTask.new( :quiet ) do |task|
72
- task.rspec_opts = COMMON_RSPEC_OPTS + ['-f', 'p']
73
- end
74
-
75
- desc "Generate HTML output"
76
- RSpec::Core::RakeTask.new( :html ) do |task|
77
- task.rspec_opts = COMMON_RSPEC_OPTS + ['-f', 'h']
78
- end
79
-
80
-
81
- end
82
-
83
- ### Task: coverage (via RCov)
84
- desc "Build test coverage reports"
85
- RSpec::Core::RakeTask.new( :coverage ) do |task|
86
- task.ruby_opts = [ "-I#{LIBDIR}" ]
87
- task.rspec_opts = ['-f', 'p', '-b']
88
- task.rcov_opts = RCOV_OPTS
89
- task.rcov = true
90
- end
91
-
92
- ### Task: rcov
93
- task :rcov => :coverage
94
-
95
- ### Other coverage tasks
96
- namespace :coverage do
97
- desc "Generate a detailed text coverage report"
98
- RSpec::Core::RakeTask.new( :text ) do |task|
99
- task.rcov_opts = RCOV_OPTS + ['--text-report']
100
- task.rcov = true
101
- end
102
-
103
- desc "Show differences in coverage from last run"
104
- RSpec::Core::RakeTask.new( :diff ) do |task|
105
- task.rspec_opts = ['-f', 'p', '-b']
106
- task.rcov_opts = RCOV_OPTS - ['--save'] + ['--text-coverage-diff']
107
- task.rcov = true
108
- end
109
-
110
- desc "Run RCov in 'spec-only' mode to check coverage from specs"
111
- RSpec::Core::RakeTask.new( :speconly ) do |task|
112
- task.rcov_opts = ['--exclude', RCOV_EXCLUDES, '--text-report', '--save']
113
- task.rcov = true
114
- end
115
- end
116
-
117
- CLOBBER.include( COVERAGE_TARGETDIR )
118
- rescue LoadError => err
119
- task :no_rspec do
120
- $stderr.puts "Specification tasks not defined: %s" % [ err.message ]
121
- end
122
-
123
- task :spec => :no_rspec
124
- namespace :spec do
125
- task :autotest => :no_rspec
126
- task :doc => :no_rspec
127
- task :profile => :no_rspec
128
- task :quiet => :no_rspec
129
- task :html => :no_rspec
130
- end
131
- end
132
-
133
-
134
- ### Test::Unit tests
135
- begin
136
- require 'rake/testtask'
137
-
138
- Rake::TestTask.new( :unittests ) do |task|
139
- task.libs += [LIBDIR]
140
- task.test_files = TEST_FILES
141
- task.verbose = true
142
- end
143
-
144
- rescue LoadError => err
145
- task :no_test do
146
- $stderr.puts "Test tasks not defined: %s" % [ err.message ]
147
- end
148
-
149
- task :unittests => :no_rspec
150
- end
151
-
152
-
@@ -1,64 +0,0 @@
1
- #####################################################################
2
- ### S U B V E R S I O N T A S K S A N D H E L P E R S
3
- #####################################################################
4
-
5
- require 'rake/tasklib'
6
-
7
- #
8
- # Work around the inexplicable behaviour of the original RDoc::VerifyTask, which
9
- # errors if your coverage isn't *exactly* the threshold.
10
- #
11
-
12
- # A task that can verify that the RCov coverage doesn't
13
- # drop below a certain threshold. It should be run after
14
- # running Spec::Rake::SpecTask.
15
- class VerifyTask < Rake::TaskLib
16
-
17
- COVERAGE_PERCENTAGE_PATTERN =
18
- %r{<tt class='coverage_code'>(\d+\.\d+)%</tt>}
19
-
20
- # Name of the task. Defaults to :verify_rcov
21
- attr_accessor :name
22
-
23
- # Path to the index.html file generated by RCov, which
24
- # is the file containing the total coverage.
25
- # Defaults to 'coverage/index.html'
26
- attr_accessor :index_html
27
-
28
- # Whether or not to output details. Defaults to true.
29
- attr_accessor :verbose
30
-
31
- # The threshold value (in percent) for coverage. If the
32
- # actual coverage is not equal to this value, the task will raise an
33
- # exception.
34
- attr_accessor :threshold
35
-
36
- def initialize( name=:verify )
37
- @name = name
38
- @index_html = 'coverage/index.html'
39
- @verbose = true
40
- yield self if block_given?
41
- raise "Threshold must be set" if @threshold.nil?
42
- define
43
- end
44
-
45
- def define
46
- desc "Verify that rcov coverage is at least #{threshold}%"
47
-
48
- task @name do
49
- total_coverage = nil
50
- if match = File.read( index_html ).match( COVERAGE_PERCENTAGE_PATTERN )
51
- total_coverage = Float( match[1] )
52
- else
53
- raise "Couldn't find the coverage percentage in #{index_html}"
54
- end
55
-
56
- puts "Coverage: #{total_coverage}% (threshold: #{threshold}%)" if verbose
57
- if total_coverage < threshold
58
- raise "Coverage must be at least #{threshold}% but was #{total_coverage}%"
59
- end
60
- end
61
- end
62
- end
63
-
64
- # vim: set nosta noet ts=4 sw=4:
metadata.gz.sig DELETED
Binary file