mutant 0.3.0.beta21 → 0.3.0.beta22
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/.gitignore +37 -6
- data/.rspec +2 -0
- data/.ruby-gemset +1 -0
- data/.travis.yml +13 -7
- data/Gemfile +8 -3
- data/Gemfile.devtools +2 -6
- data/Guardfile +22 -8
- data/README.md +3 -1
- data/Rakefile +3 -0
- data/bin/mutant +4 -3
- data/config/devtools.yml +1 -1
- data/config/flay.yml +1 -1
- data/config/flog.yml +1 -1
- data/config/reek.yml +7 -6
- data/config/rubocop.yml +55 -0
- data/lib/mutant.rb +3 -1
- data/lib/mutant/cache.rb +2 -0
- data/lib/mutant/cli.rb +14 -10
- data/lib/mutant/cli/classifier.rb +22 -10
- data/lib/mutant/cli/classifier/method.rb +14 -15
- data/lib/mutant/cli/classifier/namespace.rb +6 -2
- data/lib/mutant/cli/classifier/scope.rb +3 -1
- data/lib/mutant/color.rb +7 -3
- data/lib/mutant/config.rb +2 -0
- data/lib/mutant/constants.rb +5 -4
- data/lib/mutant/context.rb +2 -0
- data/lib/mutant/context/scope.rb +3 -1
- data/lib/mutant/differ.rb +10 -2
- data/lib/mutant/killer.rb +4 -1
- data/lib/mutant/killer/forked.rb +2 -0
- data/lib/mutant/killer/forking.rb +2 -0
- data/lib/mutant/killer/rspec.rb +19 -3
- data/lib/mutant/killer/static.rb +2 -0
- data/lib/mutant/loader.rb +8 -1
- data/lib/mutant/matcher.rb +2 -0
- data/lib/mutant/matcher/chain.rb +2 -0
- data/lib/mutant/matcher/method.rb +15 -3
- data/lib/mutant/matcher/method/finder.rb +2 -0
- data/lib/mutant/matcher/method/instance.rb +4 -1
- data/lib/mutant/matcher/method/singleton.rb +7 -1
- data/lib/mutant/matcher/methods.rb +3 -1
- data/lib/mutant/matcher/namespace.rb +4 -2
- data/lib/mutant/matcher/scope.rb +2 -0
- data/lib/mutant/mutation.rb +19 -5
- data/lib/mutant/mutation/evil.rb +12 -0
- data/lib/mutant/mutation/filter.rb +2 -0
- data/lib/mutant/mutation/filter/code.rb +3 -1
- data/lib/mutant/mutation/filter/regexp.rb +2 -0
- data/lib/mutant/mutation/filter/whitelist.rb +2 -0
- data/lib/mutant/mutation/neutral.rb +25 -0
- data/lib/mutant/mutator.rb +4 -6
- data/lib/mutant/mutator/node.rb +5 -1
- data/lib/mutant/mutator/node/argument.rb +2 -0
- data/lib/mutant/mutator/node/arguments.rb +2 -0
- data/lib/mutant/mutator/node/begin.rb +2 -0
- data/lib/mutant/mutator/node/block.rb +2 -0
- data/lib/mutant/mutator/node/case.rb +3 -1
- data/lib/mutant/mutator/node/connective/binary.rb +3 -1
- data/lib/mutant/mutator/node/const.rb +2 -0
- data/lib/mutant/mutator/node/define.rb +2 -0
- data/lib/mutant/mutator/node/generic.rb +4 -3
- data/lib/mutant/mutator/node/if.rb +2 -0
- data/lib/mutant/mutator/node/literal.rb +2 -0
- data/lib/mutant/mutator/node/literal/array.rb +2 -0
- data/lib/mutant/mutator/node/literal/boolean.rb +2 -0
- data/lib/mutant/mutator/node/literal/dynamic.rb +2 -0
- data/lib/mutant/mutator/node/literal/fixnum.rb +3 -1
- data/lib/mutant/mutator/node/literal/float.rb +2 -0
- data/lib/mutant/mutator/node/literal/hash.rb +2 -0
- data/lib/mutant/mutator/node/literal/nil.rb +2 -0
- data/lib/mutant/mutator/node/literal/range.rb +2 -1
- data/lib/mutant/mutator/node/literal/regex.rb +2 -0
- data/lib/mutant/mutator/node/literal/string.rb +2 -0
- data/lib/mutant/mutator/node/literal/symbol.rb +5 -1
- data/lib/mutant/mutator/node/masgn.rb +2 -0
- data/lib/mutant/mutator/node/mlhs.rb +2 -0
- data/lib/mutant/mutator/node/named_value/access.rb +2 -0
- data/lib/mutant/mutator/node/named_value/constant_assignment.rb +2 -0
- data/lib/mutant/mutator/node/named_value/variable_assignment.rb +3 -1
- data/lib/mutant/mutator/node/{cbase.rb → noop.rb} +7 -5
- data/lib/mutant/mutator/node/return.rb +2 -0
- data/lib/mutant/mutator/node/send.rb +2 -0
- data/lib/mutant/mutator/node/send/binary.rb +2 -0
- data/lib/mutant/mutator/node/splat.rb +2 -0
- data/lib/mutant/mutator/node/super.rb +2 -0
- data/lib/mutant/mutator/node/when.rb +3 -1
- data/lib/mutant/mutator/node/while.rb +2 -0
- data/lib/mutant/mutator/node/zsuper.rb +2 -0
- data/lib/mutant/mutator/registry.rb +55 -13
- data/lib/mutant/mutator/util.rb +2 -0
- data/lib/mutant/mutator/util/array.rb +3 -1
- data/lib/mutant/mutator/util/symbol.rb +2 -0
- data/lib/mutant/node_helpers.rb +10 -4
- data/lib/mutant/random.rb +2 -0
- data/lib/mutant/reporter.rb +2 -0
- data/lib/mutant/reporter/cli.rb +2 -0
- data/lib/mutant/reporter/cli/printer.rb +2 -0
- data/lib/mutant/reporter/cli/printer/config.rb +5 -2
- data/lib/mutant/reporter/cli/printer/killer.rb +2 -0
- data/lib/mutant/reporter/cli/printer/mutation.rb +13 -6
- data/lib/mutant/reporter/cli/printer/subject.rb +5 -1
- data/lib/mutant/reporter/null.rb +2 -0
- data/lib/mutant/runner.rb +2 -0
- data/lib/mutant/runner/config.rb +2 -0
- data/lib/mutant/runner/mutation.rb +2 -0
- data/lib/mutant/runner/subject.rb +2 -0
- data/lib/mutant/singleton_methods.rb +5 -3
- data/lib/mutant/strategy.rb +2 -0
- data/lib/mutant/strategy/method_expansion.rb +2 -0
- data/lib/mutant/strategy/rspec.rb +2 -0
- data/lib/mutant/strategy/rspec/dm2.rb +2 -0
- data/lib/mutant/strategy/rspec/dm2/lookup.rb +4 -2
- data/lib/mutant/strategy/rspec/dm2/lookup/method.rb +2 -0
- data/lib/mutant/strategy/static.rb +2 -0
- data/lib/mutant/subject.rb +4 -1
- data/lib/mutant/subject/method.rb +2 -0
- data/lib/mutant/subject/method/instance.rb +2 -0
- data/lib/mutant/subject/method/singleton.rb +2 -0
- data/lib/mutant/support/method_object.rb +2 -0
- data/lib/mutant/zombifier.rb +10 -6
- data/mutant.gemspec +11 -10
- data/spec/integration/mutant/rspec_killer_spec.rb +9 -4
- data/spec/integration/mutant/test_mutator_handles_types_spec.rb +3 -1
- data/spec/integration/mutant/zombie_spec.rb +2 -0
- data/spec/shared/method_matcher_behavior.rb +2 -0
- data/spec/shared/mutator_behavior.rb +16 -7
- data/spec/spec_helper.rb +26 -5
- data/spec/support/compress_helper.rb +5 -5
- data/spec/support/ice_nine_config.rb +2 -0
- data/spec/support/rspec.rb +2 -0
- data/spec/support/test_app.rb +2 -0
- data/spec/unit/mutant/class_methods/singleton_subclass_instance_spec.rb +2 -0
- data/spec/unit/mutant/cli/class_methods/new_spec.rb +17 -8
- data/spec/unit/mutant/cli/class_methods/run_spec.rb +10 -2
- data/spec/unit/mutant/cli/classifier/class_methods/build_spec.rb +4 -1
- data/spec/unit/mutant/cli/classifier/method/each_spec.rb +89 -0
- data/spec/unit/mutant/cli/classifier/namespace/flat/each_spec.rb +58 -0
- data/spec/unit/mutant/cli/classifier/namespace/recursive/each_spec.rb +58 -0
- data/spec/unit/mutant/cli/classifier/scope/each_spec.rb +33 -0
- data/spec/unit/mutant/context/root_spec.rb +5 -1
- data/spec/unit/mutant/context/scope/root_spec.rb +2 -0
- data/spec/unit/mutant/context/scope/unqualified_name_spec.rb +2 -0
- data/spec/unit/mutant/differ/class_methods/build_spec.rb +2 -0
- data/spec/unit/mutant/differ/class_methods/colorize_line_spec.rb +2 -0
- data/spec/unit/mutant/differ/diff_spec.rb +67 -5
- data/spec/unit/mutant/killer/rspec/class_methods/new_spec.rb +21 -4
- data/spec/unit/mutant/killer/success_predicate_spec.rb +2 -0
- data/spec/unit/mutant/loader/eval/class_methods/run_spec.rb +12 -5
- data/spec/unit/mutant/matcher/chain/each_spec.rb +2 -0
- data/spec/unit/mutant/matcher/chain/matchers_spec.rb +2 -0
- data/spec/unit/mutant/matcher/each_spec.rb +8 -1
- data/spec/unit/mutant/matcher/method/instance/class_methods/build_spec.rb +4 -2
- data/spec/unit/mutant/matcher/method/instance/each_spec.rb +21 -20
- data/spec/unit/mutant/matcher/method/singleton/each_spec.rb +22 -19
- data/spec/unit/mutant/matcher/methods/instance/each_spec.rb +8 -3
- data/spec/unit/mutant/matcher/methods/singleton/each_spec.rb +8 -3
- data/spec/unit/mutant/matcher/namespace/each_spec.rb +8 -2
- data/spec/unit/mutant/mutator/each_spec.rb +2 -0
- data/spec/unit/mutant/mutator/emit_new_spec.rb +10 -3
- data/spec/unit/mutant/mutator/emit_spec.rb +4 -2
- data/spec/unit/mutant/mutator/node/and_asgn/mutation_spec.rb +26 -0
- data/spec/unit/mutant/mutator/node/begin/mutation_spec.rb +2 -0
- data/spec/unit/mutant/mutator/node/block/mutation_spec.rb +4 -2
- data/spec/unit/mutant/mutator/node/block_pass/mutation_spec.rb +14 -0
- data/spec/unit/mutant/mutator/node/break/mutation_spec.rb +15 -0
- data/spec/unit/mutant/mutator/node/case/mutation_spec.rb +2 -0
- data/spec/unit/mutant/mutator/node/cbase/mutation_spec.rb +3 -6
- data/spec/unit/mutant/mutator/node/connective/binary/mutation_spec.rb +2 -0
- data/spec/unit/mutant/mutator/node/const/mutation_spec.rb +3 -6
- data/spec/unit/mutant/mutator/node/define/mutation_spec.rb +2 -1
- data/spec/unit/mutant/mutator/node/defined_predicate/mutation_spec.rb +10 -0
- data/spec/unit/mutant/mutator/node/dstr/mutation_spec.rb +21 -0
- data/spec/unit/mutant/mutator/node/dsym/mutation_spec.rb +21 -0
- data/spec/unit/mutant/mutator/node/ensure/mutation_spec.rb +15 -0
- data/spec/unit/mutant/mutator/node/if/mutation_spec.rb +2 -1
- data/spec/unit/mutant/mutator/node/literal/array_spec.rb +2 -0
- data/spec/unit/mutant/mutator/node/literal/boolean/mutation_spec.rb +2 -0
- data/spec/unit/mutant/mutator/node/literal/fixnum_spec.rb +2 -0
- data/spec/unit/mutant/mutator/node/literal/float_spec.rb +4 -2
- data/spec/unit/mutant/mutator/node/literal/hash_spec.rb +2 -0
- data/spec/unit/mutant/mutator/node/literal/nil_spec.rb +4 -5
- data/spec/unit/mutant/mutator/node/literal/range_spec.rb +8 -8
- data/spec/unit/mutant/mutator/node/literal/regex_spec.rb +2 -0
- data/spec/unit/mutant/mutator/node/literal/string_spec.rb +2 -0
- data/spec/unit/mutant/mutator/node/literal/symbol_spec.rb +2 -0
- data/spec/unit/mutant/mutator/node/masgn/mutation_spec.rb +4 -10
- data/spec/unit/mutant/mutator/node/match_current_line/mutation_spec.rb +20 -0
- data/spec/unit/mutant/mutator/node/named_value/access/mutation_spec.rb +3 -2
- data/spec/unit/mutant/mutator/node/named_value/constant_assignment/mutation_spec.rb +3 -2
- data/spec/unit/mutant/mutator/node/named_value/variable_assignment/mutation_spec.rb +3 -2
- data/spec/unit/mutant/mutator/node/next/mutation_spec.rb +15 -0
- data/spec/unit/mutant/mutator/node/op_assgn/mutation_spec.rb +26 -0
- data/spec/unit/mutant/mutator/node/or_asgn/mutation_spec.rb +26 -0
- data/spec/unit/mutant/mutator/node/redo/mutation_spec.rb +10 -0
- data/spec/unit/mutant/mutator/node/rescue/mutation_spec.rb +24 -0
- data/spec/unit/mutant/mutator/node/restarg/mutation_spec.rb +16 -0
- data/spec/unit/mutant/mutator/node/return/mutation_spec.rb +2 -0
- data/spec/unit/mutant/mutator/node/send/mutation_spec.rb +3 -1
- data/spec/unit/mutant/mutator/node/super/mutation_spec.rb +2 -0
- data/spec/unit/mutant/mutator/node/while/mutation_spec.rb +3 -1
- data/spec/unit/mutant/mutator/node/yield/mutation_spec.rb +15 -0
- data/spec/unit/mutant/node_helpers/n_not_spec.rb +2 -0
- data/spec/unit/mutant/runner/config/subjects_spec.rb +6 -2
- data/spec/unit/mutant/runner/config/success_predicate_spec.rb +15 -6
- data/spec/unit/mutant/runner/mutation/killer_spec.rb +3 -1
- data/spec/unit/mutant/runner/subject/success_predicate_spec.rb +15 -8
- data/spec/unit/mutant/strategy/method_expansion/class_methods/run_spec.rb +2 -0
- data/spec/unit/mutant/strategy/rspec/dm2/lookup/method/instance/spec_files_spec.rb +32 -11
- data/spec/unit/mutant/strategy/rspec/dm2/lookup/method/singleton/spec_files_spec.rb +31 -11
- data/spec/unit/mutant/subject/context_spec.rb +2 -0
- data/spec/unit/mutant/subject/mutations_spec.rb +2 -0
- data/spec/unit/mutant/subject/node_spec.rb +2 -0
- data/test_app/lib/test_app.rb +2 -0
- data/test_app/lib/test_app/literal.rb +2 -0
- data/test_app/spec/shared/method_filter_parse_behavior.rb +5 -1
- data/test_app/spec/shared/method_match_behavior.rb +2 -0
- data/test_app/spec/spec_helper.rb +3 -1
- data/test_app/spec/unit/test_app/literal/command_spec.rb +2 -0
- data/test_app/spec/unit/test_app/literal/string_spec.rb +3 -1
- metadata +66 -18
- data/bin/zombie +0 -18
- data/test_app/spec/shared/mutator_behavior.rb +0 -44
data/lib/mutant/runner/config.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
1
3
|
# Singleton methods are defined here so zombie can pick them up
|
|
2
4
|
module Mutant
|
|
3
5
|
|
|
@@ -12,13 +14,13 @@ module Mutant
|
|
|
12
14
|
#
|
|
13
15
|
def self.singleton_subclass_instance(name, superclass, &block)
|
|
14
16
|
klass = Class.new(superclass) do
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
def inspect
|
|
18
|
+
self.class.name
|
|
19
|
+
end
|
|
17
20
|
|
|
18
21
|
define_singleton_method(:name) do
|
|
19
22
|
"#{superclass.name}::#{name}".freeze
|
|
20
23
|
end
|
|
21
|
-
|
|
22
24
|
end
|
|
23
25
|
klass.class_eval(&block)
|
|
24
26
|
superclass.const_set(name, klass.new)
|
data/lib/mutant/strategy.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
1
3
|
module Mutant
|
|
2
4
|
class Strategy
|
|
3
5
|
class Rspec
|
|
@@ -38,13 +40,13 @@ module Mutant
|
|
|
38
40
|
# @api private
|
|
39
41
|
#
|
|
40
42
|
def self.handle(subject_class)
|
|
41
|
-
REGISTRY[subject_class]=self
|
|
43
|
+
REGISTRY[subject_class] = self
|
|
42
44
|
end
|
|
43
45
|
private_class_method :handle
|
|
44
46
|
|
|
45
47
|
# Build lookup object
|
|
46
48
|
#
|
|
47
|
-
# @param [
|
|
49
|
+
# @param [Subject] subject
|
|
48
50
|
#
|
|
49
51
|
# @return [Lookup]
|
|
50
52
|
#
|
data/lib/mutant/subject.rb
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
1
3
|
module Mutant
|
|
2
4
|
# Subject of a mutation
|
|
3
5
|
class Subject
|
|
4
|
-
include AbstractType, Adamantium::Flat, Enumerable
|
|
6
|
+
include AbstractType, Adamantium::Flat, Enumerable
|
|
7
|
+
include Concord::Public.new(:context, :node)
|
|
5
8
|
|
|
6
9
|
# Return mutations
|
|
7
10
|
#
|
data/lib/mutant/zombifier.rb
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
1
3
|
module Mutant
|
|
2
4
|
# Zombifier namespace
|
|
3
5
|
module Zombifier
|
|
4
6
|
|
|
5
7
|
# Excluded from zombification, reasons
|
|
6
8
|
#
|
|
7
|
-
# * Relies dynamic require, zombifier does not know how to recurse
|
|
9
|
+
# * Relies dynamic require, zombifier does not know how to recurse (racc)
|
|
8
10
|
# * Unparser bug (optparse)
|
|
9
11
|
# * Toplevel reference/cbase nodes in code (rspec)
|
|
10
12
|
# * Creates useless toplevel modules that get vendored under ::Zombie (set)
|
|
@@ -141,10 +143,10 @@ module Mutant
|
|
|
141
143
|
#
|
|
142
144
|
def self.find_uncached(logical_name)
|
|
143
145
|
file_name =
|
|
144
|
-
|
|
145
|
-
"#{logical_name}.rb"
|
|
146
|
-
else
|
|
146
|
+
if logical_name.end_with?('.rb')
|
|
147
147
|
logical_name
|
|
148
|
+
else
|
|
149
|
+
"#{logical_name}.rb"
|
|
148
150
|
end
|
|
149
151
|
|
|
150
152
|
$LOAD_PATH.each do |path|
|
|
@@ -218,7 +220,9 @@ module Mutant
|
|
|
218
220
|
children = node.type == :begin ? node.children : [node]
|
|
219
221
|
children.select do |node|
|
|
220
222
|
children = node.children
|
|
221
|
-
node.type == :send &&
|
|
223
|
+
node.type == :send &&
|
|
224
|
+
children.at(RECEIVER_INDEX).nil? &&
|
|
225
|
+
children.at(SELECTOR_INDEX) == :require
|
|
222
226
|
end
|
|
223
227
|
end
|
|
224
228
|
|
|
@@ -248,7 +252,7 @@ module Mutant
|
|
|
248
252
|
# @api private
|
|
249
253
|
#
|
|
250
254
|
def root_file
|
|
251
|
-
File.find(name)
|
|
255
|
+
File.find(name) or raise 'No root file!'
|
|
252
256
|
end
|
|
253
257
|
memoize :root_file
|
|
254
258
|
|
data/mutant.gemspec
CHANGED
|
@@ -1,24 +1,23 @@
|
|
|
1
|
-
#
|
|
1
|
+
# encoding: utf-8
|
|
2
2
|
|
|
3
3
|
Gem::Specification.new do |gem|
|
|
4
4
|
gem.name = 'mutant'
|
|
5
|
-
gem.version = '0.3.0.
|
|
6
|
-
gem.authors = [
|
|
7
|
-
gem.email = [
|
|
8
|
-
|
|
5
|
+
gem.version = '0.3.0.beta22'
|
|
6
|
+
gem.authors = ['Markus Schirp']
|
|
7
|
+
gem.email = ['mbj@schirp-dso.com']
|
|
9
8
|
gem.description = 'Mutation testing for ruby'
|
|
10
9
|
gem.summary = 'Mutation testing tool for ruby under MRI and Rubinius'
|
|
11
10
|
gem.homepage = 'https://github.com/mbj/mutant'
|
|
12
11
|
gem.license = 'MIT'
|
|
13
12
|
|
|
14
|
-
gem.require_paths = [
|
|
13
|
+
gem.require_paths = %w[lib]
|
|
15
14
|
gem.files = `git ls-files`.split("\n")
|
|
16
|
-
gem.test_files = `git ls-files -- spec`.split("\n")
|
|
15
|
+
gem.test_files = `git ls-files -- spec/{unit,integration}`.split("\n")
|
|
17
16
|
gem.extra_rdoc_files = %w[TODO LICENSE]
|
|
18
|
-
gem.executables = [
|
|
17
|
+
gem.executables = %w[mutant]
|
|
19
18
|
|
|
20
|
-
gem.add_runtime_dependency('parser', '~> 2.0.0.
|
|
21
|
-
gem.add_runtime_dependency('unparser', '~> 0.0.
|
|
19
|
+
gem.add_runtime_dependency('parser', '~> 2.0.0.pre3')
|
|
20
|
+
gem.add_runtime_dependency('unparser', '~> 0.0.13')
|
|
22
21
|
gem.add_runtime_dependency('ice_nine', '~> 0.8.0')
|
|
23
22
|
gem.add_runtime_dependency('descendants_tracker', '~> 0.0.1')
|
|
24
23
|
gem.add_runtime_dependency('adamantium', '~> 0.0.10')
|
|
@@ -27,4 +26,6 @@ Gem::Specification.new do |gem|
|
|
|
27
26
|
gem.add_runtime_dependency('anima', '~> 0.0.6')
|
|
28
27
|
gem.add_runtime_dependency('concord', '~> 0.1.1')
|
|
29
28
|
gem.add_runtime_dependency('rspec', '~> 2.14.1')
|
|
29
|
+
|
|
30
|
+
gem.add_development_dependency('bundler', '~> 1.3', '>= 1.3.5')
|
|
30
31
|
end
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
|
-
describe Mutant,'rspec integration' do
|
|
5
|
+
describe Mutant, 'rspec integration' do
|
|
4
6
|
|
|
5
7
|
around do |example|
|
|
6
8
|
Dir.chdir(TestApp.root) do
|
|
@@ -11,14 +13,17 @@ describe Mutant,'rspec integration' do
|
|
|
11
13
|
let(:strategy) { Mutant::Strategy::Rspec::DM2 }
|
|
12
14
|
|
|
13
15
|
specify 'allows to kill mutations' do
|
|
14
|
-
|
|
16
|
+
cli = 'bundle exec mutant --rspec-dm2 ::TestApp::Literal#string'
|
|
17
|
+
Kernel.system(cli).should be(true)
|
|
15
18
|
end
|
|
16
19
|
|
|
17
20
|
specify 'fails to kill mutations when they are not covered' do
|
|
18
|
-
|
|
21
|
+
cli = 'bundle exec mutant --rspec-dm2 ::TestApp::Literal#uncovered_string'
|
|
22
|
+
Kernel.system(cli).should be(false)
|
|
19
23
|
end
|
|
20
24
|
|
|
21
25
|
specify 'fails when some mutations when are not covered' do
|
|
22
|
-
|
|
26
|
+
cli = 'bundle exec mutant --rspec-dm2 ::TestApp::Literal'
|
|
27
|
+
Kernel.system(cli).should be(false)
|
|
23
28
|
end
|
|
24
29
|
end
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
describe Mutant do
|
|
4
6
|
specify 'mutant should not crash for any node parser can generate' do
|
|
5
7
|
Mutant::NODE_TYPES.each do |type|
|
|
6
|
-
Mutant::Mutator::
|
|
8
|
+
Mutant::Mutator::Registry.lookup(Mutant::NodeHelpers.s(type))
|
|
7
9
|
end
|
|
8
10
|
end
|
|
9
11
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
1
3
|
class Subject
|
|
2
4
|
|
|
3
5
|
include Equalizer.new(:source)
|
|
@@ -32,7 +34,7 @@ class Subject
|
|
|
32
34
|
again = Unparser.generate(parsed)
|
|
33
35
|
unless generated == again
|
|
34
36
|
# mostly an unparser bug!
|
|
35
|
-
fail "Untransitive:\n%s\n---\n%s"
|
|
37
|
+
fail sprintf("Untransitive:\n%s\n---\n%s", generated, again)
|
|
36
38
|
end
|
|
37
39
|
self
|
|
38
40
|
end
|
|
@@ -56,9 +58,7 @@ shared_examples_for 'a mutator' do
|
|
|
56
58
|
it { should be_instance_of(to_enum.class) }
|
|
57
59
|
|
|
58
60
|
let(:expected_mutations) do
|
|
59
|
-
mutations.map
|
|
60
|
-
Subject.coerce(mutation)
|
|
61
|
-
end
|
|
61
|
+
mutations.map(&Subject.method(:coerce))
|
|
62
62
|
end
|
|
63
63
|
|
|
64
64
|
let(:generated_mutations) do
|
|
@@ -74,16 +74,25 @@ shared_examples_for 'a mutator' do
|
|
|
74
74
|
message = []
|
|
75
75
|
|
|
76
76
|
if missing.any?
|
|
77
|
-
message << 'Missing mutations (%i):'
|
|
77
|
+
message << sprintf('Missing mutations (%i):', missing.length)
|
|
78
78
|
message.concat(missing)
|
|
79
79
|
end
|
|
80
80
|
|
|
81
81
|
if unexpected.any?
|
|
82
|
-
message << 'Unexpected mutations (%i):'
|
|
82
|
+
message << sprintf('Unexpected mutations (%i):', unexpected.length)
|
|
83
83
|
message.concat(unexpected)
|
|
84
84
|
end
|
|
85
85
|
|
|
86
|
-
|
|
86
|
+
if message.any?
|
|
87
|
+
|
|
88
|
+
message = sprintf(
|
|
89
|
+
"Original:\n%s\n-----\n%s",
|
|
90
|
+
generate(node),
|
|
91
|
+
message.join("\n-----\n")
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
fail message
|
|
95
|
+
end
|
|
87
96
|
end
|
|
88
97
|
end
|
|
89
98
|
end
|
data/spec/spec_helper.rb
CHANGED
|
@@ -1,8 +1,29 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'equalizer'
|
|
4
|
+
require 'devtools/spec_helper'
|
|
5
|
+
|
|
6
|
+
if ENV['COVERAGE'] == 'true'
|
|
7
|
+
require 'simplecov'
|
|
8
|
+
require 'coveralls'
|
|
9
|
+
|
|
10
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
|
11
|
+
SimpleCov::Formatter::HTMLFormatter,
|
|
12
|
+
Coveralls::SimpleCov::Formatter
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
SimpleCov.start do
|
|
16
|
+
command_name 'spec:unit'
|
|
17
|
+
add_filter 'config'
|
|
18
|
+
add_filter 'spec'
|
|
19
|
+
add_filter 'test_app'
|
|
20
|
+
minimum_coverage 89.56 # TODO: raise this to 100, then mutation test
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
1
24
|
require 'mutant'
|
|
2
|
-
require 'devtools'
|
|
3
|
-
Devtools.init_spec_helper
|
|
4
25
|
|
|
5
|
-
|
|
26
|
+
$LOAD_PATH << File.join(TestApp.root, 'lib')
|
|
6
27
|
|
|
7
28
|
require 'test_app'
|
|
8
29
|
|
|
@@ -24,7 +45,7 @@ RSpec.configure do |config|
|
|
|
24
45
|
config.include(CompressHelper)
|
|
25
46
|
config.include(ParserHelper)
|
|
26
47
|
config.include(Mutant::NodeHelpers)
|
|
27
|
-
config.mock_with :rspec do |
|
|
28
|
-
|
|
48
|
+
config.mock_with :rspec do |rspec|
|
|
49
|
+
rspec.syntax = [:expect, :should]
|
|
29
50
|
end
|
|
30
51
|
end
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
1
3
|
module CompressHelper
|
|
2
4
|
def strip_indent(string)
|
|
3
|
-
lines
|
|
4
|
-
match
|
|
5
|
+
lines = string.lines
|
|
6
|
+
match = /\A( *)/.match(lines.first)
|
|
5
7
|
whitespaces = match[1].to_s.length
|
|
6
|
-
|
|
7
|
-
line[whitespaces..-1]
|
|
8
|
-
end.join
|
|
8
|
+
lines.map { |line| line[whitespaces..-1] }.join
|
|
9
9
|
end
|
|
10
10
|
end
|
data/spec/support/rspec.rb
CHANGED
data/spec/support/test_app.rb
CHANGED