m 1.6.1 → 1.6.2
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.
- checksums.yaml +4 -4
- data/.github/workflows/ruby-ci.yml +3 -3
- data/.gitignore +1 -0
- data/.standard.yml +1 -0
- data/Gemfile +4 -6
- data/README.md +3 -25
- data/Rakefile +34 -82
- data/bin/m +2 -2
- data/gemfiles/minitest4.gemfile +2 -4
- data/gemfiles/minitest5.gemfile +2 -4
- data/gemfiles/test_unit_gem.gemfile +2 -4
- data/lib/error_tests/error_test.rb +1 -1
- data/lib/m/executor.rb +19 -23
- data/lib/m/frameworks.rb +20 -16
- data/lib/m/parser.rb +30 -31
- data/lib/m/runner.rb +3 -3
- data/lib/m/runners/base.rb +4 -4
- data/lib/m/runners/minitest_4.rb +1 -1
- data/lib/m/runners/minitest_5.rb +3 -5
- data/lib/m/runners/test_unit.rb +6 -6
- data/lib/m/runners/unsupported_framework.rb +2 -2
- data/lib/m/test_collection.rb +5 -5
- data/lib/m/test_method.rb +5 -5
- data/lib/m/testable.rb +2 -2
- data/lib/m/version.rb +1 -1
- data/lib/m.rb +4 -4
- data/m.gemspec +13 -14
- data/test/Rakefile +2 -2
- data/test/active_support_test.rb +17 -17
- data/test/allocations.rb +11 -13
- data/test/bench.rb +9 -9
- data/test/empty_test.rb +2 -2
- data/test/everything_test.rb +7 -7
- data/test/examples/active_support_example_test.rb +2 -5
- data/test/examples/active_support_unescaped_example_test.rb +2 -5
- data/test/examples/empty_example_test.rb +1 -1
- data/test/examples/minitest_4_example_test.rb +1 -1
- data/test/examples/minitest_5_example_test.rb +1 -1
- data/test/examples/minitest_example_test.rb +2 -2
- data/test/examples/multiple_example_test.rb +3 -3
- data/test/examples/subdir/a_test.rb +1 -1
- data/test/examples/subdir/another_subdir/d_test.rb +1 -1
- data/test/examples/subdir/another_subdir/yet_another_subdir/e_test.rb +1 -1
- data/test/examples/subdir/b_test.rb +1 -1
- data/test/examples/subdir/c_test.rb +1 -1
- data/test/examples/subdir_with_failures/a_test.rb +1 -1
- data/test/examples/test_unit_example_test.rb +2 -2
- data/test/exit_codes_test.rb +6 -6
- data/test/minitest_4_test.rb +7 -7
- data/test/minitest_5_test.rb +8 -8
- data/test/multiple_test.rb +4 -4
- data/test/options_test.rb +14 -14
- data/test/test_helper.rb +15 -17
- data/test/test_unit_test.rb +9 -9
- metadata +11 -69
- data/.travis.yml +0 -19
- data/Appraisals +0 -11
- data/Gemfile.lock +0 -74
- data/gemfiles/minitest4.gemfile.lock +0 -73
- data/gemfiles/minitest5.gemfile.lock +0 -73
- data/gemfiles/test_unit_gem.gemfile.lock +0 -76
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3242d76170ae6e9c1e655bca994edab9289d44424ec463f26909d87b759a7b65
|
4
|
+
data.tar.gz: 7bade78b916378359932c6a9fb6129a8c4a62c2a76ab1214103db34c2c88c55c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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.
|
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
data/.standard.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby_version: 2.7
|
data/Gemfile
CHANGED
@@ -1,10 +1,8 @@
|
|
1
|
-
source
|
1
|
+
source "https://rubygems.org"
|
2
2
|
|
3
|
-
gem
|
4
|
-
gem
|
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
|
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
|
-
|
136
|
+
bundle exec rake test:minitest4
|
159
137
|
|
160
138
|
and the ones for minitest 5 with:
|
161
139
|
|
162
|
-
|
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
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
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 :
|
10
|
+
task default: [:test, "standard:fix"]
|
11
11
|
|
12
12
|
Rake::TestTask.new do |t|
|
13
|
-
t.libs <<
|
14
|
-
t.libs <<
|
15
|
-
t.pattern =
|
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
|
33
|
+
desc "Run all tests and get merged test coverage"
|
19
34
|
task :tests do
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
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
|
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
|
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
data/gemfiles/minitest4.gemfile
CHANGED
@@ -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: "../"
|
data/gemfiles/minitest5.gemfile
CHANGED
@@ -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: "../"
|
data/lib/m/executor.rb
CHANGED
@@ -1,46 +1,46 @@
|
|
1
|
-
require_relative
|
2
|
-
require_relative
|
3
|
-
require_relative
|
4
|
-
require_relative
|
5
|
-
require_relative
|
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
|
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
|
15
|
+
tests_to_run = tests.within testable.lines
|
16
16
|
|
17
17
|
# If we found any tests,
|
18
|
-
if tests_to_run.size
|
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
|
27
|
-
elsif tests.size
|
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
|
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 << "#{
|
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
|
-
|
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
|
-
|
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.
|
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
|
-
|
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
|
-
|
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
|
1
|
+
require_relative "testable"
|
2
2
|
|
3
3
|
module M
|
4
4
|
class Parser
|
5
|
-
def initialize
|
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
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
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!
|
59
|
-
require
|
57
|
+
def parse_options! argv
|
58
|
+
require "optparse"
|
60
59
|
|
61
60
|
OptionParser.new do |opts|
|
62
|
-
opts.banner
|
61
|
+
opts.banner = "Options:"
|
63
62
|
opts.version = M::VERSION
|
64
63
|
|
65
|
-
opts.on
|
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
|
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
|
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
|
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
|
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
|
2
|
-
require_relative
|
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
|
8
|
+
def initialize argv
|
9
9
|
@argv = argv
|
10
10
|
end
|
11
11
|
|
data/lib/m/runners/base.rb
CHANGED
@@ -2,14 +2,14 @@ module M
|
|
2
2
|
module Runners
|
3
3
|
class Base
|
4
4
|
def suites
|
5
|
-
raise
|
5
|
+
raise "Not implemented"
|
6
6
|
end
|
7
7
|
|
8
|
-
def run
|
9
|
-
raise
|
8
|
+
def run _test_arguments
|
9
|
+
raise "Not implemented"
|
10
10
|
end
|
11
11
|
|
12
|
-
def test_methods
|
12
|
+
def test_methods suite_class
|
13
13
|
suite_class.test_methods
|
14
14
|
end
|
15
15
|
end
|
data/lib/m/runners/minitest_4.rb
CHANGED
data/lib/m/runners/minitest_5.rb
CHANGED
@@ -2,19 +2,17 @@ module M
|
|
2
2
|
module Runners
|
3
3
|
class Minitest5 < Base
|
4
4
|
def suites
|
5
|
-
if Minitest.respond_to?
|
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
|
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
|
15
|
+
def test_methods suite_class
|
18
16
|
suite_class.runnable_methods
|
19
17
|
end
|
20
18
|
end
|
data/lib/m/runners/test_unit.rb
CHANGED
@@ -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?
|
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
|
13
|
-
Test::Unit::AutoRunner.run
|
12
|
+
def run test_arguments
|
13
|
+
Test::Unit::AutoRunner.run false, nil, test_arguments
|
14
14
|
end
|
15
15
|
|
16
|
-
def test_methods
|
17
|
-
if suite_class.respond_to?
|
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
|
20
|
+
suite_class.public_instance_methods(true).grep(/^test/).map(&:to_s)
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|