deep-cover 0.6.2 → 0.6.3.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (139) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -1
  3. data/.rspec +2 -1
  4. data/.rspec_all +2 -1
  5. data/.rubocop.yml +8 -9
  6. data/Gemfile +2 -0
  7. data/Rakefile +32 -6
  8. data/bin/cov +3 -3
  9. data/deep_cover.gemspec +3 -16
  10. data/exe/deep-cover +5 -0
  11. data/lib/deep_cover/cli/debugger.rb +1 -1
  12. data/lib/deep_cover/cli/exec.rb +1 -1
  13. data/lib/deep_cover/cli/instrumented_clone_reporter.rb +5 -3
  14. data/lib/deep_cover/cli/runner.rb +2 -2
  15. data/lib/deep_cover/{tools/dump_covered_code.rb → dump_covered_code.rb} +2 -0
  16. metadata +10 -203
  17. data/lib/deep-cover.rb +0 -3
  18. data/lib/deep_cover.rb +0 -22
  19. data/lib/deep_cover/analyser.rb +0 -23
  20. data/lib/deep_cover/analyser/base.rb +0 -104
  21. data/lib/deep_cover/analyser/branch.rb +0 -41
  22. data/lib/deep_cover/analyser/covered_code_source.rb +0 -21
  23. data/lib/deep_cover/analyser/function.rb +0 -14
  24. data/lib/deep_cover/analyser/node.rb +0 -54
  25. data/lib/deep_cover/analyser/per_char.rb +0 -38
  26. data/lib/deep_cover/analyser/per_line.rb +0 -41
  27. data/lib/deep_cover/analyser/ruby25_like_branch.rb +0 -211
  28. data/lib/deep_cover/analyser/statement.rb +0 -33
  29. data/lib/deep_cover/analyser/stats.rb +0 -54
  30. data/lib/deep_cover/analyser/subset.rb +0 -27
  31. data/lib/deep_cover/auto_run.rb +0 -71
  32. data/lib/deep_cover/autoload_tracker.rb +0 -215
  33. data/lib/deep_cover/backports.rb +0 -22
  34. data/lib/deep_cover/base.rb +0 -117
  35. data/lib/deep_cover/basics.rb +0 -22
  36. data/lib/deep_cover/builtin_takeover.rb +0 -10
  37. data/lib/deep_cover/config.rb +0 -104
  38. data/lib/deep_cover/config_setter.rb +0 -33
  39. data/lib/deep_cover/core_ext/autoload_overrides.rb +0 -112
  40. data/lib/deep_cover/core_ext/coverage_replacement.rb +0 -61
  41. data/lib/deep_cover/core_ext/exec_callbacks.rb +0 -27
  42. data/lib/deep_cover/core_ext/instruction_sequence_load_iseq.rb +0 -32
  43. data/lib/deep_cover/core_ext/load_overrides.rb +0 -19
  44. data/lib/deep_cover/core_ext/require_overrides.rb +0 -28
  45. data/lib/deep_cover/coverage.rb +0 -125
  46. data/lib/deep_cover/coverage/analysis.rb +0 -42
  47. data/lib/deep_cover/coverage/persistence.rb +0 -84
  48. data/lib/deep_cover/covered_code.rb +0 -145
  49. data/lib/deep_cover/custom_requirer.rb +0 -187
  50. data/lib/deep_cover/flag_comment_associator.rb +0 -68
  51. data/lib/deep_cover/load.rb +0 -66
  52. data/lib/deep_cover/memoize.rb +0 -48
  53. data/lib/deep_cover/module_override.rb +0 -39
  54. data/lib/deep_cover/node.rb +0 -23
  55. data/lib/deep_cover/node/arguments.rb +0 -51
  56. data/lib/deep_cover/node/assignments.rb +0 -273
  57. data/lib/deep_cover/node/base.rb +0 -155
  58. data/lib/deep_cover/node/begin.rb +0 -27
  59. data/lib/deep_cover/node/block.rb +0 -61
  60. data/lib/deep_cover/node/branch.rb +0 -32
  61. data/lib/deep_cover/node/case.rb +0 -113
  62. data/lib/deep_cover/node/collections.rb +0 -31
  63. data/lib/deep_cover/node/const.rb +0 -12
  64. data/lib/deep_cover/node/def.rb +0 -40
  65. data/lib/deep_cover/node/empty_body.rb +0 -32
  66. data/lib/deep_cover/node/exceptions.rb +0 -79
  67. data/lib/deep_cover/node/if.rb +0 -73
  68. data/lib/deep_cover/node/keywords.rb +0 -86
  69. data/lib/deep_cover/node/literals.rb +0 -100
  70. data/lib/deep_cover/node/loops.rb +0 -74
  71. data/lib/deep_cover/node/mixin/can_augment_children.rb +0 -65
  72. data/lib/deep_cover/node/mixin/check_completion.rb +0 -18
  73. data/lib/deep_cover/node/mixin/child_can_be_empty.rb +0 -27
  74. data/lib/deep_cover/node/mixin/executed_after_children.rb +0 -15
  75. data/lib/deep_cover/node/mixin/execution_location.rb +0 -66
  76. data/lib/deep_cover/node/mixin/filters.rb +0 -47
  77. data/lib/deep_cover/node/mixin/flow_accounting.rb +0 -71
  78. data/lib/deep_cover/node/mixin/has_child.rb +0 -145
  79. data/lib/deep_cover/node/mixin/has_child_handler.rb +0 -75
  80. data/lib/deep_cover/node/mixin/has_tracker.rb +0 -46
  81. data/lib/deep_cover/node/mixin/is_statement.rb +0 -20
  82. data/lib/deep_cover/node/mixin/rewriting.rb +0 -35
  83. data/lib/deep_cover/node/mixin/wrapper.rb +0 -15
  84. data/lib/deep_cover/node/module.rb +0 -66
  85. data/lib/deep_cover/node/root.rb +0 -20
  86. data/lib/deep_cover/node/send.rb +0 -161
  87. data/lib/deep_cover/node/short_circuit.rb +0 -42
  88. data/lib/deep_cover/node/splat.rb +0 -15
  89. data/lib/deep_cover/node/variables.rb +0 -16
  90. data/lib/deep_cover/parser_ext/range.rb +0 -21
  91. data/lib/deep_cover/problem_with_diagnostic.rb +0 -63
  92. data/lib/deep_cover/reporter.rb +0 -10
  93. data/lib/deep_cover/reporter/base.rb +0 -68
  94. data/lib/deep_cover/reporter/html.rb +0 -15
  95. data/lib/deep_cover/reporter/html/base.rb +0 -14
  96. data/lib/deep_cover/reporter/html/index.rb +0 -59
  97. data/lib/deep_cover/reporter/html/site.rb +0 -70
  98. data/lib/deep_cover/reporter/html/source.rb +0 -136
  99. data/lib/deep_cover/reporter/html/template/assets/32px.png +0 -0
  100. data/lib/deep_cover/reporter/html/template/assets/40px.png +0 -0
  101. data/lib/deep_cover/reporter/html/template/assets/deep_cover.css.sass +0 -336
  102. data/lib/deep_cover/reporter/html/template/assets/jquery-3.2.1.min.js +0 -4
  103. data/lib/deep_cover/reporter/html/template/assets/jquery-3.2.1.min.map +0 -1
  104. data/lib/deep_cover/reporter/html/template/assets/jstree.css +0 -1108
  105. data/lib/deep_cover/reporter/html/template/assets/jstree.js +0 -8424
  106. data/lib/deep_cover/reporter/html/template/assets/jstreetable.js +0 -1069
  107. data/lib/deep_cover/reporter/html/template/assets/throbber.gif +0 -0
  108. data/lib/deep_cover/reporter/html/template/index.html.erb +0 -75
  109. data/lib/deep_cover/reporter/html/template/source.html.erb +0 -35
  110. data/lib/deep_cover/reporter/istanbul.rb +0 -184
  111. data/lib/deep_cover/reporter/text.rb +0 -58
  112. data/lib/deep_cover/reporter/tree/util.rb +0 -86
  113. data/lib/deep_cover/tools.rb +0 -22
  114. data/lib/deep_cover/tools/blank.rb +0 -25
  115. data/lib/deep_cover/tools/builtin_coverage.rb +0 -55
  116. data/lib/deep_cover/tools/camelize.rb +0 -13
  117. data/lib/deep_cover/tools/content_tag.rb +0 -11
  118. data/lib/deep_cover/tools/covered.rb +0 -9
  119. data/lib/deep_cover/tools/execute_sample.rb +0 -34
  120. data/lib/deep_cover/tools/format.rb +0 -18
  121. data/lib/deep_cover/tools/format_char_cover.rb +0 -19
  122. data/lib/deep_cover/tools/format_generated_code.rb +0 -27
  123. data/lib/deep_cover/tools/indent_string.rb +0 -26
  124. data/lib/deep_cover/tools/merge.rb +0 -16
  125. data/lib/deep_cover/tools/number_lines.rb +0 -22
  126. data/lib/deep_cover/tools/our_coverage.rb +0 -11
  127. data/lib/deep_cover/tools/profiling.rb +0 -68
  128. data/lib/deep_cover/tools/render_template.rb +0 -13
  129. data/lib/deep_cover/tools/require_relative_dir.rb +0 -12
  130. data/lib/deep_cover/tools/scan_match_datas.rb +0 -10
  131. data/lib/deep_cover/tools/silence_warnings.rb +0 -18
  132. data/lib/deep_cover/tools/slice.rb +0 -9
  133. data/lib/deep_cover/tools/strip_heredoc.rb +0 -18
  134. data/lib/deep_cover/tools/truncate_backtrace.rb +0 -32
  135. data/lib/deep_cover/tracker_bucket.rb +0 -50
  136. data/lib/deep_cover/tracker_hits_per_path.rb +0 -35
  137. data/lib/deep_cover/tracker_storage.rb +0 -76
  138. data/lib/deep_cover/tracker_storage_per_path.rb +0 -34
  139. data/lib/deep_cover/version.rb +0 -5
@@ -1,22 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Basic constants without any dependencies are here
4
- module DeepCover
5
- DEFAULTS = {
6
- ignore_uncovered: [].freeze,
7
- paths: %w[./app ./lib].freeze,
8
- allow_partial: false,
9
- tracker_global: '$_cov',
10
- reporter: :html,
11
- output: './coverage',
12
- }.freeze
13
-
14
- CLI_DEFAULTS = {
15
- command: 'bundle exec rake',
16
- bundle: true,
17
- process: true,
18
- open: false,
19
- }.freeze
20
-
21
- OPTIONALLY_COVERED = %i[case_implicit_else default_argument raise trivial_if warn]
22
- end
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative '../deep_cover'
4
- require_relative 'coverage'
5
- require_relative 'core_ext/coverage_replacement'
6
-
7
- require 'coverage'
8
- BuiltinCoverage = Coverage
9
- Object.send(:remove_const, 'Coverage')
10
- Coverage = DeepCover::CoverageReplacement.dup
@@ -1,104 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module DeepCover
4
- class Config
5
- def initialize(notify = nil)
6
- @notify = notify
7
- @options = DEFAULTS.dup
8
- end
9
-
10
- def to_hash
11
- @options.dup
12
- end
13
- alias_method :to_h, :to_hash
14
-
15
- def ignore_uncovered(*keywords, &block)
16
- if block
17
- raise ArgumentError, "wrong number of arguments (given #{keywords.size}, expected 0..1)" if keywords.size > 1
18
- keywords << Node.unique_filter if keywords.empty?
19
- Node.create_filter(keywords.first, &block)
20
- end
21
- if keywords.empty?
22
- @options[:ignore_uncovered]
23
- else
24
- keywords = check_uncovered(keywords)
25
- change(:ignore_uncovered, @options[:ignore_uncovered] | keywords)
26
- end
27
- end
28
-
29
- def detect_uncovered(*keywords)
30
- raise ArgumentError, 'No block is accepted' if block_given?
31
- if keywords.empty?
32
- OPTIONALLY_COVERED - @options[:ignore_uncovered]
33
- else
34
- keywords = check_uncovered(keywords)
35
- change(:ignore_uncovered, @options[:ignore_uncovered] - keywords)
36
- end
37
- end
38
-
39
- def paths(paths = nil)
40
- if paths
41
- change(:paths, Array(paths).dup)
42
- else
43
- @options[:paths]
44
- end
45
- end
46
-
47
- def tracker_global(tracker_global = nil)
48
- if tracker_global
49
- change(:tracker_global, tracker_global)
50
- else
51
- @options[:tracker_global]
52
- end
53
- end
54
-
55
- def reporter(reporter = nil)
56
- if reporter
57
- change(:reporter, reporter)
58
- else
59
- @options[:reporter]
60
- end
61
- end
62
-
63
- def output(path_or_false = nil)
64
- if path_or_false != nil
65
- change(:output, path_or_false)
66
- else
67
- @options[:output]
68
- end
69
- end
70
-
71
- def reset
72
- DEFAULTS.each do |key, value|
73
- change(key, value)
74
- end
75
- self
76
- end
77
-
78
- def set(**options)
79
- @options[:ignore_uncovered] = [] if options.has_key?(:ignore_uncovered)
80
- options.each do |key, value|
81
- next if key == :allow_partial
82
- public_send key, value
83
- end
84
- self
85
- end
86
-
87
- private
88
-
89
- def check_uncovered(keywords)
90
- keywords = keywords.first if keywords.size == 1 && keywords.first.is_a?(Array)
91
- unknown = keywords - OPTIONALLY_COVERED
92
- raise ArgumentError, "unknown options: #{unknown.join(', ')}" unless unknown.empty?
93
- keywords
94
- end
95
-
96
- def change(option, value)
97
- if @options[option] != value
98
- @options[option] = value.freeze
99
- @notify.config_changed(option) if @notify.respond_to? :config_changed
100
- end
101
- self
102
- end
103
- end
104
- end
@@ -1,33 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module DeepCover
4
- module ConfigSetter
5
- def config_queue
6
- @config_queue ||= []
7
- end
8
-
9
- def config(notify = self)
10
- raise ArgumentError, 'config does not accept an argument. Did you mean `configure`?' if block_given?
11
- @config ||= Config.new(notify)
12
- config_queue.each { |block| configure(&block) }
13
- config_queue.clear
14
- @config
15
- end
16
-
17
- def configure(&block)
18
- raise 'Must provide a block' unless block
19
- @config ||= nil # avoid warning
20
- if @config == nil
21
- config_queue << block
22
- else
23
- case block.arity
24
- when 0
25
- @config.instance_eval(&block)
26
- when 1
27
- block.call(@config)
28
- end
29
- end
30
- self
31
- end
32
- end
33
- end
@@ -1,112 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Autoload is quite difficult to hook into to do what we need to do.
4
- #
5
- # We create a temporary file that gets set as path for autoloads. The file then does a require of the
6
- # autoloaded file. We also keep track of autoloaded constants and files and change the autoload's target when
7
- # those files get required (or when we guess they are being).
8
- #
9
- # Doing it this way solves:
10
- #
11
- # * When autoload is triggered, it doesn't always call `require`. In Ruby 2.1 and 2.2, it just loads the
12
- # file somehow without using require, this means we can't instrument autoloaded files. Using an intercept
13
- # file means that the intercept is not covered (we don't care) and then the manual require will
14
- # allow us to instrument the real target.
15
- #
16
- # * When autoload is triggered, there are special states setup internal to ruby to allow constants to
17
- # be used conditionally. If the target file is not actually required (such as when using our custom requirer),
18
- # then the state is not correct and we can't do simple things such as `A ||= 1` or `module A; ...; end`.
19
- # This problem was happening when all we did was use the custom require that does get called for Ruby 2.3+.
20
- #
21
- # To solve the issues, we keep track of all the autoloads, and when we detect that a file is being autoloaded,
22
- # we change the state so that ruby thinks the file was already loaded.
23
- #
24
- # * An issue with the interceptor files is that if some code manually requires a file that is the target of
25
- # autoloading, ruby would not disable the autoload behavior, and would end up trying to autoload once the constant
26
- # is reached.
27
- #
28
- # To solve this, every require, we check if it is for a file that is is meant to autoload a constant, and if so,
29
- # we remove that autoload.
30
- #
31
- # * To make matter more complicated, when loading gems without bundle's setup, the $LOAD_PATH is filled by RubyGems
32
- # as part of a monkey-patch of Kernel#require. Because of this, we can't always find the file that will be required,
33
- # even though a file will indeed be required.
34
- #
35
- # However, if nothing is done, the autoload can cause problems on that built-in require (as explained in a previous
36
- # point). So when we don't find the target, we check if it's a require that will go through the $LOAD_PATH,
37
- # meaning that require's parameter is not an absolute path, and isn't relative to the current directory (so doesn't
38
- # start with './' or '../').
39
- #
40
- # When a require does go through $LOAD_PATH, we do a best effort to deactivate the autoloads that seem to match
41
- # to match this require by comparing the required path (as it is received) to all the autoload path we have, and
42
- # deactivating those that match. This is only an issue when there is an autoload made which will load a different
43
- # gem. This is pretty rare (but deep-cover does it...)
44
- #
45
- # * All of this changing autoloads means that for modules/classes that are frozen, we can't handle the situation, since
46
- # we can't change the autoload stuff.
47
- #
48
- # We don't resolve this problem. However, we could work around it by always calling the real require for these
49
- # files (which means we wouldn't cover them), and by not creating interceptor files for the autoloads. Since we
50
- # can't know when the #autoload call is made, if the constant will be frozen later on, we would have to instead
51
- # monkey-patch #freeze on modules and classes to remove the interceptor file before things get frozen.
52
- #
53
- # * Kernel#autoload uses the caller's `Module.nesting` instead of using self.
54
- # This means that if we intercept the autoload, then we cannot call the original Kernel#autoload because it will
55
- # now use our Module instead if our caller's. The only reliable solution we've found to this is to use binding_of_caller
56
- # to get the correct object to call autoload on.
57
- #
58
- # (This is not a problem with Module#autoload and Module.autoload)
59
- #
60
- # A possible solution to investigate is to make a simple C extension, to do the work of our monkey-patch, this way,
61
- # the check for the caller doesn't find our callstack
62
- #
63
- # Some situations where Module.nesting of the caller is different from self in Kernel#autoload:
64
- # * When in the top-level: (self: main) vs (Module.nesting: nil, which we default to Object)
65
- # * When called from a method defined on a module that is included:
66
- # module A
67
- # def begin_autoload
68
- # # `Kernel.autoload` would have the same result
69
- # autoload :A1, 'hello'
70
- # end
71
- # end
72
- # class B
73
- # include A
74
- # end
75
- # Calling `B.new.begin_autoload` is equivalent to:
76
- # A.autoload :A1, 'hello'
77
- # NOT this:
78
- # B.autoload :A1, 'hello'
79
- #
80
- require 'binding_of_caller'
81
- require 'tempfile'
82
-
83
- module DeepCover
84
- load_all
85
-
86
- module KernelAutoloadOverride
87
- def autoload(name, path)
88
- mod = binding.of_caller(1).eval('Module.nesting').first || Object
89
- autoload_path = DeepCover.autoload_tracker.autoload_path_for(mod, name, path)
90
- mod.autoload_without_deep_cover(name, autoload_path)
91
- end
92
-
93
- extend ModuleOverride
94
- override ::Kernel, ::Kernel.singleton_class
95
- end
96
-
97
- module ModuleAutoloadOverride
98
- def autoload(name, path)
99
- autoload_path = DeepCover.autoload_tracker.autoload_path_for(self, name, path)
100
- autoload_without_deep_cover(name, autoload_path)
101
- end
102
-
103
- extend ModuleOverride
104
- override Module
105
- end
106
-
107
- module AutoloadOverride
108
- def self.active=(flag)
109
- KernelAutoloadOverride.active = ModuleAutoloadOverride.active = flag
110
- end
111
- end
112
- end
@@ -1,61 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # This is a complete replacement for the builtin Coverage module of Ruby
4
-
5
- module DeepCover
6
- module CoverageReplacement
7
- OLD_COVERAGE_SENTINEL = Object.new
8
- ALL_COVERAGES = {lines: true, branches: true, methods: true}.freeze
9
-
10
- class << self
11
- def running?
12
- DeepCover.running?
13
- end
14
-
15
- def start(targets = OLD_COVERAGE_SENTINEL)
16
- if targets == OLD_COVERAGE_SENTINEL
17
- # Do nothing
18
- elsif targets == :all
19
- targets = ALL_COVERAGES
20
- else
21
- targets = targets.to_hash.slice(*ALL_COVERAGES.keys).select { |_, v| v }
22
- targets = targets.map { |k, v| [k, !!v] }.to_h
23
- raise 'no measuring target is specified' if targets.empty?
24
- end
25
-
26
- if DeepCover.running?
27
- raise 'cannot change the measuring target during coverage measurement' if @started_args != targets
28
- return
29
- end
30
-
31
- @started_args = targets
32
-
33
- DeepCover.start
34
- nil
35
- end
36
-
37
- def result
38
- r = peek_result
39
- DeepCover.stop
40
- r
41
- end
42
-
43
- def peek_result
44
- raise 'coverage measurement is not enabled' unless running?
45
- if @started_args == OLD_COVERAGE_SENTINEL
46
- DeepCover.coverage.covered_codes.map do |covered_code|
47
- [covered_code.path.to_s, covered_code.line_coverage(allow_partial: false)]
48
- end.to_h
49
- else
50
- DeepCover.coverage.covered_codes.map do |covered_code|
51
- cov = {}
52
- cov[:branches] = DeepCover::Analyser::Ruby25LikeBranch.new(covered_code).results if @started_args[:branches]
53
- cov[:lines] = covered_code.line_coverage(allow_partial: false) if @started_args[:lines]
54
- cov[:methods] = {} if @started_args[:methods]
55
- [covered_code.path.to_s, cov]
56
- end.to_h
57
- end
58
- end
59
- end
60
- end
61
- end
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative '../module_override'
4
-
5
- # Adds a functionality to add callbacks before an `exec`
6
-
7
- module DeepCover
8
- module ExecCallbacks
9
- class << self
10
- attr_reader :callbacks
11
-
12
- def before_exec(&block)
13
- self.active = true
14
- (@callbacks ||= []) << block
15
- end
16
- end
17
-
18
- def exec(*args)
19
- ExecCallbacks.callbacks.each(&:call)
20
- exec_without_deep_cover(*args)
21
- end
22
-
23
- extend ModuleOverride
24
- override ::Kernel, ::Kernel.singleton_class
25
- self.active = true
26
- end
27
- end
@@ -1,32 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module DeepCover
4
- load_all
5
-
6
- module InstructionSequenceLoadIseq
7
- def load_iseq(path)
8
- compiled = InstructionSequenceLoadIseq.load_iseq_logic(path)
9
-
10
- return compiled if compiled
11
-
12
- # By default there is no super, but if bootsnap is there, and things are in the right order,
13
- # we could possibly fallback to it as usual to keep the perf gain. Same for other possible
14
- # tools using #load_iseq
15
- super if defined?(super)
16
- end
17
-
18
- def self.load_iseq_logic(path)
19
- return unless DeepCover.running?
20
- return unless DeepCover.within_lookup_paths?(path)
21
-
22
- covered_code = DeepCover.coverage.covered_code_or_warn(path)
23
- return unless covered_code
24
-
25
- covered_code.compile_or_warn
26
- end
27
- end
28
- end
29
-
30
- class << RubyVM::InstructionSequence
31
- prepend DeepCover::InstructionSequenceLoadIseq
32
- end
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # These are the monkeypatches to replace the default #load in order
4
- # to instrument the code before it gets run.
5
- # For now, this is not used, and may never be. The tracking and reporting for things can might be
6
- # loaded multiple times can be complex and is beyond the current scope of the project.
7
-
8
- module DeepCover
9
- module LoadOverride
10
- def load(path, wrap = false)
11
- return load_without_deep_cover(path, wrap) if wrap
12
-
13
- DeepCover.custom_requirer.load(path) { load_without_deep_cover(path) }
14
- end
15
-
16
- extend ModuleOverride
17
- override ::Kernel, ::Kernel.singleton_class
18
- end
19
- end
@@ -1,28 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # These are the monkeypatches to replace the default #require and
4
- # #require_relative in order to instrument the code before it gets run.
5
- # Kernel.require and Kernel#require must both have their version because
6
- # each can have been already overwritten individually. (Rubygems only
7
- # overrides Kernel#require)
8
-
9
- module DeepCover
10
- load_all
11
-
12
- module RequireOverride
13
- def require(path)
14
- DeepCover.custom_requirer.require(path) { require_without_deep_cover(path) }
15
- end
16
-
17
- def require_relative(path)
18
- base = caller(1..1).first[/[^:]+/]
19
- raise LoadError, 'cannot infer basepath' unless base
20
- base = File.dirname(base)
21
-
22
- require(File.absolute_path(path, base))
23
- end
24
-
25
- extend ModuleOverride
26
- override ::Kernel, ::Kernel.singleton_class
27
- end
28
- end