7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/diff_test/trackers/ruby_file.rb', line 7
def initialize
super
do_line_check = ENV['DIFF_TEST_SKIP_LINE_CHECK'] != '1'
@seen_constants = Set.new
@tracepoint = TracePoint.new(:call, :b_call) do |event|
if do_line_check && DiffTest::Helper.file_in_project?(event.path)
record(DiffTest::Helper.relative_path_from_project_root(event.path))
end
constant = event.defined_class
constant = event.self if constant == Class && event.method_id == :new
unless @seen_constants.include?(constant)
@seen_constants.add(constant)
if constant&.singleton_class?
constant = constant.attached_object if constant&.singleton_class?
next if constant.__basic_object?
end
path = @@location_by_constant[constant]
if path.nil?
if constant
path = begin
DiffTest::Helper.const_source_path(constant.name)
rescue StandardError
nil
end
end
path = false if !path || !DiffTest::Helper.file_in_project?(path)
path = DiffTest::Helper.relative_path_from_project_root(path) if path
@@location_by_constant[constant] = path
end
record(path) if path
end
end
end
|