mutant-minitest 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +20 -0
- data/lib/mutant/integration/minitest.rb +174 -0
- data/lib/mutant/minitest/coverage.rb +56 -0
- metadata +76 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 279aa0ddb0529bfe71450630a9cf2e1c59140d4f30c5d83f212ae446e9c0109e
|
4
|
+
data.tar.gz: df2a0ad024f3987adccbb2ffd3633df6b402a684e195f16ed80c489979e5e856
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e97baa23175be495490968be97f1522e55da94cd328a10a5dfff015bec04f133df8bbd5e011bce43f13fdf6612100a4e7c4648d0c94dd504284342a743786f84
|
7
|
+
data.tar.gz: 05e8c6f6935350bb686ccbb5418b8ed5b2bf5277685ac7ee28ea30d38230c7ad2de9aec1a2299bb5d2167ad0bd631cebd17a70a912cc854be39ff9bf2a69ad0a
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012-2014 Markus Schirp
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,174 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'minitest'
|
4
|
+
require 'mutant/minitest/coverage'
|
5
|
+
|
6
|
+
module Minitest
|
7
|
+
# Prevent autorun from running tests when the VM closes
|
8
|
+
#
|
9
|
+
# Mutant needs control about the exit status of the VM and
|
10
|
+
# the moment of test execution
|
11
|
+
#
|
12
|
+
# @api private
|
13
|
+
#
|
14
|
+
# @return [nil]
|
15
|
+
def self.autorun; end
|
16
|
+
end # Minitest
|
17
|
+
|
18
|
+
module Mutant
|
19
|
+
class Integration
|
20
|
+
# Minitest integration
|
21
|
+
class Minitest < self
|
22
|
+
TEST_FILE_PATTERN = './test/**/{test_*,*_test}.rb'
|
23
|
+
IDENTIFICATION_FORMAT = 'minitest:%s#%s'
|
24
|
+
|
25
|
+
private_constant(*constants(false))
|
26
|
+
|
27
|
+
# Compose a runnable with test method
|
28
|
+
#
|
29
|
+
# This looks actually like a missing object on minitest implementation.
|
30
|
+
class TestCase
|
31
|
+
include Adamantium, Concord.new(:klass, :test_method)
|
32
|
+
|
33
|
+
# Identification string
|
34
|
+
#
|
35
|
+
# @return [String]
|
36
|
+
def identification
|
37
|
+
IDENTIFICATION_FORMAT % [klass, test_method]
|
38
|
+
end
|
39
|
+
memoize :identification
|
40
|
+
|
41
|
+
# Run test case
|
42
|
+
#
|
43
|
+
# @param [Object] reporter
|
44
|
+
#
|
45
|
+
# @return [Boolean]
|
46
|
+
def call(reporter)
|
47
|
+
::Minitest::Runnable.run_one_method(klass, test_method, reporter)
|
48
|
+
reporter.passed?
|
49
|
+
end
|
50
|
+
|
51
|
+
# Cover expression syntaxes
|
52
|
+
#
|
53
|
+
# @return [String, nil]
|
54
|
+
def expression_syntax
|
55
|
+
klass.resolve_cover_expression
|
56
|
+
end
|
57
|
+
|
58
|
+
end # TestCase
|
59
|
+
|
60
|
+
private_constant(*constants(false))
|
61
|
+
|
62
|
+
# Setup integration
|
63
|
+
#
|
64
|
+
# @return [self]
|
65
|
+
def setup
|
66
|
+
Pathname.glob(TEST_FILE_PATTERN)
|
67
|
+
.map(&:to_s)
|
68
|
+
.each(&method(:require))
|
69
|
+
|
70
|
+
self
|
71
|
+
end
|
72
|
+
|
73
|
+
# Call test integration
|
74
|
+
#
|
75
|
+
# @param [Array<Tests>] tests
|
76
|
+
#
|
77
|
+
# @return [Result::Test]
|
78
|
+
#
|
79
|
+
# rubocop:disable MethodLength
|
80
|
+
#
|
81
|
+
# ignore :reek:TooManyStatements
|
82
|
+
def call(tests)
|
83
|
+
test_cases = tests.map(&all_tests_index.method(:fetch))
|
84
|
+
output = StringIO.new
|
85
|
+
start = Time.now
|
86
|
+
|
87
|
+
reporter = ::Minitest::SummaryReporter.new(output)
|
88
|
+
|
89
|
+
reporter.start
|
90
|
+
|
91
|
+
test_cases.each do |test|
|
92
|
+
break unless test.call(reporter)
|
93
|
+
end
|
94
|
+
|
95
|
+
output.rewind
|
96
|
+
|
97
|
+
Result::Test.new(
|
98
|
+
passed: reporter.passed?,
|
99
|
+
tests: tests,
|
100
|
+
output: output.read,
|
101
|
+
runtime: Time.now - start
|
102
|
+
)
|
103
|
+
end
|
104
|
+
|
105
|
+
# All tests exposed by this integration
|
106
|
+
#
|
107
|
+
# @return [Array<Test>]
|
108
|
+
def all_tests
|
109
|
+
all_tests_index.keys
|
110
|
+
end
|
111
|
+
memoize :all_tests
|
112
|
+
|
113
|
+
private
|
114
|
+
|
115
|
+
# The index of all tests to runnable test cases
|
116
|
+
#
|
117
|
+
# @return [Hash<Test,TestCase>]
|
118
|
+
def all_tests_index
|
119
|
+
all_test_cases.each_with_object({}) do |test_case, index|
|
120
|
+
index[construct_test(test_case)] = test_case
|
121
|
+
end
|
122
|
+
end
|
123
|
+
memoize :all_tests_index
|
124
|
+
|
125
|
+
# Construct test from test case
|
126
|
+
#
|
127
|
+
# @param [TestCase]
|
128
|
+
#
|
129
|
+
# @return [Test]
|
130
|
+
def construct_test(test_case)
|
131
|
+
Test.new(
|
132
|
+
id: test_case.identification,
|
133
|
+
expression: config.expression_parser.call(test_case.expression_syntax)
|
134
|
+
)
|
135
|
+
end
|
136
|
+
|
137
|
+
# All minitest test cases
|
138
|
+
#
|
139
|
+
# Intentional utility method.
|
140
|
+
#
|
141
|
+
# @return [Array<TestCase>]
|
142
|
+
def all_test_cases
|
143
|
+
::Minitest::Runnable
|
144
|
+
.runnables
|
145
|
+
.select(&method(:allow_runnable?))
|
146
|
+
.flat_map(&method(:test_case))
|
147
|
+
end
|
148
|
+
|
149
|
+
# Test if runnable qualifies for mutation testing
|
150
|
+
#
|
151
|
+
# @param [Class]
|
152
|
+
#
|
153
|
+
# @return [Bool]
|
154
|
+
#
|
155
|
+
# ignore :reek:UtilityFunction
|
156
|
+
def allow_runnable?(klass)
|
157
|
+
!klass.equal?(::Minitest::Runnable) && klass.resolve_cover_expression
|
158
|
+
end
|
159
|
+
|
160
|
+
# Turn a minitest runnable into its test cases
|
161
|
+
#
|
162
|
+
# Intentional utility method.
|
163
|
+
#
|
164
|
+
# @param [Object] runnable
|
165
|
+
#
|
166
|
+
# @return [Array<TestCase>]
|
167
|
+
#
|
168
|
+
# ignore :reek:UtilityFunction
|
169
|
+
def test_case(runnable)
|
170
|
+
runnable.runnable_methods.map { |method| TestCase.new(runnable, method) }
|
171
|
+
end
|
172
|
+
end # Minitest
|
173
|
+
end # Integration
|
174
|
+
end # Mutant
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'minitest'
|
4
|
+
|
5
|
+
module Mutant
|
6
|
+
module Minitest
|
7
|
+
module Coverage
|
8
|
+
# Setup coverage declaration for current class
|
9
|
+
#
|
10
|
+
# @param [String]
|
11
|
+
#
|
12
|
+
# @example
|
13
|
+
#
|
14
|
+
# class MyTest < MiniTest::Test
|
15
|
+
# cover 'MyCode*'
|
16
|
+
#
|
17
|
+
# def test_some_stuff
|
18
|
+
# end
|
19
|
+
# end
|
20
|
+
#
|
21
|
+
# @api public
|
22
|
+
def cover(expression)
|
23
|
+
fail "#{self} already declares to cover: #{@covers}" if @covers
|
24
|
+
|
25
|
+
@cover_expression = expression
|
26
|
+
end
|
27
|
+
|
28
|
+
# Effective coverage expression
|
29
|
+
#
|
30
|
+
# @return [String, nil]
|
31
|
+
#
|
32
|
+
# @api private
|
33
|
+
def resolve_cover_expression
|
34
|
+
return @cover_expression if defined?(@cover_expression)
|
35
|
+
|
36
|
+
try_superclass_cover_expression
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
# Attempt to resolve superclass cover expressio
|
42
|
+
#
|
43
|
+
# @return [String, nil]
|
44
|
+
#
|
45
|
+
# @api private
|
46
|
+
def try_superclass_cover_expression
|
47
|
+
return if superclass.equal?(::Minitest::Runnable)
|
48
|
+
|
49
|
+
superclass.resolve_cover_expression
|
50
|
+
end
|
51
|
+
|
52
|
+
end # Coverage
|
53
|
+
end # Minitest
|
54
|
+
end # Mutant
|
55
|
+
|
56
|
+
Minitest::Test.extend(Mutant::Minitest::Coverage)
|
metadata
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mutant-minitest
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Markus Schirp
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-11-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: minitest
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '5.11'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '5.11'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: mutant
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.0.1
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.0.1
|
41
|
+
description: Minitest integration for mutant
|
42
|
+
email:
|
43
|
+
- mbj@schirp-dso.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files:
|
47
|
+
- LICENSE
|
48
|
+
files:
|
49
|
+
- LICENSE
|
50
|
+
- lib/mutant/integration/minitest.rb
|
51
|
+
- lib/mutant/minitest/coverage.rb
|
52
|
+
homepage: https://github.com/mbj/mutant
|
53
|
+
licenses:
|
54
|
+
- MIT
|
55
|
+
metadata: {}
|
56
|
+
post_install_message:
|
57
|
+
rdoc_options: []
|
58
|
+
require_paths:
|
59
|
+
- lib
|
60
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
requirements: []
|
71
|
+
rubyforge_project:
|
72
|
+
rubygems_version: 2.7.6
|
73
|
+
signing_key:
|
74
|
+
specification_version: 4
|
75
|
+
summary: Minitest integration for mutant
|
76
|
+
test_files: []
|