minitest 4.3.3 → 4.4.0
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.
- data.tar.gz.sig +0 -0
- data/History.txt +12 -0
- data/README.txt +1 -1
- data/lib/minitest/benchmark.rb +43 -0
- data/lib/minitest/hell.rb +1 -1
- data/lib/minitest/parallel_each.rb +17 -1
- data/lib/minitest/spec.rb +1 -1
- data/lib/minitest/unit.rb +9 -5
- data/test/minitest/test_minitest_benchmark.rb +16 -0
- data/test/minitest/test_minitest_unit.rb +76 -30
- metadata +8 -8
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
Binary file
|
data/History.txt
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
=== 4.4.0 / 2013-01-07
|
2
|
+
|
3
|
+
* 3 minor enhancements:
|
4
|
+
|
5
|
+
* Added fit_logarithic and assert_performance_logarithmic. (ktheory)
|
6
|
+
* Merge processed options so others can mess with defaults. (tenderlove)
|
7
|
+
* TestCase#message can now take another proc to defer custom message cost. (ordinaryzelig/bhenderson)
|
8
|
+
|
9
|
+
* 1 bug fix:
|
10
|
+
|
11
|
+
* TestCase#passed? now true if test is skipped. (qanhd)
|
12
|
+
|
1
13
|
=== 4.3.3 / 2012-12-06
|
2
14
|
|
3
15
|
* 1 bug fix:
|
data/README.txt
CHANGED
@@ -319,6 +319,7 @@ minitest-reporters :: Create customizable MiniTest output formats
|
|
319
319
|
minitest-rg :: redgreen minitest
|
320
320
|
minitest-shouldify :: Adding all manner of shoulds to MiniTest (bad idea)
|
321
321
|
minitest-spec-magic :: Minitest::Spec extensions for Rails and beyond
|
322
|
+
minitest-spec-rails :: Drop in MiniTest::Spec superclass for ActiveSupport::TestCase.
|
322
323
|
minitest-tags :: add tags for minitest
|
323
324
|
minitest-wscolor :: Yet another test colorizer.
|
324
325
|
minitest_owrapper :: Get tests results as a TestResult object.
|
@@ -347,7 +348,6 @@ Authors... Please send me a pull request with a description of your minitest ext
|
|
347
348
|
* minitest-rails-shoulda
|
348
349
|
* minitest-spec
|
349
350
|
* minitest-spec-context
|
350
|
-
* minitest-spec-rails
|
351
351
|
* minitest-spec-should
|
352
352
|
* minitest-sugar
|
353
353
|
* minitest_should
|
data/lib/minitest/benchmark.rb
CHANGED
@@ -154,6 +154,26 @@ class MiniTest::Unit # :nodoc:
|
|
154
154
|
assert_performance validation_for_fit(:exponential, threshold), &work
|
155
155
|
end
|
156
156
|
|
157
|
+
##
|
158
|
+
# Runs the given +work+ and asserts that the times gathered fit to
|
159
|
+
# match a logarithmic curve within a given error +threshold+.
|
160
|
+
#
|
161
|
+
# Fit is calculated by #fit_logarithmic.
|
162
|
+
#
|
163
|
+
# Ranges are specified by ::bench_range.
|
164
|
+
#
|
165
|
+
# Eg:
|
166
|
+
#
|
167
|
+
# def bench_algorithm
|
168
|
+
# assert_performance_logarithmic 0.9999 do |n|
|
169
|
+
# @obj.algorithm(n)
|
170
|
+
# end
|
171
|
+
# end
|
172
|
+
|
173
|
+
def assert_performance_logarithmic threshold = 0.99, &work
|
174
|
+
assert_performance validation_for_fit(:logarithmic, threshold), &work
|
175
|
+
end
|
176
|
+
|
157
177
|
##
|
158
178
|
# Runs the given +work+ and asserts that the times gathered fit to
|
159
179
|
# match a straight line within a given error +threshold+.
|
@@ -229,6 +249,29 @@ class MiniTest::Unit # :nodoc:
|
|
229
249
|
return Math.exp(a), b, fit_error(xys) { |x| Math.exp(a + b * x) }
|
230
250
|
end
|
231
251
|
|
252
|
+
##
|
253
|
+
# To fit a functional form: y = a + b*ln(x).
|
254
|
+
#
|
255
|
+
# Takes x and y values and returns [a, b, r^2].
|
256
|
+
#
|
257
|
+
# See: http://mathworld.wolfram.com/LeastSquaresFittingLogarithmic.html
|
258
|
+
|
259
|
+
def fit_logarithmic xs, ys
|
260
|
+
n = xs.size
|
261
|
+
xys = xs.zip(ys)
|
262
|
+
slnx2 = sigma(xys) { |x,y| Math.log(x) ** 2 }
|
263
|
+
slnx = sigma(xys) { |x,y| Math.log(x) }
|
264
|
+
sylnx = sigma(xys) { |x,y| y * Math.log(x) }
|
265
|
+
sy = sigma(xys) { |x,y| y }
|
266
|
+
|
267
|
+
c = n * slnx2 - slnx ** 2
|
268
|
+
b = ( n * sylnx - sy * slnx ) / c
|
269
|
+
a = (sy - b * slnx) / n
|
270
|
+
|
271
|
+
return a, b, fit_error(xys) { |x| a + b * Math.log(x) }
|
272
|
+
end
|
273
|
+
|
274
|
+
|
232
275
|
##
|
233
276
|
# Fits the functional form: a + bx.
|
234
277
|
#
|
data/lib/minitest/hell.rb
CHANGED
@@ -1,9 +1,21 @@
|
|
1
|
+
##
|
2
|
+
# Provides a parallel #each that lets you enumerate using N threads.
|
3
|
+
# Use environment variable N to customize. Defaults to 2. Enumerable,
|
4
|
+
# so all the goodies come along (tho not all are wrapped yet to
|
5
|
+
# return another ParallelEach instance).
|
6
|
+
|
1
7
|
class ParallelEach
|
2
8
|
require 'thread'
|
3
9
|
include Enumerable
|
4
10
|
|
11
|
+
##
|
12
|
+
# How many Threads to use for this parallel #each.
|
13
|
+
|
5
14
|
N = (ENV['N'] || 2).to_i
|
6
15
|
|
16
|
+
##
|
17
|
+
# Create a new ParallelEach instance over +list+.
|
18
|
+
|
7
19
|
def initialize list
|
8
20
|
@queue = Queue.new # *sigh*... the Queue api sucks sooo much...
|
9
21
|
|
@@ -11,10 +23,14 @@ class ParallelEach
|
|
11
23
|
N.times { @queue << nil }
|
12
24
|
end
|
13
25
|
|
14
|
-
def grep pattern
|
26
|
+
def grep pattern # :nodoc:
|
15
27
|
self.class.new super
|
16
28
|
end
|
17
29
|
|
30
|
+
##
|
31
|
+
# Starts N threads that yield each element to your block. Joins the
|
32
|
+
# threads at the end.
|
33
|
+
|
18
34
|
def each
|
19
35
|
threads = N.times.map {
|
20
36
|
Thread.new do
|
data/lib/minitest/spec.rb
CHANGED
@@ -179,7 +179,7 @@ class MiniTest::Spec < MiniTest::Unit::TestCase
|
|
179
179
|
##
|
180
180
|
# Define an expectation with name +desc+. Name gets morphed to a
|
181
181
|
# proper test method name. For some freakish reason, people who
|
182
|
-
# write specs don't like class
|
182
|
+
# write specs don't like class inheritance, so this goes way out of
|
183
183
|
# its way to make sure that expectations aren't inherited.
|
184
184
|
#
|
185
185
|
# This is also aliased to #specify and doesn't require a +desc+ arg.
|
data/lib/minitest/unit.rb
CHANGED
@@ -33,6 +33,9 @@ module MiniTest
|
|
33
33
|
class Skip < Assertion; end
|
34
34
|
|
35
35
|
class << self
|
36
|
+
##
|
37
|
+
# Filter object for backtraces.
|
38
|
+
|
36
39
|
attr_accessor :backtrace_filter
|
37
40
|
end
|
38
41
|
|
@@ -555,6 +558,7 @@ module MiniTest
|
|
555
558
|
|
556
559
|
def message msg = nil, ending = ".", &default
|
557
560
|
proc {
|
561
|
+
msg = msg.call.chomp(".") if Proc === msg
|
558
562
|
custom_message = "#{msg}.\n" unless msg.nil? or msg.to_s.empty?
|
559
563
|
"#{custom_message}#{default.call}#{ending}"
|
560
564
|
}
|
@@ -730,7 +734,7 @@ module MiniTest
|
|
730
734
|
end
|
731
735
|
|
732
736
|
class Unit # :nodoc:
|
733
|
-
VERSION = "4.
|
737
|
+
VERSION = "4.4.0" # :nodoc:
|
734
738
|
|
735
739
|
attr_accessor :report, :failures, :errors, :skips # :nodoc:
|
736
740
|
attr_accessor :test_count, :assertion_count # :nodoc:
|
@@ -1032,7 +1036,7 @@ module MiniTest
|
|
1032
1036
|
# Top level driver, controls all output and filtering.
|
1033
1037
|
|
1034
1038
|
def _run args = []
|
1035
|
-
self.options
|
1039
|
+
self.options.merge! process_args args
|
1036
1040
|
|
1037
1041
|
puts "Run options: #{help}"
|
1038
1042
|
|
@@ -1299,7 +1303,7 @@ module MiniTest
|
|
1299
1303
|
rescue *PASSTHROUGH_EXCEPTIONS
|
1300
1304
|
raise
|
1301
1305
|
rescue Exception => e
|
1302
|
-
@passed =
|
1306
|
+
@passed = Skip === e
|
1303
1307
|
time = Time.now - start_time
|
1304
1308
|
runner.record self.class, self.__name__, self._assertions, time, e
|
1305
1309
|
result = runner.puke self.class, self.__name__, e
|
@@ -1325,11 +1329,11 @@ module MiniTest
|
|
1325
1329
|
@__name__ = name
|
1326
1330
|
@__io__ = nil
|
1327
1331
|
@passed = nil
|
1328
|
-
@@current = self
|
1332
|
+
@@current = self # FIX: make thread local
|
1329
1333
|
end
|
1330
1334
|
|
1331
1335
|
def self.current # :nodoc:
|
1332
|
-
@@current
|
1336
|
+
@@current # FIX: make thread local
|
1333
1337
|
end
|
1334
1338
|
|
1335
1339
|
##
|
@@ -44,6 +44,22 @@ class TestMiniTestBenchmark < MiniTest::Unit::TestCase
|
|
44
44
|
assert_fit :exponential, x, y, 0.95, 13.81148, -0.1820
|
45
45
|
end
|
46
46
|
|
47
|
+
def test_fit_logarithmic_clean
|
48
|
+
x = [1.0, 2.0, 3.0, 4.0, 5.0]
|
49
|
+
y = x.map { |n| 1.1 + 2.1 * Math.log(n) }
|
50
|
+
|
51
|
+
assert_fit :logarithmic, x, y, 1.0, 1.1, 2.1
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_fit_logarithmic_noisy
|
55
|
+
x = [1.0, 2.0, 3.0, 4.0, 5.0]
|
56
|
+
# Generated with
|
57
|
+
# y = x.map { |n| jitter = 0.999 + 0.002 * rand; (Math.log(n) ) * jitter }
|
58
|
+
y = [0.0, 0.6935, 1.0995, 1.3873, 1.6097]
|
59
|
+
|
60
|
+
assert_fit :logarithmic, x, y, 0.95, 0, 1
|
61
|
+
end
|
62
|
+
|
47
63
|
def test_fit_constant_clean
|
48
64
|
x = (1..5).to_a
|
49
65
|
y = [5.0, 5.0, 5.0, 5.0, 5.0]
|
@@ -172,42 +172,22 @@ class TestMiniTestUnit < MetaMetaMetaTestCase
|
|
172
172
|
assert_instance_of MiniTest::Unit, MiniTest::Unit.runner
|
173
173
|
end
|
174
174
|
|
175
|
-
def with_overridden_include
|
176
|
-
Class.class_eval do
|
177
|
-
def inherited_with_hacks klass
|
178
|
-
throw :inherited_hook
|
179
|
-
end
|
180
175
|
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
yield
|
187
|
-
ensure
|
188
|
-
Class.class_eval do
|
189
|
-
alias inherited inherited_without_hacks
|
190
|
-
|
191
|
-
undef_method :inherited_with_hacks
|
192
|
-
undef_method :inherited_without_hacks
|
176
|
+
def test_passed_eh_teardown_good
|
177
|
+
test_class = Class.new MiniTest::Unit::TestCase do
|
178
|
+
def teardown; assert true; end
|
179
|
+
def test_omg; assert true; end
|
193
180
|
end
|
194
181
|
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
def test_inherited_hook_plays_nice_with_others
|
200
|
-
with_overridden_include do
|
201
|
-
assert_throws :inherited_hook do
|
202
|
-
Class.new MiniTest::Unit::TestCase
|
203
|
-
end
|
204
|
-
end
|
182
|
+
test = test_class.new :test_omg
|
183
|
+
test.run @tu
|
184
|
+
assert test.passed?
|
205
185
|
end
|
206
186
|
|
207
|
-
def
|
187
|
+
def test_passed_eh_teardown_skipped
|
208
188
|
test_class = Class.new MiniTest::Unit::TestCase do
|
209
189
|
def teardown; assert true; end
|
210
|
-
def test_omg;
|
190
|
+
def test_omg; skip "bork"; end
|
211
191
|
end
|
212
192
|
|
213
193
|
test = test_class.new :test_omg
|
@@ -235,6 +215,40 @@ class TestMiniTestUnit < MetaMetaMetaTestCase
|
|
235
215
|
end
|
236
216
|
end
|
237
217
|
|
218
|
+
class TestMiniTestUnitInherited < MetaMetaMetaTestCase
|
219
|
+
def with_overridden_include
|
220
|
+
Class.class_eval do
|
221
|
+
def inherited_with_hacks klass
|
222
|
+
throw :inherited_hook
|
223
|
+
end
|
224
|
+
|
225
|
+
alias inherited_without_hacks inherited
|
226
|
+
alias inherited inherited_with_hacks
|
227
|
+
alias IGNORE_ME! inherited # 1.8 bug. god I love venture bros
|
228
|
+
end
|
229
|
+
|
230
|
+
yield
|
231
|
+
ensure
|
232
|
+
Class.class_eval do
|
233
|
+
alias inherited inherited_without_hacks
|
234
|
+
|
235
|
+
undef_method :inherited_with_hacks
|
236
|
+
undef_method :inherited_without_hacks
|
237
|
+
end
|
238
|
+
|
239
|
+
refute_respond_to Class, :inherited_with_hacks
|
240
|
+
refute_respond_to Class, :inherited_without_hacks
|
241
|
+
end
|
242
|
+
|
243
|
+
def test_inherited_hook_plays_nice_with_others
|
244
|
+
with_overridden_include do
|
245
|
+
assert_throws :inherited_hook do
|
246
|
+
Class.new MiniTest::Unit::TestCase
|
247
|
+
end
|
248
|
+
end
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
238
252
|
class TestMiniTestRunner < MetaMetaMetaTestCase
|
239
253
|
# do not parallelize this suite... it just can't handle it.
|
240
254
|
|
@@ -658,7 +672,9 @@ class TestMiniTestUnitOrder < MetaMetaMetaTestCase
|
|
658
672
|
end
|
659
673
|
|
660
674
|
class TestMiniTestUnitTestCase < MiniTest::Unit::TestCase
|
661
|
-
parallelize_me!
|
675
|
+
# do not call parallelize_me! - teardown accesses @tc._assertions
|
676
|
+
# which is not threadsafe. Nearly every method in here is an
|
677
|
+
# assertion test so it isn't worth splitting it out further.
|
662
678
|
|
663
679
|
RUBY18 = ! defined? Encoding
|
664
680
|
|
@@ -1402,6 +1418,36 @@ class TestMiniTestUnitTestCase < MiniTest::Unit::TestCase
|
|
1402
1418
|
assert_equal "blah2.", @tc.message("") { "blah2" }.call
|
1403
1419
|
assert_equal "blah1.\nblah2.", @tc.message(:blah1) { "blah2" }.call
|
1404
1420
|
assert_equal "blah1.\nblah2.", @tc.message("blah1") { "blah2" }.call
|
1421
|
+
|
1422
|
+
message = proc { "blah1" }
|
1423
|
+
assert_equal "blah1.\nblah2.", @tc.message(message) { "blah2" }.call
|
1424
|
+
|
1425
|
+
message = @tc.message { "blah1" }
|
1426
|
+
assert_equal "blah1.\nblah2.", @tc.message(message) { "blah2" }.call
|
1427
|
+
end
|
1428
|
+
|
1429
|
+
def test_message_message
|
1430
|
+
util_assert_triggered "whoops.\nExpected: 1\n Actual: 2" do
|
1431
|
+
@tc.assert_equal 1, 2, message { "whoops" }
|
1432
|
+
end
|
1433
|
+
end
|
1434
|
+
|
1435
|
+
def test_message_lambda
|
1436
|
+
util_assert_triggered "whoops.\nExpected: 1\n Actual: 2" do
|
1437
|
+
@tc.assert_equal 1, 2, lambda { "whoops" }
|
1438
|
+
end
|
1439
|
+
end
|
1440
|
+
|
1441
|
+
def test_message_deferred
|
1442
|
+
@assertion_count, var = 0, nil
|
1443
|
+
|
1444
|
+
msg = message { var = "blah" }
|
1445
|
+
|
1446
|
+
assert_nil var
|
1447
|
+
|
1448
|
+
msg.call
|
1449
|
+
|
1450
|
+
assert_equal "blah", var
|
1405
1451
|
end
|
1406
1452
|
|
1407
1453
|
def test_pass
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minitest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 47
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 4
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 4.
|
8
|
+
- 4
|
9
|
+
- 0
|
10
|
+
version: 4.4.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ryan Davis
|
@@ -36,7 +36,7 @@ cert_chain:
|
|
36
36
|
FBHgymkyj/AOSqKRIpXPhjC6
|
37
37
|
-----END CERTIFICATE-----
|
38
38
|
|
39
|
-
date:
|
39
|
+
date: 2013-01-08 00:00:00 Z
|
40
40
|
dependencies:
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rdoc
|
@@ -61,11 +61,11 @@ dependencies:
|
|
61
61
|
requirements:
|
62
62
|
- - ~>
|
63
63
|
- !ruby/object:Gem::Version
|
64
|
-
hash:
|
64
|
+
hash: 15
|
65
65
|
segments:
|
66
66
|
- 3
|
67
|
-
-
|
68
|
-
version: "3.
|
67
|
+
- 4
|
68
|
+
version: "3.4"
|
69
69
|
type: :development
|
70
70
|
version_requirements: *id002
|
71
71
|
description: |-
|
metadata.gz.sig
CHANGED
Binary file
|