m 1.4.2 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4eb68da70e67de74c0b2074aa426481b9261f0e3
4
- data.tar.gz: f80e95794ab9c624d9ce64208e7d076ae31db2cf
3
+ metadata.gz: 797baa07531404e7d5add0a5928b0a3997dae6c6
4
+ data.tar.gz: b0210ac7b23dc08ce3666568c783cf44fcebffa1
5
5
  SHA512:
6
- metadata.gz: 64487e0b8fa78471e2317887a0876638bdf56ed56350293494ef94b61727abc189f0775370bdef56106666f45e4d84b3e1e242baec9bac93d521f5b8b18b2baf
7
- data.tar.gz: 197996dd41f2c9750a38fe6d8a6a87573e8176ca07f52cdd7e04aeff92aeeac8f1ea7b46a70e1c402e3562c4993900cfb5d5c096b61dd0b4f7aa1d87ebb1708f
6
+ metadata.gz: 47430e39fa825c9ce6f6c1ce0290a2bcde416edbaa5bf9113e7b5b0f53f532e563ece5ca322dd74bc686f82eabecf90dc5e513893b8845c57317cd3f3fd7d526
7
+ data.tar.gz: 2a6b64f5c7eac7f794843e12699114c790ee2de5a7a92161fe71c9f237c82b8f67080a9b8608c0a00ebb553b99fb1f084024f3ef6900ac003ba6a949d839d75b
@@ -3,6 +3,8 @@ rvm:
3
3
  - 2.1.0
4
4
  - 2.2.0
5
5
  - jruby-1.7.21
6
+ before_install:
7
+ - gem install bundler
6
8
  install:
7
9
  - bundle install
8
10
  - bundle --gemfile=gemfiles/minitest5.gemfile
data/README.md CHANGED
@@ -36,7 +36,7 @@ If you’re using Bundler, you’ll need to include it in your Gemfile. Toss it
36
36
 
37
37
  ``` ruby
38
38
  group :test do
39
- gem 'm', '~> 1.3.1'
39
+ gem 'm', '~> 1.5.0'
40
40
  end
41
41
  ```
42
42
 
@@ -46,7 +46,7 @@ Developing a RubyGem? Add m as a development dependency.
46
46
  ``` ruby
47
47
  Gem::Specification.new do |gem|
48
48
  # ...
49
- gem.add_development_dependency "m", "~> 1.3.1"
49
+ gem.add_development_dependency "m", "~> 1.5.0"
50
50
  end
51
51
  ```
52
52
 
@@ -114,6 +114,18 @@ Want to run the whole test? Just leave off the line number.
114
114
 
115
115
  1 tests, 2 assertions, 0 failures, 0 errors, 0 skips
116
116
 
117
+ If you want to run all the tests in a directory as well as its subdirectories, use the `-r` flag:
118
+
119
+ $ m -r test/models
120
+ "Searching provided directory for tests recursively"
121
+ Run options:
122
+
123
+ ..
124
+
125
+ Finished in 3.459902s, 45.0880 runs/s, 87.5747 assertions/s.
126
+
127
+ 156 tests, 303 assertions, 0 failures, 0 errors, 13 skips
128
+
117
129
 
118
130
  SUPPORT
119
131
  =======
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- m (1.3.4)
4
+ m (1.4.2)
5
5
  method_source (>= 0.6.7)
6
6
  rake (>= 0.9.2.2)
7
7
 
@@ -82,4 +82,4 @@ DEPENDENCIES
82
82
  rocco
83
83
 
84
84
  BUNDLED WITH
85
- 1.10.6
85
+ 1.11.2
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- m (1.3.4)
4
+ m (1.4.2)
5
5
  method_source (>= 0.6.7)
6
6
  rake (>= 0.9.2.2)
7
7
 
@@ -72,4 +72,4 @@ DEPENDENCIES
72
72
  rocco
73
73
 
74
74
  BUNDLED WITH
75
- 1.10.6
75
+ 1.11.2
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- m (1.3.4)
4
+ m (1.4.2)
5
5
  method_source (>= 0.6.7)
6
6
  rake (>= 0.9.2.2)
7
7
 
@@ -82,4 +82,4 @@ DEPENDENCIES
82
82
  test-unit
83
83
 
84
84
  BUNDLED WITH
85
- 1.10.6
85
+ 1.11.2
@@ -0,0 +1,7 @@
1
+ require_relative "../../test/test_helper.rb"
2
+
3
+ class ErrorTest < MTest
4
+ def test_purposeful_error
5
+ raise RuntimeError
6
+ end
7
+ end
@@ -25,15 +25,15 @@ module M
25
25
  Rake::TestTask.new(:m_custom) do |t|
26
26
  t.libs << 'test'
27
27
  t.libs << 'spec'
28
- t.test_files = FileList["#{testable.file}/*test*.rb", "#{testable.file}/*spec*.rb"]
28
+ t.test_files = FileList[wildcard("test"), wildcard("spec")]
29
29
  end
30
30
  # Invoke the rake task and exit, hopefully it'll work!
31
31
  begin
32
32
  Rake::Task['m_custom'].invoke
33
33
  rescue RuntimeError
34
- exit
34
+ exit(1)
35
35
  ensure
36
- exit
36
+ exit($?.exitstatus)
37
37
  end
38
38
  else
39
39
  return testable
@@ -67,8 +67,21 @@ module M
67
67
  testable.line = line
68
68
  end
69
69
 
70
+ opts.on '-r', '--recursive DIR', 'Search provided directory recursively.' do |directory|
71
+ testable.recursive = true
72
+ argv << directory
73
+ end
74
+
70
75
  opts.parse! argv
71
76
  end
72
77
  end
78
+
79
+ def wildcard(type)
80
+ if testable.recursive
81
+ "#{testable.file}/**/*#{type}*.rb"
82
+ else
83
+ "#{testable.file}/*#{type}*.rb"
84
+ end
85
+ end
73
86
  end
74
87
  end
@@ -1,11 +1,12 @@
1
1
  module M
2
2
  class Testable
3
- attr_accessor :file
3
+ attr_accessor :file, :recursive
4
4
  attr_reader :line
5
5
 
6
- def initialize(file = "", line = nil)
6
+ def initialize(file = "", line = nil, recursive = false)
7
7
  @file = file
8
8
  @line = line
9
+ @recursive = recursive
9
10
  end
10
11
 
11
12
  def line=(line)
@@ -1,3 +1,3 @@
1
1
  module M
2
- VERSION = "1.4.2"
2
+ VERSION = "1.5.0"
3
3
  end
@@ -27,7 +27,7 @@ class EverythingTest < MTest
27
27
 
28
28
  def test_running_tests_with_failures_within_a_subdirectory
29
29
  output = m('examples/subdir_with_failures')
30
- assert_output(/1 tests, 1 assertions, 1 failures/, output)
30
+ assert_output_for_failed_execution(/1 tests, 1 assertions, 1 failures/, output)
31
31
  end
32
32
 
33
33
  def test_blank_file_is_quieter
@@ -0,0 +1,7 @@
1
+ require_relative '../../../test_helper'
2
+
3
+ class DTest < MTest
4
+ def test_d
5
+ assert_equal 1, 1
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require_relative '../../../../test_helper'
2
+
3
+ class ETest < MTest
4
+ def test_e
5
+ assert_equal 1, 1
6
+ end
7
+ end
@@ -0,0 +1,33 @@
1
+ require "test_helper"
2
+
3
+ class ExitCodesTest < MTest
4
+ def test_failing_test_returns_1
5
+ m("examples/subdir_with_failures/a_test")
6
+ refute $?.success?, "expected exit code to be 1 but it was #{$?.exitstatus}"
7
+ end
8
+
9
+ def test_test_with_error_returns_1
10
+ m("../lib/error_tests/error_test")
11
+ refute $?.success?, "expected exit code to be 1 but it was #{$?.exitstatus}"
12
+ end
13
+
14
+ def test_dir_with_failure_returns_1
15
+ m("examples/subdir_with_failures")
16
+ refute $?.success?, "expected exit code to be 1 but it was #{$?.exitstatus}"
17
+ end
18
+
19
+ def test_dir_with_error_returns_1
20
+ m("../lib/error_tests")
21
+ refute $?.success?, "expected exit code to be 1 but it was #{$?.exitstatus}"
22
+ end
23
+
24
+ def test_without_errors_or_failures_returns_0
25
+ m("examples/subdir/a_test")
26
+ assert $?.success?, "expected exit code to be 0 but it was #{$?.exitstatus}"
27
+ end
28
+
29
+ def test_dir_without_errors_or_failures_returns_0
30
+ m("examples/subdir")
31
+ assert $?.success?, "expected exit code to be 0 but it was #{$?.exitstatus}"
32
+ end
33
+ end
@@ -30,4 +30,14 @@ class OptionsTest < MTest
30
30
  output = m('--line 20 examples/minitest_4_example_test.rb:2')
31
31
  assert_output(/1 tests, 1 assertions/, output)
32
32
  end
33
+
34
+ def test_recursive_option
35
+ output = m('-r examples/subdir')
36
+ assert_output(/5 tests/, output)
37
+ end
38
+
39
+ def test_recursive_option_without_directory_arg_fails
40
+ output = m('-r')
41
+ assert_match(/OptionParser::MissingArgument/, output)
42
+ end
33
43
  end
@@ -16,6 +16,11 @@ module Testable
16
16
  assert $?.success?, "Execution failed, output:\n\n#{output}"
17
17
  assert_match regexp, output
18
18
  end
19
+
20
+ def assert_output_for_failed_execution(regexp, output)
21
+ refute $?.success?, "Execution did not fail, but it should"
22
+ assert_match regexp, output
23
+ end
19
24
  end
20
25
 
21
26
  require 'm'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: m
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.2
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Quaranto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-30 00:00:00.000000000 Z
11
+ date: 2016-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: method_source
@@ -120,6 +120,7 @@ files:
120
120
  - gemfiles/minitest5.gemfile.lock
121
121
  - gemfiles/test_unit_gem.gemfile
122
122
  - gemfiles/test_unit_gem.gemfile.lock
123
+ - lib/error_tests/error_test.rb
123
124
  - lib/m.rb
124
125
  - lib/m/executor.rb
125
126
  - lib/m/frameworks.rb
@@ -149,10 +150,13 @@ files:
149
150
  - test/examples/minitest_5_example_test.rb
150
151
  - test/examples/multiple_example_test.rb
151
152
  - test/examples/subdir/a_test.rb
153
+ - test/examples/subdir/another_subdir/d_test.rb
154
+ - test/examples/subdir/another_subdir/yet_another_subdir/e_test.rb
152
155
  - test/examples/subdir/b_test.rb
153
156
  - test/examples/subdir/c_test.rb
154
157
  - test/examples/subdir_with_failures/a_test.rb
155
158
  - test/examples/test_unit_example_test.rb
159
+ - test/exit_codes_test.rb
156
160
  - test/minitest_4_test.rb
157
161
  - test/minitest_5_test.rb
158
162
  - test/multiple_test.rb
@@ -178,7 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
178
182
  version: '0'
179
183
  requirements: []
180
184
  rubyforge_project:
181
- rubygems_version: 2.4.8
185
+ rubygems_version: 2.5.1
182
186
  signing_key:
183
187
  specification_version: 4
184
188
  summary: Run test/unit tests by line number. Metal!
@@ -196,10 +200,13 @@ test_files:
196
200
  - test/examples/minitest_5_example_test.rb
197
201
  - test/examples/multiple_example_test.rb
198
202
  - test/examples/subdir/a_test.rb
203
+ - test/examples/subdir/another_subdir/d_test.rb
204
+ - test/examples/subdir/another_subdir/yet_another_subdir/e_test.rb
199
205
  - test/examples/subdir/b_test.rb
200
206
  - test/examples/subdir/c_test.rb
201
207
  - test/examples/subdir_with_failures/a_test.rb
202
208
  - test/examples/test_unit_example_test.rb
209
+ - test/exit_codes_test.rb
203
210
  - test/minitest_4_test.rb
204
211
  - test/minitest_5_test.rb
205
212
  - test/multiple_test.rb