mega-sharp-tool 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/mega-sharp-tool.gemspec +12 -0
- data/minitest-6.0.6/History.rdoc +1860 -0
- data/minitest-6.0.6/Manifest.txt +41 -0
- data/minitest-6.0.6/README.rdoc +763 -0
- data/minitest-6.0.6/Rakefile +89 -0
- data/minitest-6.0.6/bin/minitest +5 -0
- data/minitest-6.0.6/design_rationale.rb +54 -0
- data/minitest-6.0.6/lib/hoe/minitest.rb +30 -0
- data/minitest-6.0.6/lib/minitest/assertions.rb +821 -0
- data/minitest-6.0.6/lib/minitest/autorun.rb +5 -0
- data/minitest-6.0.6/lib/minitest/benchmark.rb +452 -0
- data/minitest-6.0.6/lib/minitest/bisect.rb +304 -0
- data/minitest-6.0.6/lib/minitest/complete.rb +56 -0
- data/minitest-6.0.6/lib/minitest/compress.rb +94 -0
- data/minitest-6.0.6/lib/minitest/error_on_warning.rb +11 -0
- data/minitest-6.0.6/lib/minitest/expectations.rb +321 -0
- data/minitest-6.0.6/lib/minitest/find_minimal_combination.rb +127 -0
- data/minitest-6.0.6/lib/minitest/hell.rb +11 -0
- data/minitest-6.0.6/lib/minitest/manual_plugins.rb +4 -0
- data/minitest-6.0.6/lib/minitest/parallel.rb +72 -0
- data/minitest-6.0.6/lib/minitest/path_expander.rb +432 -0
- data/minitest-6.0.6/lib/minitest/pride.rb +4 -0
- data/minitest-6.0.6/lib/minitest/pride_plugin.rb +135 -0
- data/minitest-6.0.6/lib/minitest/server.rb +49 -0
- data/minitest-6.0.6/lib/minitest/server_plugin.rb +88 -0
- data/minitest-6.0.6/lib/minitest/spec.rb +324 -0
- data/minitest-6.0.6/lib/minitest/sprint.rb +105 -0
- data/minitest-6.0.6/lib/minitest/sprint_plugin.rb +39 -0
- data/minitest-6.0.6/lib/minitest/test.rb +232 -0
- data/minitest-6.0.6/lib/minitest/test_task.rb +331 -0
- data/minitest-6.0.6/lib/minitest.rb +1232 -0
- data/minitest-6.0.6/test/minitest/metametameta.rb +150 -0
- data/minitest-6.0.6/test/minitest/test_bisect.rb +249 -0
- data/minitest-6.0.6/test/minitest/test_find_minimal_combination.rb +138 -0
- data/minitest-6.0.6/test/minitest/test_minitest_assertions.rb +1729 -0
- data/minitest-6.0.6/test/minitest/test_minitest_benchmark.rb +151 -0
- data/minitest-6.0.6/test/minitest/test_minitest_reporter.rb +437 -0
- data/minitest-6.0.6/test/minitest/test_minitest_spec.rb +1095 -0
- data/minitest-6.0.6/test/minitest/test_minitest_test.rb +1295 -0
- data/minitest-6.0.6/test/minitest/test_minitest_test_task.rb +57 -0
- data/minitest-6.0.6/test/minitest/test_path_expander.rb +229 -0
- data/minitest-6.0.6/test/minitest/test_server.rb +146 -0
- metadata +83 -0
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
require "shellwords"
|
|
2
|
+
require "rbconfig"
|
|
3
|
+
|
|
4
|
+
begin
|
|
5
|
+
require "rake/tasklib"
|
|
6
|
+
rescue LoadError => e
|
|
7
|
+
warn e.message
|
|
8
|
+
return
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
module Minitest # :nodoc:
|
|
12
|
+
|
|
13
|
+
##
|
|
14
|
+
# Minitest::TestTask is a rake helper that generates several rake
|
|
15
|
+
# tasks under the main test task's name-space.
|
|
16
|
+
#
|
|
17
|
+
# task <name> :: the main test task
|
|
18
|
+
# task <name>:cmd :: prints the command to use
|
|
19
|
+
# task <name>:deps :: runs each test file by itself to find dependency errors
|
|
20
|
+
# task <name>:slow :: runs the tests and reports the slowest 25 tests.
|
|
21
|
+
#
|
|
22
|
+
# Examples:
|
|
23
|
+
#
|
|
24
|
+
# Minitest::TestTask.create
|
|
25
|
+
#
|
|
26
|
+
# The most basic and default setup.
|
|
27
|
+
#
|
|
28
|
+
# Minitest::TestTask.create :my_tests
|
|
29
|
+
#
|
|
30
|
+
# The most basic/default setup, but with a custom name
|
|
31
|
+
#
|
|
32
|
+
# Minitest::TestTask.create :unit do |t|
|
|
33
|
+
# t.test_globs = ["test/unit/**/*_test.rb"]
|
|
34
|
+
# t.warning = false
|
|
35
|
+
# end
|
|
36
|
+
#
|
|
37
|
+
# Customize the name and only run unit tests.
|
|
38
|
+
#
|
|
39
|
+
# NOTE: To hook this task up to the default, make it a dependency:
|
|
40
|
+
#
|
|
41
|
+
# task default: :unit
|
|
42
|
+
|
|
43
|
+
class TestTask < Rake::TaskLib
|
|
44
|
+
WINDOWS = RbConfig::CONFIG["host_os"] =~ /mswin|mingw/ # :nodoc:
|
|
45
|
+
|
|
46
|
+
##
|
|
47
|
+
# Create several test-oriented tasks under +name+ (default:
|
|
48
|
+
# "test"). Takes an optional block to customize variables.
|
|
49
|
+
# Examples:
|
|
50
|
+
#
|
|
51
|
+
# Minitest::TestTask.create # named "test", all defaults
|
|
52
|
+
#
|
|
53
|
+
# Minitest::TestTask.create do |t|
|
|
54
|
+
# t.warning = false # my tests are noisy
|
|
55
|
+
# t.framework = %(require_relative "./test/helper.rb")
|
|
56
|
+
# end
|
|
57
|
+
|
|
58
|
+
def self.create name = :test, &block
|
|
59
|
+
task = new name
|
|
60
|
+
task.instance_eval(&block) if block
|
|
61
|
+
task.process_env
|
|
62
|
+
task.define
|
|
63
|
+
task
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
##
|
|
67
|
+
# Extra arguments to pass to the tests. Defaults empty but gets
|
|
68
|
+
# populated by a number of enviroment variables:
|
|
69
|
+
#
|
|
70
|
+
# N (-n flag) :: a string or regexp of tests to run.
|
|
71
|
+
# X (-e flag) :: a string or regexp of tests to exclude.
|
|
72
|
+
# A (arg) :: quick way to inject an arbitrary argument (eg A=--help).
|
|
73
|
+
#
|
|
74
|
+
# See #process_env
|
|
75
|
+
|
|
76
|
+
attr_accessor :extra_args
|
|
77
|
+
|
|
78
|
+
##
|
|
79
|
+
# The code to load the framework. Defaults to requiring
|
|
80
|
+
# minitest/autorun.
|
|
81
|
+
#
|
|
82
|
+
# If you have a test helper file that requires minitest/autorun
|
|
83
|
+
# and anything else your project standardizes on, then you'll
|
|
84
|
+
# probably want to change this to:
|
|
85
|
+
#
|
|
86
|
+
# Minitest::TestTask.create do |t|
|
|
87
|
+
# t.framework = %(require_relative "./test/helper.rb")
|
|
88
|
+
# end
|
|
89
|
+
#
|
|
90
|
+
# or something similar. NOTE: if you do this, then helper must
|
|
91
|
+
# require "minitest/autorun" at the top to start the tests.
|
|
92
|
+
|
|
93
|
+
attr_accessor :framework
|
|
94
|
+
|
|
95
|
+
##
|
|
96
|
+
# Extra library directories to include. Defaults to %w[lib test
|
|
97
|
+
# .]. Also uses $MT_LIB_EXTRAS allowing you to dynamically
|
|
98
|
+
# override/inject directories for custom runs.
|
|
99
|
+
|
|
100
|
+
attr_accessor :libs
|
|
101
|
+
|
|
102
|
+
##
|
|
103
|
+
# The name of the task and base name for the other tasks generated.
|
|
104
|
+
|
|
105
|
+
attr_accessor :name
|
|
106
|
+
|
|
107
|
+
##
|
|
108
|
+
# File globs to find test files. Defaults to something sensible to
|
|
109
|
+
# find test files under the test directory.
|
|
110
|
+
|
|
111
|
+
attr_accessor :test_globs
|
|
112
|
+
|
|
113
|
+
##
|
|
114
|
+
# Turn on ruby warnings (-w flag). Defaults to true.
|
|
115
|
+
|
|
116
|
+
attr_accessor :warning
|
|
117
|
+
|
|
118
|
+
##
|
|
119
|
+
# Optional: Additional ruby to run before the test framework is loaded.
|
|
120
|
+
# Example:
|
|
121
|
+
#
|
|
122
|
+
# Minitest::TestTask.create "test:cov" do |t|
|
|
123
|
+
# t.test_prelude = %(require "simplecov")
|
|
124
|
+
# end
|
|
125
|
+
|
|
126
|
+
attr_accessor :test_prelude
|
|
127
|
+
|
|
128
|
+
##
|
|
129
|
+
# Print out commands as they run. Defaults to Rake's +trace+ (-t
|
|
130
|
+
# flag) option.
|
|
131
|
+
|
|
132
|
+
attr_accessor :verbose
|
|
133
|
+
|
|
134
|
+
##
|
|
135
|
+
# Use TestTask.create instead.
|
|
136
|
+
|
|
137
|
+
def initialize name = :test # :nodoc:
|
|
138
|
+
self.extra_args = []
|
|
139
|
+
self.framework = %(require "minitest/autorun")
|
|
140
|
+
self.libs = %w[lib test .]
|
|
141
|
+
self.name = name
|
|
142
|
+
self.test_globs = ["test/**/test_*.rb",
|
|
143
|
+
"test/**/*_test.rb"]
|
|
144
|
+
self.test_prelude = nil
|
|
145
|
+
self.verbose = Rake.application.options.trace || Rake.verbose == true
|
|
146
|
+
self.warning = true
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
##
|
|
150
|
+
# Extract variables from the environment and convert them to
|
|
151
|
+
# command line arguments. See #extra_args.
|
|
152
|
+
#
|
|
153
|
+
# Environment Variables:
|
|
154
|
+
#
|
|
155
|
+
# MT_LIB_EXTRAS :: Extra libs to dynamically override/inject for custom runs.
|
|
156
|
+
# N :: Tests to run (string or /regexp/).
|
|
157
|
+
# X :: Tests to exclude (string or /regexp/).
|
|
158
|
+
# A :: Any extra arguments. Honors shell quoting.
|
|
159
|
+
#
|
|
160
|
+
# Deprecated:
|
|
161
|
+
#
|
|
162
|
+
# TESTOPTS :: For argument passing, use +A+.
|
|
163
|
+
# N :: For parallel testing, use +MT_CPU+.
|
|
164
|
+
# FILTER :: Same as +TESTOPTS+.
|
|
165
|
+
|
|
166
|
+
def process_env
|
|
167
|
+
warn "TESTOPTS is deprecated in Minitest::TestTask. Use A instead" if
|
|
168
|
+
ENV["TESTOPTS"]
|
|
169
|
+
warn "FILTER is deprecated in Minitest::TestTask. Use A instead" if
|
|
170
|
+
ENV["FILTER"]
|
|
171
|
+
|
|
172
|
+
lib_extras = (ENV["MT_LIB_EXTRAS"] || "").split File::PATH_SEPARATOR
|
|
173
|
+
self.libs[0, 0] = lib_extras
|
|
174
|
+
|
|
175
|
+
extra_args << "-i" << ENV["N"] if ENV["N"]
|
|
176
|
+
extra_args << "-i" << ENV["I"] if ENV["I"]
|
|
177
|
+
extra_args << "-x" << ENV["X"] if ENV["X"]
|
|
178
|
+
extra_args << "-x" << ENV["E"] if ENV["E"]
|
|
179
|
+
extra_args.concat Shellwords.split(ENV["TESTOPTS"]) if ENV["TESTOPTS"]
|
|
180
|
+
extra_args.concat Shellwords.split(ENV["FILTER"]) if ENV["FILTER"]
|
|
181
|
+
extra_args.concat Shellwords.split(ENV["A"]) if ENV["A"]
|
|
182
|
+
|
|
183
|
+
# TODO? RUBY_DEBUG = ENV["RUBY_DEBUG"]
|
|
184
|
+
# TODO? ENV["RUBY_FLAGS"]
|
|
185
|
+
|
|
186
|
+
extra_args.compact!
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
def define # :nodoc:
|
|
190
|
+
desc "Run the test suite. Use I, X, and A to add flags/args."
|
|
191
|
+
task name do
|
|
192
|
+
ruby make_test_cmd, verbose: verbose
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
desc "Run the test suite, filtering for 'FU' in name (focused units?)."
|
|
196
|
+
task "#{name}:fu" do
|
|
197
|
+
ruby make_test_cmd(include:"/FU/"), verbose: verbose
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
desc "Print out the test command. Good for profiling and other tools."
|
|
201
|
+
task "#{name}:cmd" do
|
|
202
|
+
puts "ruby #{make_test_cmd}"
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
desc "Show which test files fail when run in isolation."
|
|
206
|
+
task "#{name}:isolated" do
|
|
207
|
+
tests = Dir[*self.test_globs].uniq
|
|
208
|
+
|
|
209
|
+
# 3 seems to be the magic number... (tho not by that much)
|
|
210
|
+
bad, good, n = {}, [], (ENV.delete("K") || 3).to_i
|
|
211
|
+
file = ENV.delete "F"
|
|
212
|
+
times = {}
|
|
213
|
+
|
|
214
|
+
tt0 = Time.now
|
|
215
|
+
|
|
216
|
+
n.threads_do tests.sort do |path|
|
|
217
|
+
t0 = Time.now
|
|
218
|
+
output = `#{Gem.ruby} #{make_test_cmd path:path} 2>&1`
|
|
219
|
+
t1 = Time.now - t0
|
|
220
|
+
|
|
221
|
+
times[path] = t1
|
|
222
|
+
|
|
223
|
+
if $?.success?
|
|
224
|
+
$stderr.print "."
|
|
225
|
+
good << path
|
|
226
|
+
else
|
|
227
|
+
$stderr.print "x"
|
|
228
|
+
bad[path] = output
|
|
229
|
+
end
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
puts "done"
|
|
233
|
+
puts "Ran in %.2f seconds" % [ Time.now - tt0 ]
|
|
234
|
+
|
|
235
|
+
if file then
|
|
236
|
+
require "json"
|
|
237
|
+
File.open file, "w" do |io|
|
|
238
|
+
io.puts JSON.pretty_generate times
|
|
239
|
+
end
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
unless good.empty?
|
|
243
|
+
puts
|
|
244
|
+
puts "# Good tests:"
|
|
245
|
+
puts
|
|
246
|
+
good.sort.each do |path|
|
|
247
|
+
puts "%.2fs: %s" % [times[path], path]
|
|
248
|
+
end
|
|
249
|
+
end
|
|
250
|
+
|
|
251
|
+
unless bad.empty?
|
|
252
|
+
puts
|
|
253
|
+
puts "# Bad tests:"
|
|
254
|
+
puts
|
|
255
|
+
bad.keys.sort.each do |path|
|
|
256
|
+
puts "%.2fs: %s" % [times[path], path]
|
|
257
|
+
end
|
|
258
|
+
puts
|
|
259
|
+
puts "# Bad Test Output:"
|
|
260
|
+
puts
|
|
261
|
+
bad.sort.each do |path, output|
|
|
262
|
+
puts
|
|
263
|
+
puts "# #{path}:"
|
|
264
|
+
puts output
|
|
265
|
+
end
|
|
266
|
+
exit 1
|
|
267
|
+
end
|
|
268
|
+
end
|
|
269
|
+
|
|
270
|
+
task "#{name}:deps" => "#{name}:isolated" # now just an alias
|
|
271
|
+
|
|
272
|
+
desc "Run the test suite and report the slowest 25 tests."
|
|
273
|
+
task "#{name}:slow" do
|
|
274
|
+
sh ["rake #{name} A=-v",
|
|
275
|
+
"egrep '#test_.* s = .'",
|
|
276
|
+
"sort -n -k2 -t=",
|
|
277
|
+
"tail -25"].join " | "
|
|
278
|
+
end
|
|
279
|
+
end
|
|
280
|
+
|
|
281
|
+
##
|
|
282
|
+
# Generate the test command-line.
|
|
283
|
+
|
|
284
|
+
def make_test_cmd **option
|
|
285
|
+
globs = option[:path] || test_globs
|
|
286
|
+
|
|
287
|
+
tests = []
|
|
288
|
+
tests.concat Dir[*globs].sort.shuffle # TODO: SEED -> srand first?
|
|
289
|
+
tests.map! { |f| %(require "#{f}") }
|
|
290
|
+
|
|
291
|
+
runner = []
|
|
292
|
+
runner << test_prelude if test_prelude
|
|
293
|
+
runner << framework
|
|
294
|
+
runner.concat tests
|
|
295
|
+
runner = runner.join "; "
|
|
296
|
+
|
|
297
|
+
extra_args << "-i" << option[:include] if option[:include]
|
|
298
|
+
|
|
299
|
+
args = []
|
|
300
|
+
args << "-I#{libs.join File::PATH_SEPARATOR}" unless libs.empty?
|
|
301
|
+
args << "-w" if warning
|
|
302
|
+
args << "-e"
|
|
303
|
+
args << "'#{runner}'"
|
|
304
|
+
args << "--"
|
|
305
|
+
args << extra_args.map(&:shellescape)
|
|
306
|
+
|
|
307
|
+
args.join " "
|
|
308
|
+
end
|
|
309
|
+
end
|
|
310
|
+
end
|
|
311
|
+
|
|
312
|
+
class Work < Queue # :nodoc:
|
|
313
|
+
def initialize jobs # :nodoc:
|
|
314
|
+
super
|
|
315
|
+
close
|
|
316
|
+
end
|
|
317
|
+
end
|
|
318
|
+
|
|
319
|
+
class Integer # :nodoc:
|
|
320
|
+
def threads_do jobs # :nodoc:
|
|
321
|
+
q = Work.new jobs
|
|
322
|
+
|
|
323
|
+
Array.new(self) {
|
|
324
|
+
Thread.new do
|
|
325
|
+
while job = q.pop # go until quit value
|
|
326
|
+
yield job
|
|
327
|
+
end
|
|
328
|
+
end
|
|
329
|
+
}.each(&:join)
|
|
330
|
+
end
|
|
331
|
+
end
|