mutant 0.10.20 → 0.10.25

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.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/lib/mutant.rb +23 -4
  3. data/lib/mutant/ast/meta/send.rb +0 -1
  4. data/lib/mutant/ast/regexp.rb +37 -0
  5. data/lib/mutant/ast/regexp/transformer.rb +150 -0
  6. data/lib/mutant/ast/regexp/transformer/direct.rb +121 -0
  7. data/lib/mutant/ast/regexp/transformer/named_group.rb +50 -0
  8. data/lib/mutant/ast/regexp/transformer/options_group.rb +68 -0
  9. data/lib/mutant/ast/regexp/transformer/quantifier.rb +90 -0
  10. data/lib/mutant/ast/regexp/transformer/recursive.rb +56 -0
  11. data/lib/mutant/ast/regexp/transformer/root.rb +28 -0
  12. data/lib/mutant/ast/regexp/transformer/text.rb +58 -0
  13. data/lib/mutant/ast/types.rb +115 -11
  14. data/lib/mutant/cli/command/environment.rb +9 -3
  15. data/lib/mutant/config.rb +8 -54
  16. data/lib/mutant/config/coverage_criteria.rb +61 -0
  17. data/lib/mutant/env.rb +8 -6
  18. data/lib/mutant/expression.rb +0 -12
  19. data/lib/mutant/expression/namespace.rb +1 -1
  20. data/lib/mutant/isolation/fork.rb +1 -1
  21. data/lib/mutant/loader.rb +1 -1
  22. data/lib/mutant/matcher.rb +2 -2
  23. data/lib/mutant/matcher/config.rb +27 -6
  24. data/lib/mutant/matcher/method.rb +2 -3
  25. data/lib/mutant/matcher/method/metaclass.rb +1 -1
  26. data/lib/mutant/meta/example/dsl.rb +6 -1
  27. data/lib/mutant/mutator/node/arguments.rb +0 -2
  28. data/lib/mutant/mutator/node/block.rb +5 -1
  29. data/lib/mutant/mutator/node/dynamic_literal.rb +1 -1
  30. data/lib/mutant/mutator/node/kwargs.rb +44 -0
  31. data/lib/mutant/mutator/node/literal/regex.rb +26 -0
  32. data/lib/mutant/mutator/node/literal/symbol.rb +0 -2
  33. data/lib/mutant/mutator/node/regexp.rb +20 -0
  34. data/lib/mutant/mutator/node/regexp/alternation_meta.rb +20 -0
  35. data/lib/mutant/mutator/node/regexp/beginning_of_line_anchor.rb +20 -0
  36. data/lib/mutant/mutator/node/regexp/capture_group.rb +25 -0
  37. data/lib/mutant/mutator/node/regexp/character_type.rb +31 -0
  38. data/lib/mutant/mutator/node/regexp/end_of_line_anchor.rb +20 -0
  39. data/lib/mutant/mutator/node/regexp/end_of_string_or_before_end_of_line_anchor.rb +20 -0
  40. data/lib/mutant/mutator/node/regexp/zero_or_more.rb +34 -0
  41. data/lib/mutant/mutator/node/sclass.rb +1 -1
  42. data/lib/mutant/mutator/node/send.rb +36 -19
  43. data/lib/mutant/parallel.rb +43 -28
  44. data/lib/mutant/parallel/driver.rb +9 -3
  45. data/lib/mutant/parallel/worker.rb +60 -2
  46. data/lib/mutant/pipe.rb +94 -0
  47. data/lib/mutant/reporter/cli/printer/env.rb +1 -1
  48. data/lib/mutant/reporter/cli/printer/isolation_result.rb +1 -6
  49. data/lib/mutant/result.rb +8 -0
  50. data/lib/mutant/runner.rb +7 -10
  51. data/lib/mutant/runner/sink.rb +12 -2
  52. data/lib/mutant/subject.rb +1 -3
  53. data/lib/mutant/subject/method/instance.rb +2 -4
  54. data/lib/mutant/timer.rb +2 -4
  55. data/lib/mutant/transform.rb +25 -2
  56. data/lib/mutant/version.rb +1 -1
  57. data/lib/mutant/world.rb +1 -2
  58. metadata +48 -9
  59. data/lib/mutant/warnings.rb +0 -106
@@ -1,106 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Mutant
4
- # Class to capture warnings generated by Kernel#warn and Ruby itself.
5
- #
6
- # @example
7
- # capture = Mutant::Warnings.new(Warning)
8
- #
9
- # # Note that this test case shows we can capture warnings generated from C
10
- # def ruby_warning
11
- # Class.new do
12
- # undef :initialize
13
- # end
14
- # end
15
- #
16
- # messages = capture.call do
17
- # ruby_warning
18
- # end
19
- #
20
- # messages # => ["some_file.rb:44: warning: undefining `initialize' may cause serious problems\n"]
21
- #
22
- # Note this API is fundamentally impure:
23
- #
24
- # * Unlike almost all of classes in the mutant code base it has internal
25
- # mutable state
26
- # * Its therefore NOT thread safe
27
- # * And worst: Each instance, even after its not referenced anymore by user
28
- # code: Leaks permanent global state as instances of this class hook
29
- # itself into the `Warning` module.
30
- #
31
- # So ideally only make *one* instance, and re-use it.
32
- #
33
- # Also note, a more canonical implementation would prepend modules and simply
34
- # call `super` in the event the capture is disabled. This sadly does not
35
- # work as it would inference with various bad players in the ruby ecosystem
36
- # that do not adhere to the semantics outlined in the documentation.
37
- #
38
- # See: https://ruby-doc.org/core-2.6.3/Warning.html
39
- #
40
- # For example in case rubygems is active it adds its own hook to warnings,
41
- # that would in case of the super implementation cause infinite recursion.
42
- #
43
- # Reproduction for this case is as simple as:
44
- #
45
- # ```
46
- # require 'rubygems'
47
- #
48
- # module Warning
49
- # def warn(*)
50
- # super
51
- # end
52
- # end
53
- # ```
54
- #
55
- # For that reason we do have to use the original method capture to dispatch
56
- # in disabled state.
57
- #
58
- class Warnings
59
- # Error raised when warning capture is used recursively
60
- class RecursiveUseError < RuntimeError; end
61
-
62
- # Initialize object
63
- #
64
- # @param [Module] warning
65
- # the module to integrate against
66
- #
67
- # @return [undefined]
68
- def initialize(warning)
69
- @disabled = true
70
- @messages = []
71
- @original = warning.public_method(:warn)
72
-
73
- capture = method(:capture)
74
- warning.module_eval do
75
- module_function define_method(:warn, &capture)
76
- end
77
- end
78
-
79
- # Run a block with warning collection enabled
80
- #
81
- # @return [Array<String>]
82
- def call
83
- assert_no_recursion
84
- @disabled = nil
85
- yield
86
- IceNine.deep_freeze(@messages.dup)
87
- ensure
88
- @disabled = true
89
- @messages.clear
90
- end
91
-
92
- private
93
-
94
- def capture(*arguments)
95
- if @disabled
96
- @original.call(*arguments)
97
- else
98
- @messages << arguments
99
- end
100
- end
101
-
102
- def assert_no_recursion
103
- fail RecursiveUseError unless @disabled
104
- end
105
- end # Warnings
106
- end # Mutant