m 1.6.1 → 1.6.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby-ci.yml +3 -3
  3. data/.gitignore +1 -0
  4. data/.standard.yml +1 -0
  5. data/Gemfile +4 -6
  6. data/README.md +3 -25
  7. data/Rakefile +34 -82
  8. data/bin/m +2 -2
  9. data/gemfiles/minitest4.gemfile +2 -4
  10. data/gemfiles/minitest5.gemfile +2 -4
  11. data/gemfiles/test_unit_gem.gemfile +2 -4
  12. data/lib/error_tests/error_test.rb +1 -1
  13. data/lib/m/executor.rb +19 -23
  14. data/lib/m/frameworks.rb +20 -16
  15. data/lib/m/parser.rb +30 -31
  16. data/lib/m/runner.rb +3 -3
  17. data/lib/m/runners/base.rb +4 -4
  18. data/lib/m/runners/minitest_4.rb +1 -1
  19. data/lib/m/runners/minitest_5.rb +3 -5
  20. data/lib/m/runners/test_unit.rb +6 -6
  21. data/lib/m/runners/unsupported_framework.rb +2 -2
  22. data/lib/m/test_collection.rb +5 -5
  23. data/lib/m/test_method.rb +5 -5
  24. data/lib/m/testable.rb +2 -2
  25. data/lib/m/version.rb +1 -1
  26. data/lib/m.rb +4 -4
  27. data/m.gemspec +13 -14
  28. data/test/Rakefile +2 -2
  29. data/test/active_support_test.rb +17 -17
  30. data/test/allocations.rb +11 -13
  31. data/test/bench.rb +9 -9
  32. data/test/empty_test.rb +2 -2
  33. data/test/everything_test.rb +7 -7
  34. data/test/examples/active_support_example_test.rb +2 -5
  35. data/test/examples/active_support_unescaped_example_test.rb +2 -5
  36. data/test/examples/empty_example_test.rb +1 -1
  37. data/test/examples/minitest_4_example_test.rb +1 -1
  38. data/test/examples/minitest_5_example_test.rb +1 -1
  39. data/test/examples/minitest_example_test.rb +2 -2
  40. data/test/examples/multiple_example_test.rb +3 -3
  41. data/test/examples/subdir/a_test.rb +1 -1
  42. data/test/examples/subdir/another_subdir/d_test.rb +1 -1
  43. data/test/examples/subdir/another_subdir/yet_another_subdir/e_test.rb +1 -1
  44. data/test/examples/subdir/b_test.rb +1 -1
  45. data/test/examples/subdir/c_test.rb +1 -1
  46. data/test/examples/subdir_with_failures/a_test.rb +1 -1
  47. data/test/examples/test_unit_example_test.rb +2 -2
  48. data/test/exit_codes_test.rb +6 -6
  49. data/test/minitest_4_test.rb +7 -7
  50. data/test/minitest_5_test.rb +8 -8
  51. data/test/multiple_test.rb +4 -4
  52. data/test/options_test.rb +14 -14
  53. data/test/test_helper.rb +15 -17
  54. data/test/test_unit_test.rb +9 -9
  55. metadata +11 -69
  56. data/.travis.yml +0 -19
  57. data/Appraisals +0 -11
  58. data/Gemfile.lock +0 -74
  59. data/gemfiles/minitest4.gemfile.lock +0 -73
  60. data/gemfiles/minitest5.gemfile.lock +0 -73
  61. data/gemfiles/test_unit_gem.gemfile.lock +0 -76
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e82a11a5dd9af1f6023bb8150265770adee0b322f21878d88cad02fdd0b99430
4
- data.tar.gz: 5734c191624c0b77e27b3c935e4388168fc5d6fbb673182447b69530d3b9d347
3
+ metadata.gz: 3242d76170ae6e9c1e655bca994edab9289d44424ec463f26909d87b759a7b65
4
+ data.tar.gz: 7bade78b916378359932c6a9fb6129a8c4a62c2a76ab1214103db34c2c88c55c
5
5
  SHA512:
6
- metadata.gz: 6a7e89d0ff0ae83bc62d5b8de773fb3120fcd8b0db996ba8795ee11f7016ad34d722544f513fd06fda35c0cd2db2f27f16dc45241e9a839190466bb8d8be6ddf
7
- data.tar.gz: dd72cc68f9f91173b455818ad1c503b868158fedbae55c1684246223c209c87f0299513af6ed9a26381a19ef30bc73ca58333a357de2ca2a1f7202d92d48ede2
6
+ metadata.gz: a83741c31e17d531dca7255834de1be852aef6076da60fd4425c7e3970b10d7ef30be4d60fdd12ad11cf7a47dd45e75a2afc06897d306c76c41982762b1bdb75
7
+ data.tar.gz: 9666eff8dcb0241fa07645289d6d1bc4805552c709d96659ed3ed408ca9d0e3af209661000145b8aaafd1acb34933d94923bf3e7473619c7d056ad214d48ea84
@@ -13,17 +13,17 @@ jobs:
13
13
  runs-on: ubuntu-latest
14
14
  strategy:
15
15
  matrix:
16
- appraisal:
16
+ gemfile:
17
17
  - minitest4
18
18
  - minitest5
19
19
  - test_unit_gem
20
20
  ruby:
21
- - ruby-2.6
22
21
  - ruby-2.7
23
22
  - ruby-3.0
23
+ - ruby-3.1
24
24
  - truffleruby
25
25
  env:
26
- BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.appraisal }}.gemfile
26
+ BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
27
27
  steps:
28
28
  - name: Checkout
29
29
  uses: actions/checkout@v2
data/.gitignore CHANGED
@@ -3,6 +3,7 @@
3
3
  .bundle
4
4
  .config
5
5
  .yardoc
6
+ gemfiles/*.gemfile.lock
6
7
  Gemfile.lock
7
8
  InstalledFiles
8
9
  _yardoc
data/.standard.yml ADDED
@@ -0,0 +1 @@
1
+ ruby_version: 2.7
data/Gemfile CHANGED
@@ -1,10 +1,8 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
- gem 'coveralls', require: false
4
- gem 'benchmark-ips'
3
+ gem "benchmark-ips"
4
+ gem "coveralls", require: false
5
5
 
6
- if RUBY_VERSION !~ /^2.0/ && !defined?(JRUBY_VERSION)
7
- gem 'allocation_stats'
8
- end
6
+ gem "allocation_stats" if RUBY_VERSION !~ /^2.0/ && !defined?(JRUBY_VERSION)
9
7
 
10
8
  gemspec
data/README.md CHANGED
@@ -20,23 +20,10 @@ If you’re using Bundler, you’ll need to include it in your Gemfile. Toss it
20
20
 
21
21
  ``` ruby
22
22
  group :test do
23
- gem 'm', '~> 1.5.0'
23
+ gem "m"
24
24
  end
25
25
  ```
26
26
 
27
- Developing a RubyGem? Add m as a development dependency.
28
-
29
-
30
- ``` ruby
31
- Gem::Specification.new do |gem|
32
- # ...
33
- gem.add_development_dependency "m", "~> 1.5.0"
34
- end
35
- ```
36
-
37
- m works on Ruby 2.0+ only and support is only provided for [versions currently maintained by the community](https://www.ruby-lang.org/en/downloads/branches/).
38
-
39
-
40
27
  USAGE
41
28
  =====
42
29
 
@@ -138,15 +125,6 @@ SUPPORT
138
125
  CONTRIBUTING
139
126
  ============
140
127
 
141
- ## Setup
142
-
143
- This project uses [Appraisal](https://github.com/thoughtbot/appraisal) to test against different versions of dependencies.
144
-
145
- To install all scenarios (appraisals):
146
-
147
- bundle install
148
- bundle exec appraisal install
149
-
150
128
  ## Testing
151
129
 
152
130
  You can run all the tests with:
@@ -155,11 +133,11 @@ You can run all the tests with:
155
133
 
156
134
  You can also run tests selectively. For minitest 4 run:
157
135
 
158
- appraisal minitest4 rake test
136
+ bundle exec rake test:minitest4
159
137
 
160
138
  and the ones for minitest 5 with:
161
139
 
162
- appraisal minitest5 rake test
140
+ bundle exec rake test:minitest5
163
141
 
164
142
 
165
143
  LICENSE
data/Rakefile CHANGED
@@ -1,96 +1,48 @@
1
1
  #!/usr/bin/env rake
2
- require 'rubygems'
3
- require 'bundler/setup'
4
- require 'appraisal'
5
- require 'coveralls'
6
- require 'bundler/gem_tasks'
7
- require 'rake/clean'
8
- require 'rake/testtask'
2
+ require "rubygems"
3
+ require "bundler/setup"
4
+ require "coveralls"
5
+ require "bundler/gem_tasks"
6
+ require "rake/clean"
7
+ require "rake/testtask"
8
+ require "standard/rake"
9
9
 
10
- task :default => [:test]
10
+ task default: [:test, "standard:fix"]
11
11
 
12
12
  Rake::TestTask.new do |t|
13
- t.libs << 'test'
14
- t.libs << 'lib'
15
- t.pattern = 'test/*_test.rb'
13
+ t.libs << "test"
14
+ t.libs << "lib"
15
+ t.pattern = "test/*_test.rb"
16
+ end
17
+
18
+ desc "Run all tests and get merged test coverage"
19
+ namespace :test do
20
+ Dir.glob("gemfiles/*.gemfile").each do |gemfile_path|
21
+ name = /gemfiles\/(.*).gemfile/.match(gemfile_path)[1]
22
+ desc "Run #{name} tests"
23
+ task name do |rake_task|
24
+ gemfile_name = rake_task.name.split(":").last
25
+ gemfile_path = "gemfiles/#{gemfile_name}.gemfile"
26
+ Bundler.with_original_env do
27
+ sh "BUNDLE_GEMFILE=#{gemfile_path} bundle exec rake"
28
+ end
29
+ end
30
+ end
16
31
  end
17
32
 
18
- desc 'Run all tests and get merged test coverage'
33
+ desc "Run all tests and get merged test coverage"
19
34
  task :tests do
20
- system "rake test" or exit!(1)
21
- system "appraisal minitest4 rake test" or exit!(1)
22
- system "appraisal minitest5 rake test TEST=test/minitest_5_test.rb" or exit!(1)
23
- system "appraisal test_unit_gem rake test TEST=test/test_unit_test.rb" or exit!(1)
35
+ Dir.glob("gemfiles/*.gemfile").each do |gemfile_path|
36
+ Bundler.with_original_env do
37
+ sh "BUNDLE_GEMFILE=#{gemfile_path} bundle exec rake"
38
+ end
39
+ end
24
40
  Coveralls.push!
25
41
  end
26
42
 
27
- desc 'Run simple benchmarks'
43
+ desc "Run simple benchmarks"
28
44
  task :bench do
29
45
  current_commit = `git rev-parse HEAD`
30
- file_name = "benchmarks/#{Time.now.strftime('%Y%m%d')}-benchmark.log"
46
+ file_name = "benchmarks/#{Time.now.strftime "%Y%m%d"}-benchmark.log"
31
47
  exec "echo -e 'Data for commit: #{current_commit}' > #{file_name} && ruby test/bench.rb >> #{file_name}"
32
48
  end
33
-
34
- # ROCCO ===============================================================
35
-
36
- begin
37
- require 'rdiscount'
38
- rescue LoadError => e
39
- warn e.inspect
40
- end
41
- begin
42
- require 'rocco/tasks'
43
- Rocco::make 'docs/'
44
- rescue LoadError => e
45
- warn e.inspect
46
- end
47
-
48
- desc 'Build rocco docs'
49
- task :docs => :rocco
50
- directory 'docs/'
51
-
52
- desc 'Build docs and open in browser for the reading'
53
- task :read => :docs do
54
- sh 'open docs/lib/m.html'
55
- end
56
-
57
- # Make index.html a copy of rocco.html
58
- file 'docs/index.html' => 'docs/lib/m.html' do |f|
59
- cp 'docs/lib/m.html', 'docs/index.html', :preserve => true
60
- end
61
-
62
- task :docs => 'docs/index.html'
63
- CLEAN.include 'docs/index.html'
64
-
65
- # Alias for docs task
66
- task :doc => :docs
67
-
68
- # GITHUB PAGES ===============================================================
69
-
70
- desc "really kill docs folder"
71
- task :clean_docs do
72
- sh "rm -rf docs/"
73
- end
74
-
75
- desc 'Update gh-pages branch'
76
- task :pages => [:clean_docs, 'docs/.git', :docs] do
77
- rev = `git rev-parse --short HEAD`.strip
78
- Dir.chdir 'docs' do
79
- sh "mv lib/m m"
80
- sh "mv lib/m.html m.html"
81
- sh "git add -A"
82
- sh "git commit -m 'rebuild pages from #{rev}'" do |ok,res|
83
- if ok
84
- verbose { puts "gh-pages updated" }
85
- sh "git push -q o HEAD:gh-pages"
86
- end
87
- end
88
- end
89
- end
90
-
91
- # Update the pages/ directory clone
92
- file 'docs/.git' => ['docs/'] do |f|
93
- sh "cd docs && git init -q && git remote add o ../.git" if !File.exist?(f.name)
94
- sh "cd docs && git fetch -q o && git reset -q --hard o/gh-pages && git rm -r . && git commit -m 'blank out' && touch ."
95
- end
96
- CLOBBER.include 'docs/.git'
data/bin/m CHANGED
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'm'
4
- M.run(ARGV)
3
+ require "m"
4
+ M.run ARGV
@@ -1,10 +1,8 @@
1
- # This file was generated by Appraisal
2
-
3
1
  source "https://rubygems.org"
4
2
 
5
- gem "coveralls", require: false
6
- gem "benchmark-ips"
7
3
  gem "allocation_stats"
4
+ gem "benchmark-ips"
5
+ gem "coveralls", require: false
8
6
  gem "minitest", "~> 4"
9
7
 
10
8
  gemspec path: "../"
@@ -1,10 +1,8 @@
1
- # This file was generated by Appraisal
2
-
3
1
  source "https://rubygems.org"
4
2
 
5
- gem "coveralls", require: false
6
- gem "benchmark-ips"
7
3
  gem "allocation_stats"
4
+ gem "benchmark-ips"
5
+ gem "coveralls", require: false
8
6
  gem "minitest", "~> 5"
9
7
 
10
8
  gemspec path: "../"
@@ -1,10 +1,8 @@
1
- # This file was generated by Appraisal
2
-
3
1
  source "https://rubygems.org"
4
2
 
5
- gem "coveralls", require: false
6
- gem "benchmark-ips"
7
3
  gem "allocation_stats"
4
+ gem "benchmark-ips"
5
+ gem "coveralls", require: false
8
6
  gem "test-unit"
9
7
 
10
8
  gemspec path: "../"
@@ -1,4 +1,4 @@
1
- require_relative "../../test/test_helper.rb"
1
+ require_relative "../../test/test_helper"
2
2
 
3
3
  class ErrorTest < MTest
4
4
  def test_purposeful_error
data/lib/m/executor.rb CHANGED
@@ -1,46 +1,46 @@
1
- require_relative 'runners/base'
2
- require_relative 'runners/minitest_5'
3
- require_relative 'runners/minitest_4'
4
- require_relative 'runners/test_unit'
5
- require_relative 'runners/unsupported_framework'
1
+ require_relative "runners/base"
2
+ require_relative "runners/minitest_5"
3
+ require_relative "runners/minitest_4"
4
+ require_relative "runners/test_unit"
5
+ require_relative "runners/unsupported_framework"
6
6
 
7
7
  module M
8
8
  class Executor
9
- def initialize(testable)
9
+ def initialize testable
10
10
  @testable = testable
11
11
  end
12
12
 
13
13
  def execute
14
14
  # Locate tests to run that may be inside of this line. There could be more than one!
15
- tests_to_run = tests.within(testable.lines)
15
+ tests_to_run = tests.within testable.lines
16
16
 
17
17
  # If we found any tests,
18
- if tests_to_run.size > 0
18
+ if tests_to_run.size.positive?
19
19
  # assemble the regexp to run these tests,
20
- test_names = tests_to_run.map { |test| Regexp.escape(test.name) }.join('|')
20
+ test_names = tests_to_run.map { |test| Regexp.escape(test.name) }.join("|")
21
21
 
22
22
  # set up the args needed for the runner
23
23
  test_arguments = ["-n", "/^(#{test_names})$/"]
24
24
 
25
25
  # directly run the tests from here and exit with the status of the tests passing or failing
26
- runner.run(test_arguments + testable.passthrough_options)
27
- elsif tests.size > 0
26
+ runner.run test_arguments + testable.passthrough_options
27
+ elsif tests.size.positive?
28
28
  # Otherwise we found no tests on this line, so you need to pick one.
29
- message = "No tests found on line #{testable.lines.join(', ')}. Valid tests to run:\n\n"
29
+ message = "No tests found on line #{testable.lines.join ", "}. Valid tests to run:\n\n"
30
30
 
31
31
  # For every test ordered by line number,
32
32
  # spit out the test name and line number where it starts,
33
33
  tests.by_line_number do |test|
34
- message << "#{sprintf("%0#{tests.column_size}s", test.name)}: m #{testable.file}:#{test.start_line}\n"
34
+ message << "#{format "%0#{tests.column_size}s", test.name}: m #{testable.file}:#{test.start_line}\n"
35
35
  end
36
36
 
37
37
  # Spit out helpful message and bail
38
- STDERR.puts message
38
+ warn message
39
39
  false
40
40
  else
41
41
  # There were no tests at all
42
42
  message = "There were no tests found.\n\n"
43
- STDERR.puts message
43
+ warn message
44
44
  false
45
45
  end
46
46
  end
@@ -58,27 +58,25 @@ module M
58
58
  # With each suite and array of tests,
59
59
  # and with each test method present in this test file,
60
60
  # shove a new test method into this collection.
61
- suites.inject(TestCollection.new) do |collection, (suite_class, test_methods)|
61
+ suites.each_with_object TestCollection.new do |(suite_class, test_methods), collection|
62
62
  test_methods.each do |test_method|
63
63
  collection << TestMethod.create(suite_class, test_method)
64
64
  end
65
- collection
66
65
  end
67
66
  end
68
67
  end
69
68
 
70
-
71
69
  # Finds all test suites in this test file, with test methods included.
72
70
  def suites
73
71
  # Since we're not using `ruby -Itest -Ilib` to run the tests, we need to add this directory to the `LOAD_PATH`
74
- $:.unshift "./test", "./spec", "./lib"
72
+ $LOAD_PATH.unshift "./test", "./spec", "./lib"
75
73
 
76
74
  begin
77
75
  # Fire up this Ruby file. Let's hope it actually has tests.
78
76
  require "./#{testable.file}"
79
77
  rescue LoadError => e
80
78
  # Fail with a happier error message instead of spitting out a backtrace from this gem
81
- STDERR.puts "Failed loading test file:\n#{e.message}"
79
+ warn "Failed loading test file:\n#{e.message}"
82
80
  return []
83
81
  end
84
82
 
@@ -87,9 +85,7 @@ module M
87
85
  # Use some janky internal APIs to group test methods by test suite.
88
86
  suites.each_with_object({}) do |suite_class, test_suites|
89
87
  # End up with a hash of suite class name to an array of test methods, so we can later find them and ignore empty test suites
90
- if runner.test_methods(suite_class).any?
91
- test_suites[suite_class] = runner.test_methods(suite_class)
92
- end
88
+ test_suites[suite_class] = runner.test_methods(suite_class) if runner.test_methods(suite_class).any?
93
89
  end
94
90
  end
95
91
 
data/lib/m/frameworks.rb CHANGED
@@ -1,5 +1,25 @@
1
1
  module M
2
2
  class Frameworks
3
+ def self.minitest_version_major
4
+ if defined?(Minitest::Unit::VERSION)
5
+ Minitest::Unit::VERSION.slice(/\d+/)
6
+ elsif defined?(Minitest::VERSION)
7
+ Minitest::VERSION.slice(/\d+/)
8
+ end
9
+ end
10
+
11
+ def self.minitest5?
12
+ minitest_version_major == "5"
13
+ end
14
+
15
+ def self.minitest4?
16
+ minitest_version_major == "4"
17
+ end
18
+
19
+ def self.test_unit?
20
+ defined?(Test::Unit)
21
+ end
22
+
3
23
  def self.framework_runner
4
24
  new.framework_runner
5
25
  end
@@ -29,21 +49,5 @@ module M
29
49
  def test_unit?
30
50
  self.class.test_unit?
31
51
  end
32
-
33
- def self.minitest_version_major
34
- defined?(Minitest) ? Minitest::Unit::VERSION.slice(/\d+/) : nil
35
- end
36
-
37
- def self.minitest5?
38
- minitest_version_major == "5"
39
- end
40
-
41
- def self.minitest4?
42
- minitest_version_major == "4"
43
- end
44
-
45
- def self.test_unit?
46
- defined?(Test::Unit)
47
- end
48
52
  end
49
53
  end
data/lib/m/parser.rb CHANGED
@@ -1,8 +1,8 @@
1
- require_relative 'testable'
1
+ require_relative "testable"
2
2
 
3
3
  module M
4
4
  class Parser
5
- def initialize(argv)
5
+ def initialize argv
6
6
  @argv = argv
7
7
  @testable = Testable.new
8
8
  end
@@ -15,12 +15,12 @@ module M
15
15
  else
16
16
  parse_options! argv
17
17
 
18
- if argv.first.start_with?("--")
18
+ if argv.first.start_with? "--"
19
19
  exec "rake test #{argv.join}"
20
20
  exit 0
21
21
  else
22
22
  # Parse out ARGV, it should be coming in in a format like `test/test_file.rb:9:19`
23
- parsed = argv.shift.split(':')
23
+ parsed = argv.shift.split ":"
24
24
  testable.file = parsed.shift
25
25
  testable.lines = parsed if testable.lines.none?
26
26
  # Anything else on ARGV will be passed along to the runner
@@ -28,26 +28,25 @@ module M
28
28
  end
29
29
 
30
30
  # If this file is a directory, not a file, run the tests inside of this directory
31
- if Dir.exist?(testable.file)
32
- # Make a new rake test task with a hopefully unique name, and run every test looking file in it
33
- require "rake/testtask"
34
- Rake::TestTask.new(:m_custom) do |t|
35
- t.libs << 'test'
36
- t.libs << 'spec'
37
- t.test_files = FileList[wildcard("test"), wildcard("spec")]
38
- t.warning = false
39
- end
40
- # Invoke the rake task and exit, hopefully it'll work!
41
- begin
42
- Rake::Task['m_custom'].invoke
43
- rescue RuntimeError
44
- exit(1)
45
- ensure
46
- exit($?.exitstatus)
47
- end
48
- else
49
- return testable
31
+ return testable unless Dir.exist? testable.file
32
+
33
+ # Make a new rake test task with a hopefully unique name, and run every test looking file in it
34
+ require "rake/testtask"
35
+ Rake::TestTask.new :m_custom do |t|
36
+ t.libs << "test"
37
+ t.libs << "spec"
38
+ t.test_files = FileList[wildcard("test"), wildcard("spec")]
39
+ t.warning = false
50
40
  end
41
+ # Invoke the rake task and exit, hopefully it'll work!
42
+ begin
43
+ Rake::Task["m_custom"].invoke
44
+ rescue RuntimeError
45
+ exit 1
46
+ ensure
47
+ exit $?.exitstatus
48
+ end
49
+
51
50
  end
52
51
  end
53
52
 
@@ -55,29 +54,29 @@ module M
55
54
 
56
55
  attr_reader :argv, :testable
57
56
 
58
- def parse_options!(argv)
59
- require 'optparse'
57
+ def parse_options! argv
58
+ require "optparse"
60
59
 
61
60
  OptionParser.new do |opts|
62
- opts.banner = 'Options:'
61
+ opts.banner = "Options:"
63
62
  opts.version = M::VERSION
64
63
 
65
- opts.on '-h', '--help', 'Display this help.' do
64
+ opts.on "-h", "--help", "Display this help." do
66
65
  puts "Usage: m [OPTIONS] [FILES]\n\n", opts
67
66
  exit
68
67
  end
69
68
 
70
- opts.on '--version', 'Display the version.' do
69
+ opts.on "--version", "Display the version." do
71
70
  puts "m #{M::VERSION}"
72
71
  exit
73
72
  end
74
73
 
75
- opts.on '-l', '--line LINE', Integer, 'Line number for file.' do |line|
74
+ opts.on "-l", "--line LINE", Integer, "Line number for file." do |line|
76
75
  p "parsing line #{line}"
77
76
  testable.lines = [line]
78
77
  end
79
78
 
80
- opts.on '-r', '--recursive DIR', 'Search provided directory recursively.' do |directory|
79
+ opts.on "-r", "--recursive DIR", "Search provided directory recursively." do |directory|
81
80
  testable.recursive = true
82
81
  argv << directory
83
82
  end
@@ -86,7 +85,7 @@ module M
86
85
  end
87
86
  end
88
87
 
89
- def wildcard(type)
88
+ def wildcard type
90
89
  if testable.recursive
91
90
  "#{testable.file}/**/*#{type}*.rb"
92
91
  else
data/lib/m/runner.rb CHANGED
@@ -1,11 +1,11 @@
1
- require_relative 'parser'
2
- require_relative 'executor'
1
+ require_relative "parser"
2
+ require_relative "executor"
3
3
 
4
4
  ### Runners are in charge of running your tests, depending on the framework
5
5
  # Instead of slamming all of this junk in an `M` class, it's here instead.
6
6
  module M
7
7
  class Runner
8
- def initialize(argv)
8
+ def initialize argv
9
9
  @argv = argv
10
10
  end
11
11
 
@@ -2,14 +2,14 @@ module M
2
2
  module Runners
3
3
  class Base
4
4
  def suites
5
- raise 'Not implemented'
5
+ raise "Not implemented"
6
6
  end
7
7
 
8
- def run(_test_arguments)
9
- raise 'Not implemented'
8
+ def run _test_arguments
9
+ raise "Not implemented"
10
10
  end
11
11
 
12
- def test_methods(suite_class)
12
+ def test_methods suite_class
13
13
  suite_class.test_methods
14
14
  end
15
15
  end
@@ -5,7 +5,7 @@ module M
5
5
  MiniTest::Unit::TestCase.test_suites
6
6
  end
7
7
 
8
- def run(test_arguments)
8
+ def run test_arguments
9
9
  MiniTest::Unit.runner.run test_arguments
10
10
  end
11
11
  end
@@ -2,19 +2,17 @@ module M
2
2
  module Runners
3
3
  class Minitest5 < Base
4
4
  def suites
5
- if Minitest.respond_to?(:seed)
6
- Minitest.seed = (ENV["SEED"] || srand).to_i % 0xFFFF
7
- end
5
+ Minitest.seed = (ENV["SEED"] || srand).to_i % 0xFFFF if Minitest.respond_to? :seed
8
6
  Minitest::Runnable.runnables
9
7
  end
10
8
 
11
- def run(test_arguments)
9
+ def run test_arguments
12
10
  output = Minitest.run test_arguments
13
11
  ::Minitest.class_variable_get(:@@after_run).reverse_each(&:call)
14
12
  output
15
13
  end
16
14
 
17
- def test_methods(suite_class)
15
+ def test_methods suite_class
18
16
  suite_class.runnable_methods
19
17
  end
20
18
  end
@@ -2,22 +2,22 @@ module M
2
2
  module Runners
3
3
  class TestUnit < Base
4
4
  def suites
5
- if Test::Unit::TestCase.respond_to?(:test_suites)
5
+ if Test::Unit::TestCase.respond_to? :test_suites
6
6
  Test::Unit::TestCase.test_suites
7
7
  else
8
8
  Test::Unit::TestCase::DESCENDANTS
9
9
  end
10
10
  end
11
11
 
12
- def run(test_arguments)
13
- Test::Unit::AutoRunner.run(false, nil, test_arguments)
12
+ def run test_arguments
13
+ Test::Unit::AutoRunner.run false, nil, test_arguments
14
14
  end
15
15
 
16
- def test_methods(suite_class)
17
- if suite_class.respond_to?(:test_methods)
16
+ def test_methods suite_class
17
+ if suite_class.respond_to? :test_methods
18
18
  suite_class.test_methods
19
19
  else
20
- suite_class.public_instance_methods(true).grep(/^test/).map { |m| m.to_s }
20
+ suite_class.public_instance_methods(true).grep(/^test/).map(&:to_s)
21
21
  end
22
22
  end
23
23
  end