m 1.3.3 → 1.3.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.travis.yml +8 -4
  4. data/Gemfile +1 -0
  5. data/README.md +11 -6
  6. data/Rakefile +10 -1
  7. data/benchmarks/20150430-benchmark.log +26 -0
  8. data/gemfiles/minitest4.gemfile +1 -1
  9. data/gemfiles/minitest4.gemfile.lock +30 -18
  10. data/gemfiles/minitest5.gemfile +1 -1
  11. data/gemfiles/minitest5.gemfile.lock +29 -17
  12. data/lib/m.rb +1 -271
  13. data/lib/m/executor.rb +101 -0
  14. data/lib/m/frameworks.rb +34 -0
  15. data/lib/m/parser.rb +74 -0
  16. data/lib/m/runner.rb +20 -0
  17. data/lib/m/runners/base.rb +17 -0
  18. data/lib/m/runners/minitest_4.rb +13 -0
  19. data/lib/m/runners/minitest_5.rb +17 -0
  20. data/lib/m/runners/test_unit.rb +13 -0
  21. data/lib/m/runners/unsupported_framework.rb +21 -0
  22. data/lib/m/testable.rb +15 -0
  23. data/lib/version.rb +1 -1
  24. data/m.gemspec +1 -1
  25. data/test/active_support_test.rb +17 -17
  26. data/test/bench.rb +25 -8
  27. data/test/empty_test.rb +1 -1
  28. data/test/everything_test.rb +11 -6
  29. data/test/examples/active_support_example_test.rb +0 -1
  30. data/test/examples/active_support_unescaped_example_test.rb +0 -1
  31. data/test/examples/empty_example_test.rb +2 -2
  32. data/test/examples/minitest_4_example_test.rb +4 -6
  33. data/test/examples/minitest_5_example_test.rb +4 -5
  34. data/test/examples/multiple_example_test.rb +0 -1
  35. data/test/examples/subdir/a_test.rb +2 -2
  36. data/test/examples/subdir/b_test.rb +2 -2
  37. data/test/examples/subdir/c_test.rb +2 -2
  38. data/test/examples/subdir_with_failures/a_test.rb +7 -0
  39. data/test/examples/test_unit_example_test.rb +12 -12
  40. data/test/minitest_4_test.rb +13 -13
  41. data/test/minitest_5_test.rb +6 -6
  42. data/test/multiple_test.rb +3 -3
  43. data/test/options_test.rb +6 -6
  44. data/test/test_helper.rb +13 -12
  45. data/test/test_unit_test.rb +29 -27
  46. metadata +13 -16
@@ -4,6 +4,6 @@ class EmptyTest < MTest
4
4
  def test_run_simple_test_by_line_number
5
5
  output = m('examples/empty_example_test.rb')
6
6
  assert !$?.success?
7
- assert_match /There were no tests found./, output
7
+ assert_match(/There were no tests found./, output)
8
8
  end
9
9
  end
@@ -3,26 +3,31 @@ require 'test_helper'
3
3
  class EverythingTest < MTest
4
4
  def test_runs_entire_test_suite_with_no_arguments
5
5
  output = m('')
6
- assert_output /14 tests/, output
6
+ assert_output(/12 tests/, output)
7
7
  end
8
8
 
9
9
  def test_missing_file_gives_a_decent_error_message
10
10
  output = m('examples/thisdoesnexist_test.rb')
11
11
  assert !$?.success?
12
- assert_match /Failed loading test file/, output
13
- assert_match /cannot load such file/, output
12
+ assert_match(/Failed loading test file/, output)
13
+ assert_match(/cannot load such file/, output)
14
14
  end
15
15
 
16
16
  def test_running_tests_within_a_subdirectory
17
17
  output = m('examples/subdir')
18
- assert_output /3 tests/, output
18
+ assert_output(/3 tests/, output)
19
19
 
20
20
  output = m('examples')
21
- assert_output /14 tests/, output
21
+ assert_output(/12 tests/, output)
22
+ end
23
+
24
+ def test_running_tests_with_failures_within_a_subdirectory
25
+ output = m('examples/subdir_with_failures')
26
+ assert_output(/1 tests, 1 assertions, 1 failures/, output)
22
27
  end
23
28
 
24
29
  def test_blank_file_is_quieter
25
30
  output = m('bananas')
26
- assert_no_match /Valid tests to run/, output
31
+ assert(/Valid tests to run/ !~ output)
27
32
  end
28
33
  end
@@ -1,4 +1,3 @@
1
- require 'test/unit'
2
1
  require 'active_support/test_case'
3
2
 
4
3
  class ActiveSupportExampleTest < ActiveSupport::TestCase
@@ -1,4 +1,3 @@
1
- require 'test/unit'
2
1
  require 'active_support/test_case'
3
2
 
4
3
  class ActiveSupportExampleTest < ActiveSupport::TestCase
@@ -1,4 +1,4 @@
1
- require 'test/unit'
1
+ require_relative '../test_helper'
2
2
 
3
- class EmptyExampleTest < Test::Unit::TestCase
3
+ class EmptyExampleTest < MTest
4
4
  end
@@ -1,6 +1,6 @@
1
1
  require 'minitest/unit'
2
- if M::Frameworks.minitest4?
3
2
 
3
+ if M::Frameworks.minitest4?
4
4
  class Meme
5
5
  def i_can_has_cheezburger?
6
6
  "OHAI!"
@@ -11,7 +11,6 @@ if M::Frameworks.minitest4?
11
11
  end
12
12
  end
13
13
 
14
-
15
14
  class TestMeme < MiniTest::Unit::TestCase
16
15
  def setup
17
16
  @meme = Meme.new
@@ -22,15 +21,14 @@ if M::Frameworks.minitest4?
22
21
  end
23
22
 
24
23
  def test_that_it_will_not_blend
25
- refute_match /^maybe/i, @meme.will_it_blend?
26
- refute_match /^no/i, @meme.will_it_blend?
27
- refute_match /^lolz/i, @meme.will_it_blend?
24
+ refute_match(/^maybe/i, @meme.will_it_blend?)
25
+ refute_match(/^no/i, @meme.will_it_blend?)
26
+ refute_match(/^lolz/i, @meme.will_it_blend?)
28
27
  end
29
28
 
30
29
  def test_that_kitty_can_eat_two_time
31
30
  assert_equal "OHAI!", @meme.i_can_has_cheezburger?
32
31
  assert_equal "OHAI!", @meme.i_can_has_cheezburger?
33
32
  end
34
-
35
33
  end
36
34
  end
@@ -1,4 +1,5 @@
1
1
  require 'minitest/autorun'
2
+
2
3
  if M::Frameworks.minitest5?
3
4
  class Meme
4
5
  def i_can_has_cheezburger?
@@ -10,7 +11,6 @@ if M::Frameworks.minitest5?
10
11
  end
11
12
  end
12
13
 
13
-
14
14
  class TestMeme < Minitest::Test
15
15
  def setup
16
16
  @meme = Meme.new
@@ -21,15 +21,14 @@ if M::Frameworks.minitest5?
21
21
  end
22
22
 
23
23
  def test_that_it_will_not_blend
24
- refute_match /^maybe/i, @meme.will_it_blend?
25
- refute_match /^no/i, @meme.will_it_blend?
26
- refute_match /^lolz/i, @meme.will_it_blend?
24
+ refute_match(/^maybe/i, @meme.will_it_blend?)
25
+ refute_match(/^no/i, @meme.will_it_blend?)
26
+ refute_match(/^lolz/i, @meme.will_it_blend?)
27
27
  end
28
28
 
29
29
  def test_that_kitty_can_eat_two_time
30
30
  assert_equal "OHAI!", @meme.i_can_has_cheezburger?
31
31
  assert_equal "OHAI!", @meme.i_can_has_cheezburger?
32
32
  end
33
-
34
33
  end
35
34
  end
@@ -1,4 +1,3 @@
1
- require 'test/unit'
2
1
  require 'active_support/test_case'
3
2
 
4
3
  class MultipleExampleTest < ActiveSupport::TestCase
@@ -1,6 +1,6 @@
1
- require 'test/unit'
1
+ require_relative '../../test_helper'
2
2
 
3
- class ATest < Test::Unit::TestCase
3
+ class ATest < MTest
4
4
  def test_a
5
5
  assert_equal 1, 1
6
6
  end
@@ -1,6 +1,6 @@
1
- require 'test/unit'
1
+ require_relative '../../test_helper'
2
2
 
3
- class BTest < Test::Unit::TestCase
3
+ class BTest < MTest
4
4
  def test_b
5
5
  assert_equal 1, 1
6
6
  end
@@ -1,6 +1,6 @@
1
- require 'test/unit'
1
+ require_relative '../../test_helper'
2
2
 
3
- class CTest < Test::Unit::TestCase
3
+ class CTest < MTest
4
4
  def test_c
5
5
  assert_equal 1, 1
6
6
  end
@@ -0,0 +1,7 @@
1
+ require_relative '../../test_helper'
2
+
3
+ class ATest < MTest
4
+ def test_a
5
+ assert_equal 1, 2
6
+ end
7
+ end
@@ -1,16 +1,16 @@
1
- require 'test/unit'
1
+ if M::Frameworks.test_unit?
2
+ class TestUnitExampleTest < Test::Unit::TestCase
3
+ def setup
4
+ end
2
5
 
3
- class TestUnitExampleTest < Test::Unit::TestCase
4
- def setup
5
- end
6
-
7
- def test_apple
8
- assert_equal 1, 1
9
- end
6
+ def test_apple
7
+ assert_equal 1, 1
8
+ end
10
9
 
11
- def test_banana
12
- assert_equal 1, 1
13
- assert_equal 2, 2
14
- assert_equal 3, 3
10
+ def test_banana
11
+ assert_equal 1, 1
12
+ assert_equal 2, 2
13
+ assert_equal 3, 3
14
+ end
15
15
  end
16
16
  end
@@ -1,39 +1,39 @@
1
1
  require 'test_helper'
2
- if M::Frameworks.minitest4?
3
2
 
3
+ if M::Frameworks.minitest4?
4
4
  class Minitest4Test < MTest
5
5
  def test_run_simple_test_by_line_number
6
- output = m('examples/minitest_4_example_test.rb:20')
7
- assert_output /1 tests, 1 assertions/, output
6
+ output = m('examples/minitest_4_example_test.rb:19')
7
+ assert_output(/1 tests, 1 assertions/, output)
8
8
  end
9
9
 
10
10
  def test_runs_entire_test_without_line_number
11
11
  output = m('examples/minitest_4_example_test.rb')
12
- assert_output /3 tests/, output
12
+ assert_output(/3 tests/, output)
13
13
  end
14
14
 
15
15
  def test_run_inside_of_test
16
- output = m('examples/minitest_4_example_test.rb:21')
17
- assert_output /1 tests, 1 assertions/, output
16
+ output = m('examples/minitest_4_example_test.rb:20')
17
+ assert_output(/1 tests, 1 assertions/, output)
18
18
  end
19
19
 
20
20
  def test_run_on_end_of_test
21
- output = m('examples/minitest_4_example_test.rb:22')
22
- assert_output /1 tests, 1 assertions/, output
21
+ output = m('examples/minitest_4_example_test.rb:21')
22
+ assert_output(/1 tests, 1 assertions/, output)
23
23
  end
24
24
 
25
25
  def test_run_inside_big_test
26
26
  output = m('examples/minitest_4_example_test.rb:26')
27
- assert_output /1 tests, 6 assertions/, output
27
+ assert_output(/1 tests, 6 assertions/, output)
28
28
  end
29
29
 
30
30
  def test_run_on_blank_line
31
- output = m('examples/minitest_4_example_test.rb:3')
31
+ output = m('examples/minitest_4_example_test.rb:2')
32
32
 
33
33
  assert !$?.success?
34
- assert_match /No tests found on line 3. Valid tests to run:/, output
35
- assert_match %r{ test_that_kitty_can_eat: m examples/minitest_4_example_test\.rb:20}, output
36
- assert_match %r{test_that_it_will_not_blend: m examples/minitest_4_example_test\.rb:24}, output
34
+ assert_match(/No tests found on line 2. Valid tests to run:/, output)
35
+ assert_match %r{ test_that_kitty_can_eat: m examples/minitest_4_example_test\.rb:19}, output
36
+ assert_match %r{test_that_it_will_not_blend: m examples/minitest_4_example_test\.rb:23}, output
37
37
  end
38
38
  end
39
39
  end
@@ -3,34 +3,34 @@ if M::Frameworks.minitest5?
3
3
  class Minitest5Test < MTest
4
4
  def test_run_simple_test_by_line_number
5
5
  output = m('examples/minitest_5_example_test.rb:19')
6
- assert_output /1 runs, 1 assertions/, output
6
+ assert_output(/1 runs, 1 assertions/, output)
7
7
  end
8
8
 
9
9
  def test_runs_entire_test_without_line_number
10
10
  output = m('examples/minitest_5_example_test.rb')
11
- assert_output /3 runs/, output
11
+ assert_output(/3 runs/, output)
12
12
  end
13
13
 
14
14
  def test_run_inside_of_test
15
15
  output = m('examples/minitest_5_example_test.rb:20')
16
- assert_output /1 runs, 1 assertions/, output
16
+ assert_output(/1 runs, 1 assertions/, output)
17
17
  end
18
18
 
19
19
  def test_run_on_end_of_test
20
20
  output = m('examples/minitest_5_example_test.rb:21')
21
- assert_output /1 runs, 1 assertions/, output
21
+ assert_output(/1 runs, 1 assertions/, output)
22
22
  end
23
23
 
24
24
  def test_run_inside_big_test
25
25
  output = m('examples/minitest_5_example_test.rb:26')
26
- assert_output /1 runs, 6 assertions/, output
26
+ assert_output(/1 runs, 6 assertions/, output)
27
27
  end
28
28
 
29
29
  def test_run_on_blank_line
30
30
  output = m('examples/minitest_5_example_test.rb:3')
31
31
 
32
32
  assert !$?.success?
33
- assert_match /No tests found on line 3. Valid tests to run:/, output
33
+ assert_match(/No tests found on line 3. Valid tests to run:/, output)
34
34
  assert_match %r{ test_that_kitty_can_eat: m examples/minitest_5_example_test\.rb:19}, output
35
35
  assert_match %r{test_that_it_will_not_blend: m examples/minitest_5_example_test\.rb:23}, output
36
36
  end
@@ -3,16 +3,16 @@ require 'test_helper'
3
3
  class MultipleTest < MTest
4
4
  def test_run_simple_test_by_line_number
5
5
  output = m('examples/multiple_example_test.rb:11')
6
- assert_output /1 tests, 1 assertions/, output
6
+ assert_output(/1 tests, 1 assertions/, output)
7
7
  end
8
8
 
9
9
  def test_runs_entire_test_without_line_number
10
10
  output = m('examples/multiple_example_test.rb')
11
- assert_output /4 tests/, output
11
+ assert_output(/4 tests/, output)
12
12
  end
13
13
 
14
14
  def test_runs_all_tests_on_given_line_number
15
15
  output = m('examples/multiple_example_test.rb:6')
16
- assert_output /3 tests/, output
16
+ assert_output(/3 tests/, output)
17
17
  end
18
18
  end
@@ -3,31 +3,31 @@ require 'test_helper'
3
3
  class OptionsTest < MTest
4
4
  def test_short_help_option
5
5
  output = m('-h')
6
- assert_output /^Usage: m \[OPTIONS\] \[FILES\]/, output
6
+ assert_output(/^Usage: m \[OPTIONS\] \[FILES\]/, output)
7
7
  end
8
8
 
9
9
  def test_long_help_option
10
10
  output = m('--help')
11
- assert_output /^Usage: m \[OPTIONS\] \[FILES\]/, output
11
+ assert_output(/^Usage: m \[OPTIONS\] \[FILES\]/, output)
12
12
  end
13
13
 
14
14
  def test_verbose_option
15
15
  output = m('--version')
16
- assert_output /^m #{M::VERSION}/, output
16
+ assert_output(/^m #{M::VERSION}/, output)
17
17
  end
18
18
 
19
19
  def test_short_line_option
20
20
  output = m('-l20 examples/minitest_4_example_test.rb')
21
- assert_output /1 tests, 1 assertions/, output
21
+ assert_output(/1 tests, 1 assertions/, output)
22
22
  end
23
23
 
24
24
  def test_long_line_option
25
25
  output = m('--line 20 examples/minitest_4_example_test.rb')
26
- assert_output /1 tests, 1 assertions/, output
26
+ assert_output(/1 tests, 1 assertions/, output)
27
27
  end
28
28
 
29
29
  def test_line_option_has_precedence_over_colon_format
30
30
  output = m('--line 20 examples/minitest_4_example_test.rb:2')
31
- assert_output /1 tests, 1 assertions/, output
31
+ assert_output(/1 tests, 1 assertions/, output)
32
32
  end
33
33
  end
@@ -1,13 +1,10 @@
1
- if ENV['TRAVIS']
2
- require 'coveralls'
3
-
4
- Coveralls.wear!
5
- end
1
+ require 'coveralls'
2
+ Coveralls.wear_merged!
6
3
 
7
4
  module Testable
8
5
  def m(arguments)
9
6
  Dir.chdir("test") do
10
- `ruby -I../lib -I. ../bin/m #{arguments} 2>&1`.strip
7
+ `ruby -I../lib -I. ../bin/m #{arguments} 2>&1`.strip
11
8
  end
12
9
  end
13
10
 
@@ -17,17 +14,21 @@ module Testable
17
14
  end
18
15
  end
19
16
 
20
- require './lib/m'
17
+ require 'm'
21
18
  require 'minitest/autorun'
22
- if M::Frameworks.minitest5?
23
- class MTest < Minitest::Test
24
- include ::Testable
25
- end
26
- else
19
+ if M::Frameworks.test_unit?
27
20
  require 'test/unit'
28
21
  require 'active_support/test_case'
29
22
 
30
23
  class MTest < Test::Unit::TestCase
31
24
  include ::Testable
32
25
  end
26
+ elsif M::Frameworks.minitest5?
27
+ class MTest < Minitest::Test
28
+ include ::Testable
29
+ end
30
+ else
31
+ class MTest < MiniTest::Unit::TestCase
32
+ include ::Testable
33
+ end
33
34
  end
@@ -1,37 +1,39 @@
1
1
  require 'test_helper'
2
2
 
3
- class TestUnitTest < MTest
4
- def test_run_simple_test_by_line_number
5
- output = m('examples/test_unit_example_test.rb:7')
6
- assert_output /1 tests, 1 assertions/, output
7
- end
3
+ if M::Frameworks.test_unit?
4
+ class TestUnitTest < MTest
5
+ def test_run_simple_test_by_line_number
6
+ output = m('examples/test_unit_example_test.rb:7')
7
+ assert_output(/1 tests, 1 assertions/, output)
8
+ end
8
9
 
9
- def test_runs_entire_test_without_line_number
10
- output = m('examples/test_unit_example_test.rb')
11
- assert_output /2 tests/, output
12
- end
10
+ def test_runs_entire_test_without_line_number
11
+ output = m('examples/test_unit_example_test.rb')
12
+ assert_output(/2 tests/, output)
13
+ end
13
14
 
14
- def test_run_inside_of_test
15
- output = m('examples/test_unit_example_test.rb:8')
16
- assert_output /1 tests, 1 assertions/, output
17
- end
15
+ def test_run_inside_of_test
16
+ output = m('examples/test_unit_example_test.rb:8')
17
+ assert_output(/1 tests, 1 assertions/, output)
18
+ end
18
19
 
19
- def test_run_on_end_of_test
20
- output = m('examples/test_unit_example_test.rb:9')
21
- assert_output /1 tests, 1 assertions/, output
22
- end
20
+ def test_run_on_end_of_test
21
+ output = m('examples/test_unit_example_test.rb:9')
22
+ assert_output(/1 tests, 1 assertions/, output)
23
+ end
23
24
 
24
- def test_run_inside_big_test
25
- output = m('examples/test_unit_example_test.rb:14')
26
- assert_output /1 tests, 3 assertions/, output
27
- end
25
+ def test_run_inside_big_test
26
+ output = m('examples/test_unit_example_test.rb:14')
27
+ assert_output(/1 tests, 3 assertions/, output)
28
+ end
28
29
 
29
- def test_run_on_blank_line
30
- output = m('examples/test_unit_example_test.rb:2')
30
+ def test_run_on_blank_line
31
+ output = m('examples/test_unit_example_test.rb:2')
31
32
 
32
- assert !$?.success?
33
- assert_match /No tests found on line 2. Valid tests to run:/, output
34
- assert_match %r{ test_apple: m examples/test_unit_example_test\.rb:7}, output
35
- assert_match %r{test_banana: m examples/test_unit_example_test\.rb:11}, output
33
+ assert !$?.success?
34
+ assert_match(/No tests found on line 2. Valid tests to run:/, output)
35
+ assert_match(%r{ test_apple: m examples/test_unit_example_test\.rb:7}, output)
36
+ assert_match(%r{test_banana: m examples/test_unit_example_test\.rb:11}, output)
37
+ end
36
38
  end
37
39
  end