forked from rubyworks/facets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreap.test
261 lines (212 loc) · 5.55 KB
/
reap.test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
#!/usr/bin/env ruby
PATH = "lib/core:lib/standard"
#
# RUN TESTS (requires Lemon)
# ----------------------------------------------------------------------------
task "default" do
sh "ruby-test #{test_flags} test/"
end
task "test" do
if tests = ENV['TESTS']
sh "ruby-test #{test_flags} #{tests}"
else
sh "ruby-test #{test_flags} test/"
end
end
desc "run all unit tests"
task "test:all" do
sh "ruby-test #{test_flags} test/"
end
desc "run core unit tests"
task "test:core" do
sh "ruby-test #{test_flags} -Ilib/core test/core"
end
desc "run standard unit tests"
task "test:standard" do
sh "ruby-test #{test_flags} -Ilib/standard test/standard"
end
desc "run all unit tests with ActiveSupport loaded"
task 'test:all:activesupport' => [:include_activesupport, 'test:all']
desc "run core unit tests with ActiveSupport loaded"
task 'test:core:activesupport' => [:include_activesupport, 'test:core']
desc "run standard unit tests with ActiveSupport loaded"
task 'test:standard:activesupport' => [:include_activesupport, 'test:standard']
task 'include_activesupport' do
require 'activesupport'
end
def test_flags
flags = []
if ENV['verbose']
flags << '-v'
end
flags.join(' ')
end
#
# TEST COVERAGE
# ----------------------------------------------------------------------------
desc "show test coverage"
task "cov" do
sh "lemon cov -I#{PATH} test"
end
desc "show core test coverage"
task "cov:core" do
sh "lemon cov -Ilib/core test/core"
end
desc "show standard test coverage"
task "cov:standard" do
sh "lemon cov -Ilib/standard test/standard"
end
desc "show core coverage by file name"
task 'cov:file:core' do
core_scripts = Dir['lib/core/facets/**/*.rb'].reject{ |s| File.directory?(s) }
core_tests = Dir['test/core/**/*.rb']
core_scripts = core_scripts.map do |f|
md = /lib\/core\/facets\/(.*?)$/.match(f)
md[1]
end
core_tests = core_tests.map do |f|
md = /test\/core\/(.*?)$/.match(f)
md[1].sub('/test_', '/')
end
diff = core_scripts - core_tests
# remove core collectives
diff = diff - %w{
array.rb binding.rb cattr.rb class.rb comparable.rb dir.rb
enumerable.rb exception.rb hash.rb file.rb filetest.rb float.rb
integer.rb kernel.rb matchdata.rb method.rb module.rb nilclass.rb
numeric.rb object.rb proc.rb process.rb range.rb regexp.rb string.rb
symbol.rb time.rb unboundmethod.rb
}
puts diff.sort.join("\n")
puts
puts "#{diff.size} files uncovered."
end
#
# QED
# ----------------------------------------------------------------------------
desc "run qed docs"
task 'qed' do
sh "qed #{qed_flags} -I#{PATH} qed"
end
desc "run core qed docs"
task 'qed:core' do
sh "qed #{qed_flags} -I#{PATH} qed/core"
end
desc "run standard qed docs"
task 'qed:standard' do
sh "qed #{qed_flags} -I#{PATH} qed/standard"
end
desc "run core qed from code base"
task 'qed:code' do
sh "qed #{qed_flags} -c -Ilib/core lib/core"
end
def qed_flags
flags = []
if ENV['verbose']
flags << '-v'
end
flags.join(' ')
end
#
# Extension Clashes
#-----------------------------------------------------------------------------
# TODO: need to fork each lookup via a seprate process to get a clean picture
desc "print method clashes with ActiveSupport"
task 'clash:as' do
#require 'lemon/model/snapshot'
#snap1 = Snapshot.new
#$LOAD_PATH.unshift('lib/core')
#$LOAD_PATH.unshift('lib/more')
#$LOAD_PATH.unshift('lib/tour')
#require 'facets' # 'facets/all'
#snap2 = Snapshot.new
end
desc "print method clashes with Ruby"
task 'clash:ruby' do
require 'lemon/model/snapshot'
end
#
# CHECK CHERRY PICKING
# ----------------------------------------------------------------------------
desc 'check cherry pickability'
task 'check:cherry' do
files = Dir['lib/**/*.rb']
files.each do |file|
out = `ruby -Ilib #{file}`
if out != ''
puts file
puts out
end
end
end
#def add_loadpath(*paths)
# live = ENV['live']
#
# unless live
# # $LOAD_PATH.unshift(File.expand_path('lib/core'))
# # $LOAD_PATH.unshift(File.expand_path('lib/core-uncommon'))
# paths.each do |path|
# $LOAD_PATH.unshift(File.expand_path(path))
# end
# end
#
# puts "RUBY VERSION: #{RUBY_VERSION}"
# puts "LOAD PATH:\n" + $LOAD_PATH.join("\n") if $DEBUG
#end
#def get_tests(find=nil)
# find = find && File.directory?(find) ? File.join(find, '**/test_*.rb') : find
# find = find || ENV['TESTS'] || 'test/**/test_*.rb'
# Dir.glob(find)
#end
#def run_tests(files)
# files.each do |file|
# next if File.directory?(file)
# begin
# puts "Loading: #{file}" if $DEBUG
# load(file)
# rescue LoadError
# puts "Error loading: #{file}"
# end
# end
#end
#def prepare_tests_all
# add_loadpath('lib/core','lib/core-uncommon', 'lib/tour')
# files = get_tests
# run_tests(files)
#end
#def prepare_tests(type)
# add_loadpath("lib/#{type}")
# files = get_tests('test/#{type}')
# run_tests(files)
#end
#def run_tests
# live = ENV['live']
#
# unless live
# $LOAD_PATH.unshift(File.expand_path('lib/core'))
# $LOAD_PATH.unshift(File.expand_path('lib/core-uncommon'))
# end
#
# puts "RUBY VERSION: #{RUBY_VERSION}"
# puts "LOAD PATH:\n" + $LOAD_PATH.join("\n")
#
# if find = ARGV[1..-1].select{|e| e !~ /(^[-]|[=])/ }[0]
# unless FileTest.file?(find)
# find = File.join(find, '**', 'test_*.rb')
# end
# else
# find = 'test/**/test_*.rb'
# end
#
# files = Dir.glob(find)
#
# files.each do |file|
# next if File.directory?(file)
# begin
# puts "Loading: #{file}" if $DEBUG
# load(file)
# rescue LoadError
# puts "Error loading: #{file}"
# end
# end
#end