m 1.6.1 → 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 +15 -10
- data/.gitignore +1 -0
- data/.standard.yml +1 -0
- data/Gemfile +6 -6
- data/README.md +4 -40
- data/Rakefile +13 -87
- data/bin/m +2 -2
- data/lib/error_tests/error_test.rb +1 -1
- data/lib/m/executor.rb +23 -24
- data/lib/m/finish_line.rb +83 -0
- data/lib/m/frameworks.rb +27 -23
- data/lib/m/parser.rb +33 -33
- 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/minitest_6.rb +3 -0
- 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 +13 -18
- data/lib/m/testable.rb +2 -2
- data/lib/m/version.rb +1 -1
- data/lib/m.rb +4 -4
- data/m.gemspec +14 -16
- data/test/Rakefile +2 -2
- data/test/active_support_test.rb +22 -17
- data/test/allocations.rb +10 -13
- data/test/bench.rb +10 -17
- data/test/empty_test.rb +2 -2
- data/test/everything_test.rb +8 -12
- 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_5_example_test.rb → minitest_5_or_6_example_test.rb} +2 -2
- data/test/examples/minitest_example_test.rb +3 -5
- 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 +7 -7
- data/test/{minitest_5_test.rb → minitest_test.rb} +18 -12
- data/test/multiple_test.rb +4 -4
- data/test/options_test.rb +14 -14
- data/test/test_helper.rb +18 -24
- data/test/test_unit_test.rb +14 -9
- metadata +17 -95
- data/.travis.yml +0 -19
- data/Appraisals +0 -11
- data/Gemfile.lock +0 -74
- data/gemfiles/minitest4.gemfile +0 -10
- data/gemfiles/minitest4.gemfile.lock +0 -73
- data/gemfiles/minitest5.gemfile +0 -10
- data/gemfiles/minitest5.gemfile.lock +0 -73
- data/gemfiles/test_unit_gem.gemfile +0 -10
- data/gemfiles/test_unit_gem.gemfile.lock +0 -76
- data/test/examples/minitest_4_example_test.rb +0 -34
- data/test/minitest_4_test.rb +0 -39
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
|
|
@@ -6,14 +6,14 @@ module M
|
|
|
6
6
|
[]
|
|
7
7
|
end
|
|
8
8
|
|
|
9
|
-
def run
|
|
9
|
+
def run _test_arguments
|
|
10
10
|
not_supported
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
private
|
|
14
14
|
|
|
15
15
|
def not_supported
|
|
16
|
-
|
|
16
|
+
warn "This test framework is not supported! Please open up an issue at https://github.com/qrush/m !"
|
|
17
17
|
false
|
|
18
18
|
end
|
|
19
19
|
end
|
data/lib/m/test_collection.rb
CHANGED
|
@@ -11,18 +11,18 @@ module M
|
|
|
11
11
|
# internal collection
|
|
12
12
|
def_delegators :@collection, :size, :<<, :each
|
|
13
13
|
|
|
14
|
-
def initialize
|
|
14
|
+
def initialize collection = nil
|
|
15
15
|
@collection = collection || []
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
# Slice out tests that may be within the given line.
|
|
19
19
|
# Returns a new TestCollection with the results.
|
|
20
|
-
def within
|
|
20
|
+
def within lines
|
|
21
21
|
# Into a new collection, filter only the tests that...
|
|
22
22
|
collection = select do |test|
|
|
23
|
-
lines.none? || lines.any? { |line| (test.start_line..test.end_line).
|
|
23
|
+
lines.none? || lines.any? { |line| (test.start_line..test.end_line).cover?(line) }
|
|
24
24
|
end
|
|
25
|
-
self.class.new
|
|
25
|
+
self.class.new collection
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
# Used to line up method names in `#sprintf` when `m` aborts
|
|
@@ -33,7 +33,7 @@ module M
|
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
# Be considerate when printing out tests and pre-sort them by line number
|
|
36
|
-
def by_line_number
|
|
36
|
+
def by_line_number &block
|
|
37
37
|
# On each member of the collection, sort by line number and yield
|
|
38
38
|
# the block into the sorted collection
|
|
39
39
|
sort_by(&:start_line).each(&block)
|
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.
|
|
@@ -8,27 +8,22 @@ module M
|
|
|
8
8
|
#
|
|
9
9
|
# Includes the name of this method, what line on the file it begins on,
|
|
10
10
|
# and where it ends.
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
method = suite_class.instance_method(test_method)
|
|
11
|
+
TestMethod = Struct.new :name, :start_line, :end_line do
|
|
12
|
+
def self.create suite_class, test_method
|
|
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
|
-
new
|
|
26
|
+
new test_method, start_line, end_line
|
|
32
27
|
end
|
|
33
28
|
end
|
|
34
29
|
end
|
data/lib/m/testable.rb
CHANGED
|
@@ -3,14 +3,14 @@ module M
|
|
|
3
3
|
attr_accessor :file, :recursive, :passthrough_options
|
|
4
4
|
attr_reader :lines
|
|
5
5
|
|
|
6
|
-
def initialize
|
|
6
|
+
def initialize file = "", lines = [], recursive = false
|
|
7
7
|
@file = file
|
|
8
8
|
@recursive = recursive
|
|
9
9
|
@passthrough_options = []
|
|
10
10
|
self.lines = lines
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
-
def lines=
|
|
13
|
+
def lines= lines
|
|
14
14
|
@lines = lines.map(&:to_i)
|
|
15
15
|
end
|
|
16
16
|
end
|
data/lib/m/version.rb
CHANGED
data/lib/m.rb
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
### M, your metal test runner
|
|
2
2
|
# Maybe this gem should have a longer name? Metal?
|
|
3
|
-
require_relative
|
|
4
|
-
require_relative
|
|
5
|
-
require_relative
|
|
3
|
+
require_relative "m/version"
|
|
4
|
+
require_relative "m/frameworks"
|
|
5
|
+
require_relative "m/runner"
|
|
6
6
|
|
|
7
7
|
module M
|
|
8
8
|
# Accept arguments coming from bin/m and run tests, then bail out immediately.
|
|
9
|
-
def self.run
|
|
9
|
+
def self.run argv
|
|
10
10
|
# sync output since we're going to exit hard and fast
|
|
11
11
|
$stdout.sync = true
|
|
12
12
|
$stderr.sync = true
|
data/m.gemspec
CHANGED
|
@@ -1,26 +1,24 @@
|
|
|
1
|
-
require
|
|
1
|
+
require "./lib/m"
|
|
2
2
|
|
|
3
3
|
Gem::Specification.new do |gem|
|
|
4
|
-
gem.authors
|
|
5
|
-
gem.email
|
|
6
|
-
gem.homepage
|
|
4
|
+
gem.authors = ["Nick Quaranto"]
|
|
5
|
+
gem.email = ["nick@quaran.to"]
|
|
6
|
+
gem.homepage = "https://github.com/qrush/m"
|
|
7
|
+
gem.license = "MIT"
|
|
7
8
|
|
|
8
|
-
gem.executables
|
|
9
|
-
gem.files
|
|
10
|
-
gem.
|
|
11
|
-
gem.name = "m"
|
|
9
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
|
10
|
+
gem.files = `git ls-files`.split "\n"
|
|
11
|
+
gem.name = "m"
|
|
12
12
|
gem.require_paths = ["lib"]
|
|
13
|
-
gem.version
|
|
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
|
-
gem.add_development_dependency "
|
|
20
|
-
gem.add_development_dependency "rocco" unless defined? JRUBY_VERSION
|
|
21
|
-
gem.add_development_dependency "appraisal"
|
|
18
|
+
gem.add_development_dependency "standard"
|
|
22
19
|
|
|
23
|
-
gem.required_ruby_version = ">=
|
|
20
|
+
gem.required_ruby_version = ">= 2.7"
|
|
24
21
|
|
|
25
|
-
gem.summary = gem.description =
|
|
22
|
+
gem.summary = gem.description = "Run test/unit tests by line number. Metal!"
|
|
23
|
+
gem.metadata["rubygems_mfa_required"] = "true"
|
|
26
24
|
end
|
data/test/Rakefile
CHANGED
data/test/active_support_test.rb
CHANGED
|
@@ -1,53 +1,58 @@
|
|
|
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
|
-
output = m
|
|
10
|
+
output = m "examples/active_support_example_test.rb:9"
|
|
6
11
|
assert_output(/1 (runs|tests), 1 assertions/, output)
|
|
7
12
|
end
|
|
8
13
|
|
|
9
14
|
def test_runs_entire_test_without_line_number
|
|
10
|
-
output = m
|
|
15
|
+
output = m "examples/active_support_example_test.rb"
|
|
11
16
|
assert_output(/4 (runs|tests)/, output)
|
|
12
17
|
end
|
|
13
18
|
|
|
14
19
|
def test_run_inside_of_test
|
|
15
|
-
output = m
|
|
20
|
+
output = m "examples/active_support_example_test.rb:10"
|
|
16
21
|
assert_output(/1 (runs|tests), 1 assertions/, output)
|
|
17
22
|
end
|
|
18
23
|
|
|
19
24
|
def test_run_on_end_of_test
|
|
20
|
-
output = m
|
|
25
|
+
output = m "examples/active_support_example_test.rb:11"
|
|
21
26
|
assert_output(/1 (runs|tests), 1 assertions/, output)
|
|
22
27
|
end
|
|
23
28
|
|
|
24
29
|
def test_run_inside_big_test
|
|
25
|
-
output = m
|
|
30
|
+
output = m "examples/active_support_example_test.rb:15"
|
|
26
31
|
assert_output(/1 (runs|tests), 3 assertions/, output)
|
|
27
32
|
end
|
|
28
33
|
|
|
29
34
|
def test_run_on_blank_line_orders_tests_by_line_number
|
|
30
|
-
output = m
|
|
35
|
+
output = m "examples/active_support_example_test.rb:8"
|
|
31
36
|
|
|
32
37
|
assert !$?.success?
|
|
33
|
-
expected =
|
|
34
|
-
No tests found on line
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
test_eggplant_fig: m examples/active_support_example_test.rb:
|
|
40
|
-
|
|
38
|
+
expected = <<~OUTPUT
|
|
39
|
+
No tests found on line 8. Valid tests to run:
|
|
40
|
+
|
|
41
|
+
test_normal: m examples/active_support_example_test.rb:5
|
|
42
|
+
test_carrot: m examples/active_support_example_test.rb:9
|
|
43
|
+
test_daikon: m examples/active_support_example_test.rb:13
|
|
44
|
+
test_eggplant_fig: m examples/active_support_example_test.rb:19
|
|
45
|
+
OUTPUT
|
|
41
46
|
assert_equal expected.strip, output
|
|
42
47
|
end
|
|
43
48
|
|
|
44
49
|
def test_run_on_test_with_spaces
|
|
45
|
-
output = m
|
|
50
|
+
output = m "examples/active_support_example_test.rb:19"
|
|
46
51
|
assert_output(/1 (runs|tests), 1 assertions/, output)
|
|
47
52
|
end
|
|
48
53
|
|
|
49
54
|
def test_run_on_test_with_unescaped_regular_express_characters
|
|
50
|
-
output = m
|
|
55
|
+
output = m "examples/active_support_unescaped_example_test.rb:5"
|
|
51
56
|
assert_output(/1 (runs|tests), 1 assertions/, output)
|
|
52
57
|
end
|
|
53
58
|
end
|
data/test/allocations.rb
CHANGED
|
@@ -1,23 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
require
|
|
3
|
-
require 'allocation_stats'
|
|
1
|
+
require_relative "../lib/m"
|
|
2
|
+
require "allocation_stats"
|
|
4
3
|
|
|
5
|
-
def benchmark_allocations
|
|
6
|
-
stats = AllocationStats.new(burn: burn).trace
|
|
7
|
-
yield
|
|
8
|
-
end
|
|
4
|
+
def benchmark_allocations burn: 1, &block
|
|
5
|
+
stats = AllocationStats.new(burn: burn).trace(&block)
|
|
9
6
|
|
|
10
|
-
columns = if ENV[
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
columns = if ENV["DETAIL"]
|
|
8
|
+
[:sourcefile, :sourceline, :class_plus]
|
|
9
|
+
else
|
|
10
|
+
[:class_plus]
|
|
11
|
+
end
|
|
15
12
|
|
|
16
13
|
puts stats.allocations(alias_paths: true).group_by(*columns).sort_by_size.to_text
|
|
17
14
|
end
|
|
18
15
|
|
|
19
16
|
benchmark_allocations do
|
|
20
17
|
10.times do
|
|
21
|
-
M::Runner.new([
|
|
18
|
+
M::Runner.new(["test/examples/minitest_5_or_6_example_test.rb:19"]).run
|
|
22
19
|
end
|
|
23
20
|
end
|
data/test/bench.rb
CHANGED
|
@@ -1,35 +1,28 @@
|
|
|
1
|
-
require
|
|
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
|
-
`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
|
-
`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
|
-
`appraisal minitest5 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
|
-
`appraisal minitest4 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
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
require_relative "test_helper"
|
|
2
2
|
|
|
3
3
|
class EmptyTest < MTest
|
|
4
4
|
def test_run_simple_test_by_line_number
|
|
5
|
-
output = m
|
|
5
|
+
output = m "examples/empty_example_test.rb"
|
|
6
6
|
assert !$?.success?
|
|
7
7
|
assert_match(/There were no tests found./, output)
|
|
8
8
|
end
|
data/test/everything_test.rb
CHANGED
|
@@ -1,37 +1,33 @@
|
|
|
1
|
-
|
|
1
|
+
require_relative "test_helper"
|
|
2
2
|
|
|
3
3
|
class EverythingTest < MTest
|
|
4
4
|
def test_runs_entire_test_suite_with_no_arguments
|
|
5
|
-
output = m
|
|
5
|
+
output = m ""
|
|
6
6
|
assert_output(/12 (runs|tests)/, output)
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
def test_missing_file_gives_a_decent_error_message
|
|
10
|
-
output = m
|
|
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
|
|
21
|
-
output = m
|
|
17
|
+
output = m "examples/subdir"
|
|
22
18
|
assert_output(/3 (runs|tests)/, output)
|
|
23
19
|
|
|
24
|
-
output = m
|
|
20
|
+
output = m "examples"
|
|
25
21
|
assert_output(/12 (runs|tests)/, output)
|
|
26
22
|
end
|
|
27
23
|
|
|
28
24
|
def test_running_tests_with_failures_within_a_subdirectory
|
|
29
|
-
output = m
|
|
25
|
+
output = m "examples/subdir_with_failures"
|
|
30
26
|
assert_output_for_failed_execution(/1 (runs|tests), 1 assertions, 1 failures/, output)
|
|
31
27
|
end
|
|
32
28
|
|
|
33
29
|
def test_blank_file_is_quieter
|
|
34
|
-
output = m
|
|
30
|
+
output = m "bananas"
|
|
35
31
|
assert(/Valid tests to run/ !~ output)
|
|
36
32
|
end
|
|
37
33
|
end
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
require
|
|
2
|
-
require
|
|
1
|
+
require "active_support"
|
|
2
|
+
require "active_support/test_case"
|
|
3
3
|
|
|
4
4
|
class ActiveSupportExampleTest < ActiveSupport::TestCase
|
|
5
|
-
setup do
|
|
6
|
-
end
|
|
7
|
-
|
|
8
5
|
test "#assert_equal compares to objects (and ensures they are equal)" do
|
|
9
6
|
assert_equal 1, 1
|
|
10
7
|
end
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require
|
|
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
|
|
@@ -32,5 +30,5 @@ class TestMeme < Test
|
|
|
32
30
|
assert_equal "OHAI!", @meme.i_can_has_cheezburger?
|
|
33
31
|
end
|
|
34
32
|
|
|
35
|
-
Minitest.after_run { p "ran after run block" } if Minitest.respond_to?
|
|
33
|
+
Minitest.after_run { p "ran after run block" } if Minitest.respond_to? :after_run
|
|
36
34
|
end
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
require
|
|
2
|
-
require
|
|
1
|
+
require "active_support"
|
|
2
|
+
require "active_support/test_case"
|
|
3
3
|
|
|
4
4
|
class MultipleExampleTest < ActiveSupport::TestCase
|
|
5
|
-
|
|
5
|
+
["grape", "habanero", "iceplant"].each do |fruit|
|
|
6
6
|
test "#{fruit} is a fruit" do
|
|
7
7
|
assert_equal 1, 1
|
|
8
8
|
end
|