spec 5.0.19 → 5.3.3

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.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/History.txt +106 -0
  3. data/Manifest.txt +1 -1
  4. data/README.txt +83 -37
  5. data/Rakefile +3 -56
  6. data/lib/minitest.rb +58 -156
  7. data/lib/minitest/assertions.rb +13 -1
  8. data/lib/minitest/benchmark.rb +3 -3
  9. data/lib/minitest/hell.rb +1 -1
  10. data/lib/minitest/mock.rb +2 -2
  11. data/lib/minitest/parallel.rb +40 -0
  12. data/lib/minitest/pride_plugin.rb +1 -2
  13. data/lib/minitest/spec.rb +23 -22
  14. data/lib/minitest/test.rb +19 -8
  15. data/lib/spec.rb +156 -2
  16. data/readme.md +1 -1
  17. data/spec.gemspec +2 -2
  18. data/test/manual/simple.rb +10 -15
  19. data/test/minitest/metametameta.rb +4 -2
  20. data/test/minitest/test_minitest_benchmark.rb +7 -1
  21. data/test/minitest/test_minitest_mock.rb +12 -2
  22. data/test/minitest/test_minitest_reporter.rb +0 -1
  23. data/test/minitest/test_minitest_spec.rb +41 -4
  24. data/test/minitest/test_minitest_unit.rb +38 -20
  25. metadata +15 -37
  26. data/lib/minitest/parallel_each.rb +0 -120
  27. data/release_notes.md +0 -80
  28. data/test/manual/after_run.rb +0 -17
  29. data/test/manual/appium.rb +0 -14
  30. data/test/manual/appium_after_last.rb +0 -24
  31. data/test/manual/appium_before_first.rb +0 -23
  32. data/test/manual/assert.rb +0 -61
  33. data/test/manual/before_first_0.rb +0 -27
  34. data/test/manual/before_first_1.rb +0 -29
  35. data/test/manual/ctrl_c.rb +0 -11
  36. data/test/manual/debug.rb +0 -37
  37. data/test/manual/do_end.rb +0 -31
  38. data/test/manual/raise.rb +0 -61
  39. data/test/manual/run2.rb +0 -74
  40. data/test/manual/run3.rb +0 -91
  41. data/test/manual/setup.rb +0 -13
  42. data/test/manual/simple2.rb +0 -20
  43. data/test/manual/skip.rb +0 -15
  44. data/test/manual/t.rb +0 -11
  45. data/test/manual/trace.rb +0 -19
  46. data/test/manual/trace2.rb +0 -15
  47. data/test/minitest/test_helper.rb +0 -20
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5038d9de846696ce5a2f21796e96617307552236
4
- data.tar.gz: ccc9abc1332c91214faa8d35e3c89cb22976ea55
3
+ metadata.gz: 1862a5647d9edb8c300deb03b6bf21cb4d8d85e1
4
+ data.tar.gz: 8184a4a78143f820d7132ea83f9d0186e332030f
5
5
  SHA512:
6
- metadata.gz: 7da9864a71d17f68ce58d957099918028d03b19a4bcc80961b4aa5397e14867db34c18f44a8a7ddb0dc5681f84b03b9547a0c59b49e98454cf58c9c7cafea731
7
- data.tar.gz: 18330a6e213562aed882a7a31bec0d7b80607c3077375fa3fe62adf46d109debce732098ebe926d2fb843b7325116ac002009e210aa41412924c6adffc12ed90
6
+ metadata.gz: 6563324e7b8f500574e347eb5e8abb9a61a08d80d5b986435848af1a3792cd63344d503c6c63ad591433f1d3d478e9be6ca53514199b13b36a3022697677d3e3
7
+ data.tar.gz: 2389dde6619ec0fd846ba0fe8e17e0f905e7d4be40b6f4f5198e06187b766f613727375aff3839a12472077b9524adf8fad708afd0a24a2a971f07966b396562
@@ -1,3 +1,87 @@
1
+ === 5.3.3 / 2014-04-14
2
+
3
+ * 1 bug fix:
4
+
5
+ * Fixed using expectations w/ DSL in Test class w/o describe. (blowmage+others)
6
+
7
+ === 5.3.2 / 2014-04-02
8
+
9
+ * 1 bug fix:
10
+
11
+ * Fixed doco on Assertions.assertions. (xaviershay)
12
+
13
+ === 5.3.1 / 2014-03-14
14
+
15
+ * 1 minor enhancement:
16
+
17
+ * Modified verbage on bad 'let' names to be more helpful. (Archytaus)
18
+
19
+ * 1 bug fix:
20
+
21
+ * Fixed 2 cases still using MiniTest. (mikesea)
22
+
23
+ === 5.3.0 / 2014-02-25
24
+
25
+ * 1 minor enhancement:
26
+
27
+ * Mocked methods can take a block to verify state. Seattle.rb 12 bday present from ernie! Thanks!!
28
+
29
+ === 5.2.3 / 2014-02-10
30
+
31
+ * 1 bug fix:
32
+
33
+ * Fixed Spec#let check to allow overriding of other lets. (mvz)
34
+
35
+ === 5.2.2 / 2014-01-22
36
+
37
+ * 1 minor enhancement:
38
+
39
+ * Spec#let raises ArgumentError if you override _any_ instance method (except subject). (rynr)
40
+
41
+ * 1 bug fix:
42
+
43
+ * Fixed up benchmark spec doco and added a test to demonstrate. (bhenderson)
44
+
45
+ === 5.2.1 / 2014-01-07
46
+
47
+ * 1 bug fix:
48
+
49
+ * Properly deal with horrible mix of runtime load errors + other at_exit handlers. (dougo/chqr)
50
+
51
+ === 5.2.0 / 2013-12-13
52
+
53
+ * 1 minor enhancement:
54
+
55
+ * Change expectations to allow calling most on procs (but not calling the proc). (bhenderson+others)
56
+
57
+ === 5.1.0 / 2013-12-05
58
+
59
+ * 1 minor enhancement:
60
+
61
+ * Use a Queue for scheduling parallel tests. (tenderlove)
62
+
63
+ * 1 bug fix:
64
+
65
+ * Fixed misspelling in doco. (amatsuda)
66
+
67
+ === 5.0.8 / 2013-09-20
68
+
69
+ * 1 bug fix:
70
+
71
+ * Fixed siginfo handler by rearranging reporters and fixing to_s. (tenderlove)
72
+
73
+ === 5.0.7 / 2013-09-05
74
+
75
+ * 2 minor enhancements:
76
+
77
+ * Added clarification about the use of thread local variables in expectations. (jemc)
78
+ * Added extra message about skipped tests, if any. Disable globally with $MT_NO_SKIP_MSG.
79
+
80
+ * 2 bug fixes:
81
+
82
+ * Only require minitest, not minitest/autorun in pride_plugin. (judofyr)
83
+ * Require rubygems in load_plugins in case you're not using minitest/autorun.
84
+
1
85
  === 5.0.6 / 2013-06-28
2
86
 
3
87
  * 3 minor enhancements:
@@ -10,6 +94,13 @@
10
94
 
11
95
  * Fixed missing require in minitest/test. (erikh)
12
96
 
97
+ === 4.7.5 / 2013-06-21
98
+
99
+ * 2 bug fixes:
100
+
101
+ * Fix Spec#describe_stack to be thread local.
102
+ * Fix multithreaded test failures by defining Time local to mock test namespace
103
+
13
104
  === 5.0.5 / 2013-06-20
14
105
 
15
106
  * 6 bug fixes:
@@ -128,6 +219,21 @@ Minitest 5:
128
219
  * Removed Minitest::Test.synchronize (phiggins)
129
220
  * Upon loading minitest/parallel_each, record, capture_io and capture_subprocess_io are doped with synchronization code. (phiggins)
130
221
 
222
+ === 4.7.4 / 2013-05-01
223
+
224
+ This is probably the last release of the 4.x series. It will be merged
225
+ to ruby and will be put into maintenance mode there.
226
+
227
+ I'm not set in stone on this, but at this point further development of
228
+ minitest (5+) will be gem-only. It is just too hard to work w/in
229
+ ruby-core w/ test-unit compatibility holding minitest development
230
+ back.
231
+
232
+ * 2 minor enhancements:
233
+
234
+ * Added count/size to ParallelEach to fix use w/in stdlib's test/unit. :( (btaitelb)
235
+ * Allow disabling of info_signal handler in runner. (erikh)
236
+
131
237
  === 4.7.3 / 2013-04-20
132
238
 
133
239
  * 1 bug fix:
@@ -12,7 +12,7 @@ lib/minitest/benchmark.rb
12
12
  lib/minitest/expectations.rb
13
13
  lib/minitest/hell.rb
14
14
  lib/minitest/mock.rb
15
- lib/minitest/parallel_each.rb
15
+ lib/minitest/parallel.rb
16
16
  lib/minitest/pride.rb
17
17
  lib/minitest/pride_plugin.rb
18
18
  lib/minitest/spec.rb
data/README.txt CHANGED
@@ -3,6 +3,7 @@
3
3
  home :: https://github.com/seattlerb/minitest
4
4
  rdoc :: http://docs.seattlerb.org/minitest
5
5
  vim :: https://github.com/sunaku/vim-ruby-minitest
6
+ emacs:: https://github.com/arthurnn/minitest-emacs
6
7
 
7
8
  == DESCRIPTION:
8
9
 
@@ -90,6 +91,8 @@ Given that you'd like to test the following class:
90
91
 
91
92
  === Unit tests
92
93
 
94
+ Define your tests as methods beginning with `test_`.
95
+
93
96
  require "minitest/autorun"
94
97
 
95
98
  class TestMeme < Minitest::Test
@@ -366,62 +369,105 @@ you want to extend your test using setup/teardown via a module, just
366
369
  make sure you ALWAYS call super. before/after automatically call super
367
370
  for you, so make sure you don't do it twice.
368
371
 
372
+ == Prominent Projects using Minitest:
373
+
374
+ * arel
375
+ * journey
376
+ * mime-types
377
+ * nokogiri
378
+ * rails (active_support et al)
379
+ * rake
380
+ * rdoc
381
+ * ...and of course, everything from seattle.rb...
382
+
369
383
  == Known Extensions:
370
384
 
371
- capybara_minitest_spec :: Bridge between Capybara RSpec matchers and MiniTest::Spec expectations (e.g. page.must_have_content("Title")).
385
+ capybara_minitest_spec :: Bridge between Capybara RSpec matchers and
386
+ Minitest::Spec expectations (e.g.
387
+ page.must_have_content("Title")).
372
388
  minispec-metadata :: Metadata for describe/it blocks
373
389
  (e.g. `it "requires JS driver", js: true do`)
374
390
  minitest-ansi :: Colorize minitest output with ANSI colors.
375
- minitest-around :: Around block for minitest. An alternative to setup/teardown dance.
376
- minitest-capistrano :: Assertions and expectations for testing Capistrano recipes
377
- minitest-capybara :: Capybara matchers support for minitest unit and spec
391
+ minitest-around :: Around block for minitest. An alternative to
392
+ setup/teardown dance.
393
+ minitest-capistrano :: Assertions and expectations for testing
394
+ Capistrano recipes.
395
+ minitest-capybara :: Capybara matchers support for minitest unit and
396
+ spec.
378
397
  minitest-chef-handler :: Run Minitest suites as Chef report handlers
379
- minitest-ci :: CI reporter plugin for MiniTest.
380
- minitest-colorize :: Colorize MiniTest output and show failing tests instantly.
381
- minitest-context :: Defines contexts for code reuse in MiniTest
398
+ minitest-ci :: CI reporter plugin for Minitest.
399
+ minitest-colorize :: Colorize Minitest output and show failing tests
400
+ instantly.
401
+ minitest-context :: Defines contexts for code reuse in Minitest
382
402
  specs that share common expectations.
383
403
  minitest-debugger :: Wraps assert so failed assertions drop into
384
404
  the ruby debugger.
385
- minitest-display :: Patches MiniTest to allow for an easily configurable output.
386
- minitest-emoji :: Print out emoji for your test passes, fails, and skips.
387
- minitest-english :: Semantically symmetric aliases for assertions and expectations.
405
+ minitest-display :: Patches Minitest to allow for an easily
406
+ configurable output.
407
+ minitest-documentation :: Minimal documentation format inspired by rspec's.
408
+ minitest-doc_reporter :: Detailed output inspired by rspec's documentation
409
+ format.
410
+ minitest-emoji :: Print out emoji for your test passes, fails, and
411
+ skips.
412
+ minitest-english :: Semantically symmetric aliases for assertions and
413
+ expectations.
388
414
  minitest-excludes :: Clean API for excluding certain tests you
389
415
  don't want to run under certain conditions.
390
- minitest-filesystem :: Adds assertion and expectation to help testing filesystem contents.
391
- minitest-firemock :: Makes your MiniTest mocks more resilient.
392
- minitest-great_expectations :: Generally useful additions to minitest's assertions and expectations
416
+ minitest-filesystem :: Adds assertion and expectation to help testing
417
+ filesystem contents.
418
+ minitest-firemock :: Makes your Minitest mocks more resilient.
419
+ minitest-great_expectations :: Generally useful additions to minitest's
420
+ assertions and expectations.
393
421
  minitest-growl :: Test notifier for minitest via growl.
394
422
  minitest-implicit-subject :: Implicit declaration of the test subject.
395
423
  minitest-instrument :: Instrument ActiveSupport::Notifications when
396
- test method is executed
397
- minitest-instrument-db :: Store information about speed of test
398
- execution provided by minitest-instrument in database
424
+ test method is executed.
425
+ minitest-instrument-db :: Store information about speed of test execution
426
+ provided by minitest-instrument in database.
399
427
  minitest-libnotify :: Test notifier for minitest via libnotify.
400
- minitest-line :: Run test at line number
401
- minitest-macruby :: Provides extensions to minitest for macruby UI testing.
402
- minitest-matchers :: Adds support for RSpec-style matchers to minitest.
428
+ minitest-line :: Run test at line number.
429
+ minitest-macruby :: Provides extensions to minitest for macruby UI
430
+ testing.
431
+ minitest-matchers :: Adds support for RSpec-style matchers to
432
+ minitest.
403
433
  minitest-metadata :: Annotate tests with metadata (key-value).
404
- minitest-mongoid :: Mongoid assertion matchers for MiniTest
405
- minitest-must_not :: Provides must_not as an alias for wont in MiniTest
406
- minitest-nc :: Test notifier for minitest via Mountain Lion's Notification Center
407
- minitest-predicates :: Adds support for .predicate? methods
408
- minitest-rails :: MiniTest integration for Rails 3.x
409
- minitest-rails-capybara :: Capybara integration for MiniTest::Rails
410
- minitest-reporters :: Create customizable MiniTest output formats
411
- minitest-should_syntax :: RSpec-style +x.should == y+ assertions for MiniTest
412
- minitest-shouldify :: Adding all manner of shoulds to MiniTest (bad idea)
413
- minitest-spec-context :: Provides rspec-ish context method to MiniTest::Spec
414
- minitest-spec-expect :: Expect syntax for MiniTest::Spec - expect(sequences).to_include :celery_man
415
- minitest-spec-magic :: Minitest::Spec extensions for Rails and beyond
416
- minitest-spec-rails :: Drop in MiniTest::Spec superclass for ActiveSupport::TestCase.
417
- minitest-stub-const :: Stub constants for the duration of a block
418
- minitest-tags :: add tags for minitest
434
+ minitest-mongoid :: Mongoid assertion matchers for Minitest.
435
+ minitest-must_not :: Provides must_not as an alias for wont in
436
+ Minitest.
437
+ minitest-nc :: Test notifier for minitest via Mountain Lion's
438
+ Notification Center.
439
+ minitest-predicates :: Adds support for .predicate? methods.
440
+ minitest-rails :: Minitest integration for Rails 3.x.
441
+ minitest-rails-capybara :: Capybara integration for Minitest::Rails.
442
+ minitest-reporters :: Create customizable Minitest output formats.
443
+ minitest-rg :: Colored red/green output for Minitest.
444
+ minitest-rspec_mocks :: Use RSpec Mocks with Minitest.
445
+ minitest-should_syntax :: RSpec-style +x.should == y+ assertions for
446
+ Minitest.
447
+ minitest-shouldify :: Adding all manner of shoulds to Minitest (bad
448
+ idea)
449
+ minitest-spec-context :: Provides rspec-ish context method to
450
+ Minitest::Spec.
451
+ minitest-spec-expect :: Expect syntax for Minitest::Spec (e.g.
452
+ expect(sequences).to_include :celery_man).
453
+ minitest-spec-magic :: Minitest::Spec extensions for Rails and beyond.
454
+ minitest-spec-rails :: Drop in Minitest::Spec superclass for
455
+ ActiveSupport::TestCase.
456
+ minitest-stub_any_instance :: Stub any instance of a method on the given class
457
+ for the duration of a block.
458
+ minitest-stub-const :: Stub constants for the duration of a block.
459
+ minitest-tags :: Add tags for minitest.
460
+ minitest-vcr :: Automatic cassette managment with Minitest::Spec
461
+ and VCR.
419
462
  minitest-wscolor :: Yet another test colorizer.
420
463
  minitest_owrapper :: Get tests results as a TestResult object.
421
464
  minitest_should :: Shoulda style syntax for minitest test::unit.
422
- minitest_tu_shim :: minitest_tu_shim bridges between test/unit and minitest.
423
- mongoid-minitest :: MiniTest matchers for Mongoid.
424
- pry-rescue :: A pry plugin w/ minitest support. See pry-rescue/minitest.rb.
465
+ minitest_tu_shim :: Bridges between test/unit and minitest.
466
+ mongoid-minitest :: Minitest matchers for Mongoid.
467
+ pry-rescue :: A pry plugin w/ minitest support. See
468
+ pry-rescue/minitest.rb.
469
+ rspec2minitest :: Easily translate any RSpec matchers to Minitest
470
+ assertions and expectations.
425
471
 
426
472
  == Unknown Extensions:
427
473
 
data/Rakefile CHANGED
@@ -1,5 +1,3 @@
1
- # -*- ruby -*-
2
-
3
1
  require 'rubygems'
4
2
  require 'hoe'
5
3
 
@@ -8,63 +6,11 @@ Hoe.plugin :seattlerb
8
6
  Hoe.spec 'minitest' do
9
7
  developer 'Ryan Davis', 'ryand-ruby@zenspider.com'
10
8
 
11
- self.rubyforge_name = "bfts"
12
- self.testlib = :minitest
13
- self.licenses = [ 'MIT' ]
14
- end
9
+ license "MIT"
15
10
 
16
- desc "Find missing expectations"
17
- task :specs do
18
- $:.unshift "lib"
19
- require "minitest/unit"
20
- require "minitest/spec"
21
-
22
- pos_prefix, neg_prefix = "must", "wont"
23
- skip_re = /^(must|wont)$|wont_(throw)|must_(block|not?_|nothing|raise$)/x
24
- dont_flip_re = /(must|wont)_(include|respond_to)/
25
-
26
- map = {
27
- /(must_throw)s/ => '\1',
28
- /(?!not)_same/ => '_be_same_as',
29
- /_in_/ => '_be_within_',
30
- /_operator/ => '_be',
31
- /_includes/ => '_include',
32
- /(must|wont)_(.*_of|nil|silent|empty)/ => '\1_be_\2',
33
- /must_raises/ => 'must_raise',
34
- }
35
-
36
- expectations = Minitest::Expectations.public_instance_methods.map(&:to_s)
37
- assertions = Minitest::Assertions.public_instance_methods.map(&:to_s)
38
-
39
- assertions.sort.each do |assertion|
40
- expectation = case assertion
41
- when /^assert/ then
42
- assertion.sub(/^assert/, pos_prefix.to_s)
43
- when /^refute/ then
44
- assertion.sub(/^refute/, neg_prefix.to_s)
45
- end
46
-
47
- next unless expectation
48
- next if expectation =~ skip_re
49
-
50
- regexp, replacement = map.find { |re, _| expectation =~ re }
51
- expectation.sub! regexp, replacement if replacement
52
-
53
- next if expectations.include? expectation
54
-
55
- args = [assertion, expectation].map(&:to_sym).map(&:inspect)
56
- args << :reverse if expectation =~ dont_flip_re
57
-
58
- puts
59
- puts "##"
60
- puts "# :method: #{expectation}"
61
- puts "# See Minitest::Assertions##{assertion}"
62
- puts
63
- puts "infect_an_assertion #{args.join ", "}"
64
- end
11
+ self.testlib = :minitest
65
12
  end
66
13
 
67
- # vim: syntax=Ruby
68
14
 
69
15
  # from https://github.com/bootstraponline/gem_template
70
16
  # todo: publish gem_template as a gem
@@ -73,6 +19,7 @@ end
73
19
  require 'rubygems'
74
20
  require 'rake'
75
21
  require 'date'
22
+ require_relative 'lib/minitest'
76
23
 
77
24
  # Defines gem name.
78
25
  def repo_name; 'spec' end # rubygems.org name
@@ -1,12 +1,14 @@
1
1
  require "optparse"
2
- require 'chronic_duration'
2
+ require "thread"
3
+ require "mutex_m"
4
+ require "minitest/parallel"
3
5
 
4
6
  ##
5
7
  # :include: README.txt
6
8
 
7
9
  module Minitest
8
- VERSION = '5.0.19' # :nodoc:
9
- DATE = '2013-08-19' # :nodoc:
10
+ VERSION = '5.3.3' # :nodoc:
11
+ DATE = '2014-04-21' # :nodoc:
10
12
 
11
13
  @@installed_at_exit ||= false
12
14
  @@after_run = []
@@ -14,6 +16,12 @@ module Minitest
14
16
 
15
17
  mc = (class << self; self; end)
16
18
 
19
+ ##
20
+ # Parallel test executor
21
+
22
+ mc.send :attr_accessor, :parallel_executor
23
+ self.parallel_executor = Parallel::Executor.new((ENV['N'] || 2).to_i)
24
+
17
25
  ##
18
26
  # Filter object for backtraces.
19
27
 
@@ -36,7 +44,7 @@ module Minitest
36
44
 
37
45
  def self.autorun
38
46
  at_exit {
39
- next if $! and not $!.kind_of? SystemExit
47
+ next if $! and not ($!.kind_of? SystemExit and $!.success?)
40
48
 
41
49
  exit_code = nil
42
50
 
@@ -72,6 +80,8 @@ module Minitest
72
80
 
73
81
  seen = {}
74
82
 
83
+ require "rubygems" unless defined? Gem
84
+
75
85
  Gem.find_files("minitest/*_plugin.rb").each do |plugin_path|
76
86
  name = File.basename plugin_path, "_plugin.rb"
77
87
 
@@ -92,11 +102,13 @@ module Minitest
92
102
  #
93
103
  # Minitest.autorun
94
104
  # Minitest.run(args)
95
- # __run(reporter, options)
105
+ # Minitest.__run(reporter, options)
96
106
  # Runnable.runnables.each
97
107
  # runnable.run(reporter, options)
98
108
  # self.runnable_methods.each
99
- # self.new(runnable_method).run
109
+ # self.run_one_method(self, runnable_method, reporter)
110
+ # Minitest.run_one_method(klass, runnable_method, reporter)
111
+ # klass.new(runnable_method).run
100
112
 
101
113
  def self.run args = []
102
114
  self.load_plugins
@@ -104,8 +116,8 @@ module Minitest
104
116
  options = process_args args
105
117
 
106
118
  reporter = CompositeReporter.new
107
- reporter << ProgressReporter.new(options[:io], options)
108
119
  reporter << SummaryReporter.new(options[:io], options)
120
+ reporter << ProgressReporter.new(options[:io], options)
109
121
 
110
122
  self.reporter = reporter # this makes it available to plugins
111
123
  self.init_plugins options
@@ -113,6 +125,7 @@ module Minitest
113
125
 
114
126
  reporter.start
115
127
  __run reporter, options
128
+ self.parallel_executor.shutdown
116
129
  reporter.report
117
130
 
118
131
  reporter.passed?
@@ -126,88 +139,22 @@ module Minitest
126
139
  # loaded if a Runnable calls parallelize_me!.
127
140
 
128
141
  def self.__run reporter, options
129
- Runnable.runnables.each do |runnable|
130
- runnable.run reporter, options
131
- end
132
- end
133
-
134
- ##
135
- # Trace file source to :io (default $stdout)
136
- #
137
- # spec_opts = {}
138
- #
139
- # @param :trace [Array<String>] the files to trace
140
- # @param :io [IO] io to print to
141
- def self.trace_specs spec_opts
142
- targets = []
143
- files = {}
144
- last_file = ''
145
- last_line = -1
146
-
147
- files_to_trace = spec_opts.fetch(:trace, []);
148
- io = spec_opts.fetch(:io, $stdout)
149
- color = spec_opts.fetch(:color, "\e[32m") # ANSI.green default
150
- # target only existing readable files
151
- files_to_trace.each do |f|
152
- targets.push(File.expand_path(f)) if File.exists?(f) && File.readable?(f)
153
- end
154
- return if targets.empty?
155
-
156
- set_trace_func(lambda do |event, file, line, id, binding, classname|
157
- return unless targets.include? file
158
-
159
- # never repeat a line
160
- return if file == last_file && line == last_line
161
-
162
- file_sym = file.intern
163
- files[file_sym] = IO.readlines(file) if files[file_sym].nil?
164
- lines = files[file_sym]
165
-
166
- # arrays are 0 indexed and line numbers start at one.
167
- io.print color if color # ANSI code
168
- io.puts lines[ line - 1]
169
- io.print "\e[0m" if color # ANSI.clear
170
-
171
- last_file = file
172
- last_line = line
173
-
174
- end)
175
- end
176
-
177
- def self.on_exit exit_code
178
- @@after_run.reverse_each(&:call)
179
- exit exit_code || false
180
- end
181
-
182
- ##
183
- # Run specs. Does not print dots (ProgressReporter)
184
- #
185
- # spec_opts
186
- # @param :io [Array<String>] defaults to $stdout
187
- # @param :trace [Array<String>] files to trace
188
-
189
- def self.run_specs spec_opts={}
190
- options = { :io => spec_opts.fetch(:io, $stdout) }
191
- reporter = Minitest::CompositeReporter.new
192
- reporter << Minitest::SummaryReporter.new(options[:io], options)
193
- reporter.start
194
-
195
- at_exit { on_exit reporter.passed? }
196
- # exit on ctrl+c to trigger at_exit
197
- trap('SIGINT') { exit }
198
-
199
- trace_specs spec_opts
200
-
201
- begin
202
- Minitest.__run reporter, options
203
- reporter.reporters.each { |r| r.report }
204
- rescue Minitest::Runnable::ExitAfterFirstFail
205
- # Minitest calls .report on exception
206
- end
142
+ suites = Runnable.runnables
143
+ parallel, serial = suites.partition { |s| s.test_order == :parallel }
144
+
145
+ # If we run the parallel tests before the serial tests, the parallel tests
146
+ # could run in parallel with the serial tests. This would be bad because
147
+ # the serial tests won't lock around Reporter#record. Run the serial tests
148
+ # first, so that after they complete, the parallel tests will lock when
149
+ # recording results.
150
+ serial.map { |suite| suite.run reporter, options } +
151
+ parallel.map { |suite| suite.run reporter, options }
207
152
  end
208
153
 
209
154
  def self.process_args args = [] # :nodoc:
210
- options = { :io => $stdout }
155
+ options = {
156
+ :io => $stdout,
157
+ }
211
158
  orig_args = args.dup
212
159
 
213
160
  OptionParser.new do |opts|
@@ -323,27 +270,12 @@ module Minitest
323
270
 
324
271
  reset
325
272
 
326
- class ExitAfterFirstFail < RuntimeError; end
327
-
328
- def self.check_failures result, reporter
329
- # skip is not a failure.
330
- true_fails = result.failures.reject { |obj| obj.class == Minitest::Skip }
331
- if !true_fails.empty?
332
- begin
333
- reporter.reporters.each { |r| r.report }
334
- ensure
335
- raise ExitAfterFirstFail
336
- end
337
- end
338
- end
339
-
340
273
  ##
341
274
  # Responsible for running all runnable methods in a given class,
342
275
  # each in its own instance. Each instance is passed to the
343
276
  # reporter to record.
344
277
 
345
278
  def self.run reporter, options = {}
346
- io = options.fetch :io, $stdout
347
279
  filter = options[:filter] || '/./'
348
280
  filter = Regexp.new $1 if filter =~ /\/(.*)\//
349
281
 
@@ -351,64 +283,16 @@ module Minitest
351
283
  filter === m || filter === "#{self}##{m}"
352
284
  }
353
285
 
354
- begin
355
- # before_first
356
- method1 = self.new(filtered_methods.first)
357
- # run method and capture exceptions.
358
- method1.capture_exceptions do
359
- method1.before_first_method
360
- end
361
- # save exceptions to reporter and check for failures
362
- with_info_handler reporter do
363
- # only record if failures not empty, otherwise
364
- # the count (runs) are messed up. each call to .record
365
- # increases count by one.
366
- if !method1.failures.empty?
367
- reporter.record method1
368
- check_failures method1, reporter
369
- end
370
-
371
- # run the other methods
372
- filtered_methods.each do |method_name|
373
- method = self.new(method_name)
374
- matched_name = method_name.match /test_(\d+)_/
375
- if matched_name
376
- test_number = matched_name[1].to_i
377
- test_name = method_name.split(/_\d+_/).last
378
- file_path, line_number = method.method(method_name).source_location
379
- # /5/4/3/2/1/test.rb => 2/1/test.rb
380
- file_path = file_path.split(File::SEPARATOR).reject(&:empty?)
381
- file_path = (file_path.length >= 3 ? file_path[-3..-1] :
382
- file_path).join(File::SEPARATOR)
383
- # 36 = cyan, 0 = clear
384
- test_output_title = "\e[36m#{test_name} | #{test_number} |" +
385
- "#{file_path}:#{line_number}\e[0m"
386
- io.puts test_output_title
387
- end
388
- result = method.run
389
- raise "#{self}#run _must_ return self" unless self === result
390
- reporter.record result
391
- check_failures result, reporter
392
- end
393
- end
394
- ensure # ensure after last runs
395
- # after_last
396
- # init method1 again
397
- method1 = self.new(filtered_methods.first)
398
- method1.capture_exceptions do
399
- method1.after_last_method
400
- end
401
- with_info_handler reporter do
402
- if !method1.failures.empty?
403
- reporter.record method1
404
- check_failures method1, reporter
405
- end
286
+ with_info_handler reporter do
287
+ filtered_methods.each do |method_name|
288
+ run_one_method self, method_name, reporter
406
289
  end
407
290
  end
408
291
  end
409
292
 
410
- def before_first_method; end
411
- def after_last_method; end
293
+ def self.run_one_method klass, method_name, reporter
294
+ reporter.record Minitest.run_one_method(klass, method_name)
295
+ end
412
296
 
413
297
  def self.with_info_handler reporter, &block # :nodoc:
414
298
  handler = lambda do
@@ -507,6 +391,8 @@ module Minitest
507
391
  # you want. Go nuts.
508
392
 
509
393
  class AbstractReporter
394
+ include Mutex_m
395
+
510
396
  ##
511
397
  # Starts reporting on the run.
512
398
 
@@ -546,6 +432,7 @@ module Minitest
546
432
  attr_accessor :options
547
433
 
548
434
  def initialize io = $stdout, options = {} # :nodoc:
435
+ super()
549
436
  self.io = io
550
437
  self.options = options
551
438
  end
@@ -645,6 +532,11 @@ module Minitest
645
532
  def start # :nodoc:
646
533
  super
647
534
 
535
+ io.puts "Run options: #{options[:args]}"
536
+ io.puts
537
+ io.puts "# Running:"
538
+ io.puts
539
+
648
540
  self.sync = io.respond_to? :"sync=" # stupid emacs
649
541
  self.old_sync, io.sync = io.sync, true if self.sync
650
542
  end
@@ -662,7 +554,8 @@ module Minitest
662
554
  end
663
555
 
664
556
  def statistics # :nodoc:
665
- "Finished in #{ChronicDuration.output(total_time.round) || '0s'}"
557
+ "Finished in %.6fs, %.4f runs/s, %.4f assertions/s." %
558
+ [total_time, count / total_time, assertions / total_time]
666
559
  end
667
560
 
668
561
  def aggregated_results # :nodoc:
@@ -674,6 +567,8 @@ module Minitest
674
567
  end.join("\n") + "\n"
675
568
  end
676
569
 
570
+ alias to_s aggregated_results
571
+
677
572
  def summary # :nodoc:
678
573
  extra = ""
679
574
 
@@ -695,6 +590,7 @@ module Minitest
695
590
  attr_accessor :reporters
696
591
 
697
592
  def initialize *reporters # :nodoc:
593
+ super()
698
594
  self.reporters = reporters
699
595
  end
700
596
 
@@ -859,6 +755,12 @@ module Minitest
859
755
  end
860
756
 
861
757
  self.backtrace_filter = BacktraceFilter.new
758
+
759
+ def self.run_one_method klass, method_name # :nodoc:
760
+ result = klass.new(method_name).run
761
+ raise "#{klass}#run _must_ return self" unless klass === result
762
+ result
763
+ end
862
764
  end
863
765
 
864
766
  require "minitest/test"