m 1.6.2 → 1.7.0
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 +14 -9
- data/Gemfile +3 -1
- data/README.md +3 -17
- data/Rakefile +2 -28
- data/lib/m/executor.rb +4 -1
- data/lib/m/finish_line.rb +83 -0
- data/lib/m/frameworks.rb +11 -11
- data/lib/m/parser.rb +3 -2
- data/lib/m/runners/minitest_6.rb +3 -0
- data/lib/m/test_method.rb +9 -14
- data/lib/m/version.rb +1 -1
- data/m.gemspec +1 -2
- data/test/active_support_test.rb +6 -1
- data/test/allocations.rb +2 -3
- data/test/bench.rb +9 -16
- data/test/empty_test.rb +1 -1
- data/test/everything_test.rb +2 -6
- data/test/examples/{minitest_5_example_test.rb → minitest_5_or_6_example_test.rb} +1 -1
- data/test/examples/minitest_example_test.rb +2 -4
- data/test/exit_codes_test.rb +1 -1
- data/test/{minitest_5_test.rb → minitest_test.rb} +18 -12
- data/test/multiple_test.rb +1 -1
- data/test/options_test.rb +1 -1
- data/test/test_helper.rb +6 -10
- data/test/test_unit_test.rb +6 -1
- metadata +9 -29
- data/gemfiles/minitest4.gemfile +0 -8
- data/gemfiles/minitest5.gemfile +0 -8
- data/gemfiles/test_unit_gem.gemfile +0 -8
- data/test/examples/minitest_4_example_test.rb +0 -34
- data/test/minitest_4_test.rb +0 -39
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4e5825f9f89739032571e003824817f6ee777b2ce56f32b6404956b6d6a29d93
|
|
4
|
+
data.tar.gz: c54e2cc45a805c2b4ed8e3a7fa7104aafea8d81b0492fd40505a850247a36a64
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2b612e6a37f7c14b6247ffa753ba89bc790cc4c3ea51b569e96fbe04d10fc91e4df4ef29f5ff7526a2aece12706ee8d0fbd8b6fd80d65a3fb5c072038d368c57
|
|
7
|
+
data.tar.gz: 800ddcf684b4a736c697f439986cdd3979d2ef80f9c037e4fdfcca1ad263eb518de7809a8bc76a312623358cdbd47a8c1b7b77a939deaba472681a659cf8205a
|
|
@@ -10,27 +10,32 @@ on:
|
|
|
10
10
|
|
|
11
11
|
jobs:
|
|
12
12
|
test:
|
|
13
|
-
runs-on: ubuntu-latest
|
|
14
13
|
strategy:
|
|
14
|
+
fail-fast: false
|
|
15
15
|
matrix:
|
|
16
|
-
|
|
17
|
-
-
|
|
18
|
-
- minitest5
|
|
19
|
-
- test_unit_gem
|
|
16
|
+
os:
|
|
17
|
+
- ubuntu-latest
|
|
20
18
|
ruby:
|
|
21
19
|
- ruby-2.7
|
|
22
20
|
- ruby-3.0
|
|
23
21
|
- ruby-3.1
|
|
22
|
+
- ruby-3.2
|
|
23
|
+
- ruby-3.3
|
|
24
|
+
- ruby-3.4
|
|
25
|
+
- ruby-4.0
|
|
26
|
+
- jruby
|
|
24
27
|
- truffleruby
|
|
25
|
-
|
|
26
|
-
|
|
28
|
+
include:
|
|
29
|
+
- { os: macos-latest, ruby: ruby-2.7 }
|
|
30
|
+
- { os: macos-latest, ruby: ruby-4.0 }
|
|
31
|
+
runs-on: ${{ matrix.os }}
|
|
27
32
|
steps:
|
|
28
33
|
- name: Checkout
|
|
29
|
-
uses: actions/checkout@
|
|
34
|
+
uses: actions/checkout@v6
|
|
30
35
|
- name: Install
|
|
31
36
|
uses: ruby/setup-ruby@v1
|
|
32
37
|
with:
|
|
33
38
|
ruby-version: ${{ matrix.ruby }}
|
|
34
39
|
bundler-cache: true
|
|
35
40
|
- name: Test
|
|
36
|
-
run: bundle exec rake
|
|
41
|
+
run: bundle exec rake test
|
data/Gemfile
CHANGED
|
@@ -2,7 +2,9 @@ source "https://rubygems.org"
|
|
|
2
2
|
|
|
3
3
|
gem "benchmark-ips"
|
|
4
4
|
gem "coveralls", require: false
|
|
5
|
+
gem "minitest", ">= 5"
|
|
6
|
+
gem "test-unit"
|
|
5
7
|
|
|
6
|
-
gem "allocation_stats"
|
|
8
|
+
gem "allocation_stats" unless defined?(JRUBY_VERSION)
|
|
7
9
|
|
|
8
10
|
gemspec
|
data/README.md
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
M.RB
|
|
2
|
-
|
|
3
|
-
[](https://rubygems.org/gems/m) [](https://codeclimate.com/github/qrush/m) [](https://travis-ci.org/qrush/m) [](https://coveralls.io/r/qrush/m)
|
|
4
|
-
|
|
5
|
-
|
|
6
2
|
----
|
|
7
3
|
|
|
8
4
|
`m` stands for metal, a better test/unit and minitest test runner that can run tests by line number.
|
|
@@ -116,11 +112,10 @@ SUPPORT
|
|
|
116
112
|
|
|
117
113
|
`m` works with a few Ruby test frameworks:
|
|
118
114
|
|
|
115
|
+
- Minitest::Test
|
|
116
|
+
- Minitest::Spec
|
|
119
117
|
- Test::Unit
|
|
120
118
|
- ActiveSupport::TestCase
|
|
121
|
-
- MiniTest::Unit::TestCase
|
|
122
|
-
- Minitest
|
|
123
|
-
|
|
124
119
|
|
|
125
120
|
CONTRIBUTING
|
|
126
121
|
============
|
|
@@ -129,16 +124,7 @@ CONTRIBUTING
|
|
|
129
124
|
|
|
130
125
|
You can run all the tests with:
|
|
131
126
|
|
|
132
|
-
bundle exec rake
|
|
133
|
-
|
|
134
|
-
You can also run tests selectively. For minitest 4 run:
|
|
135
|
-
|
|
136
|
-
bundle exec rake test:minitest4
|
|
137
|
-
|
|
138
|
-
and the ones for minitest 5 with:
|
|
139
|
-
|
|
140
|
-
bundle exec rake test:minitest5
|
|
141
|
-
|
|
127
|
+
bundle exec rake test
|
|
142
128
|
|
|
143
129
|
LICENSE
|
|
144
130
|
=======
|
data/Rakefile
CHANGED
|
@@ -6,43 +6,17 @@ require "bundler/gem_tasks"
|
|
|
6
6
|
require "rake/clean"
|
|
7
7
|
require "rake/testtask"
|
|
8
8
|
require "standard/rake"
|
|
9
|
+
require "rbconfig"
|
|
9
10
|
|
|
10
11
|
task default: [:test, "standard:fix"]
|
|
11
12
|
|
|
12
13
|
Rake::TestTask.new do |t|
|
|
13
|
-
t.libs << "test"
|
|
14
|
-
t.libs << "lib"
|
|
15
14
|
t.pattern = "test/*_test.rb"
|
|
16
15
|
end
|
|
17
16
|
|
|
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
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
desc "Run all tests and get merged test coverage"
|
|
34
|
-
task :tests do
|
|
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
|
|
40
|
-
Coveralls.push!
|
|
41
|
-
end
|
|
42
|
-
|
|
43
17
|
desc "Run simple benchmarks"
|
|
44
18
|
task :bench do
|
|
45
19
|
current_commit = `git rev-parse HEAD`
|
|
46
20
|
file_name = "benchmarks/#{Time.now.strftime "%Y%m%d"}-benchmark.log"
|
|
47
|
-
exec "echo -e 'Data for commit: #{current_commit}' > #{file_name} && ruby test/bench.rb >> #{file_name}"
|
|
21
|
+
exec "echo -e 'Data for commit: #{current_commit}' > #{file_name} && #{RbConfig.ruby} test/bench.rb >> #{file_name}"
|
|
48
22
|
end
|
data/lib/m/executor.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require_relative "runners/base"
|
|
2
|
+
require_relative "runners/minitest_6"
|
|
2
3
|
require_relative "runners/minitest_5"
|
|
3
4
|
require_relative "runners/minitest_4"
|
|
4
5
|
require_relative "runners/test_unit"
|
|
@@ -73,7 +74,9 @@ module M
|
|
|
73
74
|
|
|
74
75
|
begin
|
|
75
76
|
# Fire up this Ruby file. Let's hope it actually has tests.
|
|
76
|
-
|
|
77
|
+
file = testable.file
|
|
78
|
+
file = "./#{testable.file}" unless file.start_with? "/"
|
|
79
|
+
require file
|
|
77
80
|
rescue LoadError => e
|
|
78
81
|
# Fail with a happier error message instead of spitting out a backtrace from this gem
|
|
79
82
|
warn "Failed loading test file:\n#{e.message}"
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
require "ripper"
|
|
2
|
+
|
|
3
|
+
module M
|
|
4
|
+
# Stripped down parser that can determine the ending line for a method.
|
|
5
|
+
class FinishLine < Ripper
|
|
6
|
+
# Brazenly stolen from Rails::TestUnit::TestParser by Carl Brasic @brasic
|
|
7
|
+
|
|
8
|
+
# Helper to translate a method object into the path and line range where
|
|
9
|
+
# the method was defined.
|
|
10
|
+
def self.ending_line_for(method_obj)
|
|
11
|
+
path, begin_line = method_obj.source_location
|
|
12
|
+
new(File.read(path), path).parse[begin_line]
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def initialize(*)
|
|
16
|
+
# A hash mapping the 1-indexed line numbers that tests start on to where they end.
|
|
17
|
+
@begins_to_ends = {}
|
|
18
|
+
super
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def parse
|
|
22
|
+
super
|
|
23
|
+
@begins_to_ends
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# method test e.g. `def test_some_description`
|
|
27
|
+
# This event's first argument gets the `ident` node containing the method
|
|
28
|
+
# name, which we have overridden to return the line number of the ident
|
|
29
|
+
# instead.
|
|
30
|
+
def on_def(begin_line, *)
|
|
31
|
+
@begins_to_ends[begin_line] = lineno
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Everything past this point is to support declarative tests, which
|
|
35
|
+
# require more work to get right because of the many different ways
|
|
36
|
+
# methods can be invoked in ruby, all of which are parsed differently.
|
|
37
|
+
#
|
|
38
|
+
# The approach is just to store the current line number when the
|
|
39
|
+
# "test" method is called and pass it up the tree so it's available at
|
|
40
|
+
# the point when we also know the line where the associated block ends.
|
|
41
|
+
|
|
42
|
+
def on_method_add_block(begin_line, end_line)
|
|
43
|
+
if begin_line && end_line
|
|
44
|
+
@begins_to_ends[begin_line] = end_line
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def on_command_call(*, begin_lineno, _args)
|
|
49
|
+
begin_lineno
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def first_arg(arg, *)
|
|
53
|
+
arg
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def just_lineno(*)
|
|
57
|
+
lineno
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
alias_method :on_method_add_arg, :first_arg
|
|
61
|
+
alias_method :on_command, :first_arg
|
|
62
|
+
alias_method :on_stmts_add, :first_arg
|
|
63
|
+
alias_method :on_arg_paren, :first_arg
|
|
64
|
+
alias_method :on_bodystmt, :first_arg
|
|
65
|
+
|
|
66
|
+
alias_method :on_ident, :just_lineno
|
|
67
|
+
alias_method :on_do_block, :just_lineno
|
|
68
|
+
alias_method :on_stmts_new, :just_lineno
|
|
69
|
+
alias_method :on_brace_block, :just_lineno
|
|
70
|
+
|
|
71
|
+
def on_args_new
|
|
72
|
+
[]
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def on_args_add(parts, part)
|
|
76
|
+
parts << part
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def on_args_add_block(args, *rest)
|
|
80
|
+
args.first
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
data/lib/m/frameworks.rb
CHANGED
|
@@ -8,12 +8,12 @@ module M
|
|
|
8
8
|
end
|
|
9
9
|
end
|
|
10
10
|
|
|
11
|
-
def self.
|
|
12
|
-
minitest_version_major == "
|
|
11
|
+
def self.minitest6?
|
|
12
|
+
minitest_version_major == "6"
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
-
def self.
|
|
16
|
-
minitest_version_major == "
|
|
15
|
+
def self.minitest5?
|
|
16
|
+
minitest_version_major == "5"
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
def self.test_unit?
|
|
@@ -25,10 +25,10 @@ module M
|
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
def framework_runner
|
|
28
|
-
if
|
|
28
|
+
if minitest6?
|
|
29
|
+
Runners::Minitest6.new
|
|
30
|
+
elsif minitest5?
|
|
29
31
|
Runners::Minitest5.new
|
|
30
|
-
elsif minitest4?
|
|
31
|
-
Runners::Minitest4.new
|
|
32
32
|
elsif test_unit?
|
|
33
33
|
Runners::TestUnit.new
|
|
34
34
|
else
|
|
@@ -38,12 +38,12 @@ module M
|
|
|
38
38
|
|
|
39
39
|
private
|
|
40
40
|
|
|
41
|
-
def
|
|
42
|
-
self.class.
|
|
41
|
+
def minitest6?
|
|
42
|
+
self.class.minitest6?
|
|
43
43
|
end
|
|
44
44
|
|
|
45
|
-
def
|
|
46
|
-
self.class.
|
|
45
|
+
def minitest5?
|
|
46
|
+
self.class.minitest5?
|
|
47
47
|
end
|
|
48
48
|
|
|
49
49
|
def test_unit?
|
data/lib/m/parser.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require_relative "testable"
|
|
2
|
+
require "rbconfig"
|
|
2
3
|
|
|
3
4
|
module M
|
|
4
5
|
class Parser
|
|
@@ -11,12 +12,12 @@ module M
|
|
|
11
12
|
# With no arguments,
|
|
12
13
|
if argv.empty?
|
|
13
14
|
# Just shell out to `rake test`.
|
|
14
|
-
exec "rake test"
|
|
15
|
+
exec "#{RbConfig.ruby} -S rake test"
|
|
15
16
|
else
|
|
16
17
|
parse_options! argv
|
|
17
18
|
|
|
18
19
|
if argv.first.start_with? "--"
|
|
19
|
-
exec "rake test #{argv.join}"
|
|
20
|
+
exec "#{RbConfig.ruby} -S rake test #{argv.join}"
|
|
20
21
|
exit 0
|
|
21
22
|
else
|
|
22
23
|
# Parse out ARGV, it should be coming in in a format like `test/test_file.rb:9:19`
|
data/lib/m/test_method.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
require_relative "finish_line" # if RUBY_VERSION < "4.1"
|
|
2
2
|
|
|
3
3
|
module M
|
|
4
4
|
### Simple data structure for what a test method contains.
|
|
@@ -9,23 +9,18 @@ module M
|
|
|
9
9
|
# Includes the name of this method, what line on the file it begins on,
|
|
10
10
|
# and where it ends.
|
|
11
11
|
TestMethod = Struct.new :name, :start_line, :end_line do
|
|
12
|
-
# Set up a new test method for this test suite class
|
|
13
12
|
def self.create suite_class, test_method
|
|
14
|
-
# Hopefully it's been defined as an instance method, so we'll need to
|
|
15
|
-
# look up the ruby Method instance for it
|
|
16
13
|
method = suite_class.instance_method test_method
|
|
17
14
|
|
|
18
|
-
# Ruby can find the starting line for us, so pull that out of the array
|
|
19
|
-
|
|
15
|
+
# Ruby can find the starting line for us, so pull that out of the array.
|
|
16
|
+
# Ruby 4.1+ can also provide the ending line.
|
|
17
|
+
#start_line, end_line = method.source_location.values_at(1, 3)
|
|
18
|
+
start_line = method.source_location[1]
|
|
20
19
|
|
|
21
|
-
# Ruby can't find the end line
|
|
22
|
-
#
|
|
23
|
-
#
|
|
24
|
-
|
|
25
|
-
# The end line should be the number of line breaks in the method source,
|
|
26
|
-
# added to the starting line and subtracted by one.
|
|
27
|
-
|
|
28
|
-
end_line = method.source.split("\n").size + start_line - 1
|
|
20
|
+
# Ruby < 4.1 can't find the end line. Use a Ripper-derived parser to
|
|
21
|
+
# determine the ending line.
|
|
22
|
+
#end_line ||= FinishLine.ending_line_for method
|
|
23
|
+
end_line = FinishLine.ending_line_for method
|
|
29
24
|
|
|
30
25
|
# Shove the given attributes into a new databag
|
|
31
26
|
new test_method, start_line, end_line
|
data/lib/m/version.rb
CHANGED
data/m.gemspec
CHANGED
|
@@ -12,8 +12,7 @@ Gem::Specification.new do |gem|
|
|
|
12
12
|
gem.require_paths = ["lib"]
|
|
13
13
|
gem.version = M::VERSION
|
|
14
14
|
|
|
15
|
-
gem.add_runtime_dependency "
|
|
16
|
-
gem.add_runtime_dependency "rake", ">= 0.9.2.2"
|
|
15
|
+
gem.add_runtime_dependency "rake"
|
|
17
16
|
|
|
18
17
|
gem.add_development_dependency "activesupport"
|
|
19
18
|
gem.add_development_dependency "standard"
|
data/test/active_support_test.rb
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
require_relative "test_helper"
|
|
2
2
|
|
|
3
3
|
class ActiveSupportTest < MTest
|
|
4
|
+
def test_run_simple_test_by_line_number_with_absolute_path
|
|
5
|
+
output = m File.join(__dir__, "examples/active_support_example_test.rb:9")
|
|
6
|
+
assert_output(/1 (runs|tests), 1 assertions/, output)
|
|
7
|
+
end
|
|
8
|
+
|
|
4
9
|
def test_run_simple_test_by_line_number
|
|
5
10
|
output = m "examples/active_support_example_test.rb:9"
|
|
6
11
|
assert_output(/1 (runs|tests), 1 assertions/, output)
|
data/test/allocations.rb
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
require "m"
|
|
1
|
+
require_relative "../lib/m"
|
|
3
2
|
require "allocation_stats"
|
|
4
3
|
|
|
5
4
|
def benchmark_allocations burn: 1, &block
|
|
@@ -16,6 +15,6 @@ end
|
|
|
16
15
|
|
|
17
16
|
benchmark_allocations do
|
|
18
17
|
10.times do
|
|
19
|
-
M::Runner.new(["test/examples/
|
|
18
|
+
M::Runner.new(["test/examples/minitest_5_or_6_example_test.rb:19"]).run
|
|
20
19
|
end
|
|
21
20
|
end
|
data/test/bench.rb
CHANGED
|
@@ -1,35 +1,28 @@
|
|
|
1
1
|
require "benchmark/ips"
|
|
2
|
+
require "rbconfig"
|
|
2
3
|
|
|
3
4
|
Benchmark.ips do |bench|
|
|
4
5
|
bench.report("running m on a file that doesn't exist") do
|
|
5
|
-
`bundle exec ruby -Ilib ./bin/m failwhale 2>/dev/null`
|
|
6
|
+
`bundle exec #{RbConfig.ruby} -Ilib ./bin/m failwhale 2>/dev/null`
|
|
6
7
|
end
|
|
7
8
|
|
|
8
9
|
bench.report("running m on an empty file") do
|
|
9
|
-
`bundle exec ruby -Ilib ./bin/m test/examples/empty_example_test.rb 2>/dev/null`
|
|
10
|
+
`bundle exec #{RbConfig.ruby} -Ilib ./bin/m test/examples/empty_example_test.rb 2>/dev/null`
|
|
10
11
|
end
|
|
11
12
|
|
|
12
|
-
bench.report("running m on an entire file with
|
|
13
|
-
`
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
bench.report("running m on an entire file with minitest5") do
|
|
17
|
-
`BUNDLE_GEMFILE=gemfiles/minitest5.gemfile bundle exec ruby -Ilib ./bin/m test/examples/minitest_5_example_test.rb 2>/dev/null`
|
|
13
|
+
bench.report("running m on an entire file with minitest") do
|
|
14
|
+
`bundle exec #{RbConfig.ruby} -Ilib ./bin/m test/examples/minitest_5_or_6_example_test.rb 2>/dev/null`
|
|
18
15
|
end
|
|
19
16
|
|
|
20
17
|
bench.report("running m on an entire file with test-unit gem") do
|
|
21
|
-
`
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
bench.report("running m on a specific test with minitest4") do
|
|
25
|
-
`BUNDLE_GEMFILE=gemfiles/minitest4.gemfile bundle exec ruby -Ilib ./bin/m test/examples/minitest_4_example_test.rb:19 2>/dev/null`
|
|
18
|
+
`bundle exec #{RbConfig.ruby} -Ilib ./bin/m test/examples/test_unit_example_test.rb 2>/dev/null`
|
|
26
19
|
end
|
|
27
20
|
|
|
28
|
-
bench.report("running m on a specific test with
|
|
29
|
-
`
|
|
21
|
+
bench.report("running m on a specific test with minitest") do
|
|
22
|
+
`bundle exec #{RbConfig.ruby} -Ilib ./bin/m test/examples/minitest_5_or_6_example_test.rb:19 2>/dev/null`
|
|
30
23
|
end
|
|
31
24
|
|
|
32
25
|
bench.report("running m on a specific test with test-unit gem") do
|
|
33
|
-
`
|
|
26
|
+
`bundle exec #{RbConfig.ruby} -Ilib ./bin/m test/examples/test_unit_example_test.rb:15 2>/dev/null`
|
|
34
27
|
end
|
|
35
28
|
end
|
data/test/empty_test.rb
CHANGED
data/test/everything_test.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
require_relative "test_helper"
|
|
2
2
|
|
|
3
3
|
class EverythingTest < MTest
|
|
4
4
|
def test_runs_entire_test_suite_with_no_arguments
|
|
@@ -10,11 +10,7 @@ class EverythingTest < MTest
|
|
|
10
10
|
output = m "examples/thisdoesnexist_test.rb"
|
|
11
11
|
assert !$?.success?
|
|
12
12
|
assert_match(/Failed loading test file/, output)
|
|
13
|
-
|
|
14
|
-
assert_match(/no such file to load/, output)
|
|
15
|
-
else
|
|
16
|
-
assert_match(/cannot load such file/, output)
|
|
17
|
-
end
|
|
13
|
+
assert_match(/cannot load such file/, output)
|
|
18
14
|
end
|
|
19
15
|
|
|
20
16
|
def test_running_tests_within_a_subdirectory
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require "minitest
|
|
1
|
+
require "minitest"
|
|
2
2
|
|
|
3
3
|
class Meme
|
|
4
4
|
def i_can_has_cheezburger?
|
|
@@ -10,9 +10,7 @@ class Meme
|
|
|
10
10
|
end
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
class TestMeme < Test
|
|
13
|
+
class TestMeme < Minitest::Test
|
|
16
14
|
def setup
|
|
17
15
|
@meme = Meme.new
|
|
18
16
|
end
|
data/test/exit_codes_test.rb
CHANGED
|
@@ -1,42 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
require_relative "test_helper"
|
|
2
|
+
|
|
3
|
+
if M::Frameworks.minitest5? || M::Frameworks.minitest6?
|
|
4
|
+
class MinitestTest < MTest
|
|
5
|
+
def test_run_simple_test_by_line_number_with_absolute_path
|
|
6
|
+
output = m File.join(__dir__, "examples/minitest_5_or_6_example_test.rb:19")
|
|
7
|
+
assert_output(/1 runs, 1 assertions/, output)
|
|
8
|
+
end
|
|
9
|
+
|
|
4
10
|
def test_run_simple_test_by_line_number
|
|
5
|
-
output = m "examples/
|
|
11
|
+
output = m "examples/minitest_5_or_6_example_test.rb:19"
|
|
6
12
|
assert_output(/1 runs, 1 assertions/, output)
|
|
7
13
|
end
|
|
8
14
|
|
|
9
15
|
def test_runs_entire_test_without_line_number
|
|
10
|
-
output = m "examples/
|
|
16
|
+
output = m "examples/minitest_5_or_6_example_test.rb"
|
|
11
17
|
assert_output(/3 runs/, output)
|
|
12
18
|
end
|
|
13
19
|
|
|
14
20
|
def test_run_inside_of_test
|
|
15
|
-
output = m "examples/
|
|
21
|
+
output = m "examples/minitest_5_or_6_example_test.rb:20"
|
|
16
22
|
assert_output(/1 runs, 1 assertions/, output)
|
|
17
23
|
end
|
|
18
24
|
|
|
19
25
|
def test_run_on_end_of_test
|
|
20
|
-
output = m "examples/
|
|
26
|
+
output = m "examples/minitest_5_or_6_example_test.rb:21"
|
|
21
27
|
assert_output(/1 runs, 1 assertions/, output)
|
|
22
28
|
end
|
|
23
29
|
|
|
24
30
|
def test_run_inside_big_test
|
|
25
|
-
output = m "examples/
|
|
31
|
+
output = m "examples/minitest_5_or_6_example_test.rb:26"
|
|
26
32
|
assert_output(/1 runs, 6 assertions/, output)
|
|
27
33
|
end
|
|
28
34
|
|
|
29
35
|
def test_run_on_blank_line
|
|
30
|
-
output = m "examples/
|
|
36
|
+
output = m "examples/minitest_5_or_6_example_test.rb:3"
|
|
31
37
|
|
|
32
38
|
assert !$?.success?
|
|
33
39
|
assert_match(/No tests found on line 3. Valid tests to run:/, output)
|
|
34
|
-
assert_match %r{ test_that_kitty_can_eat: m examples/
|
|
35
|
-
assert_match %r{test_that_it_will_not_blend: m examples/
|
|
40
|
+
assert_match %r{ test_that_kitty_can_eat: m examples/minitest_5_or_6_example_test\.rb:19}, output
|
|
41
|
+
assert_match %r{test_that_it_will_not_blend: m examples/minitest_5_or_6_example_test\.rb:23}, output
|
|
36
42
|
end
|
|
37
43
|
|
|
38
44
|
def test_run_with_after_run_block
|
|
39
|
-
output = m "examples/
|
|
45
|
+
output = m "examples/minitest_5_or_6_example_test.rb"
|
|
40
46
|
|
|
41
47
|
assert_output(/ran after run block/, output)
|
|
42
48
|
end
|
data/test/multiple_test.rb
CHANGED
data/test/options_test.rb
CHANGED
data/test/test_helper.rb
CHANGED
|
@@ -2,13 +2,14 @@ begin
|
|
|
2
2
|
require "coveralls"
|
|
3
3
|
Coveralls.wear_merged!
|
|
4
4
|
rescue LoadError
|
|
5
|
-
warn "gem 'coveralls' not available, proceeding without it"
|
|
6
5
|
end
|
|
7
6
|
|
|
7
|
+
require "rbconfig"
|
|
8
|
+
|
|
8
9
|
module Testable
|
|
9
10
|
def m arguments
|
|
10
11
|
Dir.chdir "test" do
|
|
11
|
-
|
|
12
|
+
`#{RbConfig.ruby} -I../lib -I. ../bin/m #{arguments} 2>&1`.strip
|
|
12
13
|
end
|
|
13
14
|
end
|
|
14
15
|
|
|
@@ -23,7 +24,7 @@ module Testable
|
|
|
23
24
|
end
|
|
24
25
|
end
|
|
25
26
|
|
|
26
|
-
|
|
27
|
+
require_relative "../lib/m"
|
|
27
28
|
|
|
28
29
|
def try_loading gem
|
|
29
30
|
require gem
|
|
@@ -31,8 +32,7 @@ rescue LoadError
|
|
|
31
32
|
false
|
|
32
33
|
end
|
|
33
34
|
|
|
34
|
-
try_loading("
|
|
35
|
-
try_loading("minitest/autorun") ||
|
|
35
|
+
try_loading("minitest/autorun") ||
|
|
36
36
|
try_loading("test/unit")
|
|
37
37
|
|
|
38
38
|
if M::Frameworks.test_unit?
|
|
@@ -45,12 +45,8 @@ if M::Frameworks.test_unit?
|
|
|
45
45
|
class MTest < Test::Unit::TestCase
|
|
46
46
|
include ::Testable
|
|
47
47
|
end
|
|
48
|
-
elsif M::Frameworks.minitest5?
|
|
49
|
-
class MTest < Minitest::Test
|
|
50
|
-
include ::Testable
|
|
51
|
-
end
|
|
52
48
|
else
|
|
53
|
-
class MTest <
|
|
49
|
+
class MTest < Minitest::Test
|
|
54
50
|
include ::Testable
|
|
55
51
|
end
|
|
56
52
|
end
|
data/test/test_unit_test.rb
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
require_relative "test_helper"
|
|
2
2
|
|
|
3
3
|
if M::Frameworks.test_unit?
|
|
4
4
|
class TestUnitTest < MTest
|
|
5
|
+
def test_run_simple_test_by_line_number_with_absolute_path
|
|
6
|
+
output = m File.join(__dir__, "examples/test_unit_example_test.rb:9")
|
|
7
|
+
assert_output(/1 tests, 1 assertions/, output)
|
|
8
|
+
end
|
|
9
|
+
|
|
5
10
|
def test_run_simple_test_by_line_number
|
|
6
11
|
output = m "examples/test_unit_example_test.rb:9"
|
|
7
12
|
assert_output(/1 tests, 1 assertions/, output)
|
metadata
CHANGED
|
@@ -1,43 +1,28 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: m
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.7.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Nick Quaranto
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
|
-
- !ruby/object:Gem::Dependency
|
|
14
|
-
name: method_source
|
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
|
16
|
-
requirements:
|
|
17
|
-
- - ">="
|
|
18
|
-
- !ruby/object:Gem::Version
|
|
19
|
-
version: 0.6.7
|
|
20
|
-
type: :runtime
|
|
21
|
-
prerelease: false
|
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
-
requirements:
|
|
24
|
-
- - ">="
|
|
25
|
-
- !ruby/object:Gem::Version
|
|
26
|
-
version: 0.6.7
|
|
27
12
|
- !ruby/object:Gem::Dependency
|
|
28
13
|
name: rake
|
|
29
14
|
requirement: !ruby/object:Gem::Requirement
|
|
30
15
|
requirements:
|
|
31
16
|
- - ">="
|
|
32
17
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: 0
|
|
18
|
+
version: '0'
|
|
34
19
|
type: :runtime
|
|
35
20
|
prerelease: false
|
|
36
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
22
|
requirements:
|
|
38
23
|
- - ">="
|
|
39
24
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: 0
|
|
25
|
+
version: '0'
|
|
41
26
|
- !ruby/object:Gem::Dependency
|
|
42
27
|
name: activesupport
|
|
43
28
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -85,18 +70,17 @@ files:
|
|
|
85
70
|
- benchmarks/20150505-benchmark.log
|
|
86
71
|
- benchmarks/20150927-benchmark.log
|
|
87
72
|
- bin/m
|
|
88
|
-
- gemfiles/minitest4.gemfile
|
|
89
|
-
- gemfiles/minitest5.gemfile
|
|
90
|
-
- gemfiles/test_unit_gem.gemfile
|
|
91
73
|
- lib/error_tests/error_test.rb
|
|
92
74
|
- lib/m.rb
|
|
93
75
|
- lib/m/executor.rb
|
|
76
|
+
- lib/m/finish_line.rb
|
|
94
77
|
- lib/m/frameworks.rb
|
|
95
78
|
- lib/m/parser.rb
|
|
96
79
|
- lib/m/runner.rb
|
|
97
80
|
- lib/m/runners/base.rb
|
|
98
81
|
- lib/m/runners/minitest_4.rb
|
|
99
82
|
- lib/m/runners/minitest_5.rb
|
|
83
|
+
- lib/m/runners/minitest_6.rb
|
|
100
84
|
- lib/m/runners/test_unit.rb
|
|
101
85
|
- lib/m/runners/unsupported_framework.rb
|
|
102
86
|
- lib/m/test_collection.rb
|
|
@@ -114,8 +98,7 @@ files:
|
|
|
114
98
|
- test/examples/active_support_example_test.rb
|
|
115
99
|
- test/examples/active_support_unescaped_example_test.rb
|
|
116
100
|
- test/examples/empty_example_test.rb
|
|
117
|
-
- test/examples/
|
|
118
|
-
- test/examples/minitest_5_example_test.rb
|
|
101
|
+
- test/examples/minitest_5_or_6_example_test.rb
|
|
119
102
|
- test/examples/minitest_example_test.rb
|
|
120
103
|
- test/examples/multiple_example_test.rb
|
|
121
104
|
- test/examples/subdir/a_test.rb
|
|
@@ -126,8 +109,7 @@ files:
|
|
|
126
109
|
- test/examples/subdir_with_failures/a_test.rb
|
|
127
110
|
- test/examples/test_unit_example_test.rb
|
|
128
111
|
- test/exit_codes_test.rb
|
|
129
|
-
- test/
|
|
130
|
-
- test/minitest_5_test.rb
|
|
112
|
+
- test/minitest_test.rb
|
|
131
113
|
- test/multiple_test.rb
|
|
132
114
|
- test/options_test.rb
|
|
133
115
|
- test/test_helper.rb
|
|
@@ -137,7 +119,6 @@ licenses:
|
|
|
137
119
|
- MIT
|
|
138
120
|
metadata:
|
|
139
121
|
rubygems_mfa_required: 'true'
|
|
140
|
-
post_install_message:
|
|
141
122
|
rdoc_options: []
|
|
142
123
|
require_paths:
|
|
143
124
|
- lib
|
|
@@ -152,8 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
152
133
|
- !ruby/object:Gem::Version
|
|
153
134
|
version: '0'
|
|
154
135
|
requirements: []
|
|
155
|
-
rubygems_version: 3.
|
|
156
|
-
signing_key:
|
|
136
|
+
rubygems_version: 3.6.9
|
|
157
137
|
specification_version: 4
|
|
158
138
|
summary: Run test/unit tests by line number. Metal!
|
|
159
139
|
test_files: []
|
data/gemfiles/minitest4.gemfile
DELETED
data/gemfiles/minitest5.gemfile
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
require "minitest/unit"
|
|
2
|
-
|
|
3
|
-
if M::Frameworks.minitest4?
|
|
4
|
-
class Meme
|
|
5
|
-
def i_can_has_cheezburger?
|
|
6
|
-
"OHAI!"
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
def will_it_blend?
|
|
10
|
-
"YES!"
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
class TestMeme < MiniTest::Unit::TestCase
|
|
15
|
-
def setup
|
|
16
|
-
@meme = Meme.new
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def test_that_kitty_can_eat
|
|
20
|
-
assert_equal "OHAI!", @meme.i_can_has_cheezburger?
|
|
21
|
-
end
|
|
22
|
-
|
|
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?)
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def test_that_kitty_can_eat_two_time
|
|
30
|
-
assert_equal "OHAI!", @meme.i_can_has_cheezburger?
|
|
31
|
-
assert_equal "OHAI!", @meme.i_can_has_cheezburger?
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|
data/test/minitest_4_test.rb
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
require "test_helper"
|
|
2
|
-
|
|
3
|
-
if M::Frameworks.minitest4?
|
|
4
|
-
class Minitest4Test < MTest
|
|
5
|
-
def test_run_simple_test_by_line_number
|
|
6
|
-
output = m "examples/minitest_4_example_test.rb:19"
|
|
7
|
-
assert_output(/1 tests, 1 assertions/, output)
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def test_runs_entire_test_without_line_number
|
|
11
|
-
output = m "examples/minitest_4_example_test.rb"
|
|
12
|
-
assert_output(/3 tests/, output)
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def test_run_inside_of_test
|
|
16
|
-
output = m "examples/minitest_4_example_test.rb:20"
|
|
17
|
-
assert_output(/1 tests, 1 assertions/, output)
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def test_run_on_end_of_test
|
|
21
|
-
output = m "examples/minitest_4_example_test.rb:21"
|
|
22
|
-
assert_output(/1 tests, 1 assertions/, output)
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def test_run_inside_big_test
|
|
26
|
-
output = m "examples/minitest_4_example_test.rb:26"
|
|
27
|
-
assert_output(/1 tests, 6 assertions/, output)
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def test_run_on_blank_line
|
|
31
|
-
output = m "examples/minitest_4_example_test.rb:2"
|
|
32
|
-
|
|
33
|
-
assert !$?.success?
|
|
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
|
-
end
|
|
38
|
-
end
|
|
39
|
-
end
|