Class: AffectedTests::Engine::Calleree
- Inherits:
-
Object
- Object
- AffectedTests::Engine::Calleree
- Defined in:
- lib/affected_tests/engine/calleree.rb
Instance Method Summary collapse
- #add(caller, callee) ⇒ Object
- #cache ⇒ Object
- #checkpoint(target_test_path) ⇒ Object
- #dump ⇒ Object
- #import(target_test_path, result) ⇒ Object
-
#initialize(config) ⇒ Calleree
constructor
A new instance of Calleree.
- #start_trace ⇒ Object
- #stop_trace ⇒ Object
- #tracing? ⇒ Boolean
Constructor Details
#initialize(config) ⇒ Calleree
6 7 8 9 10 11 |
# File 'lib/affected_tests/engine/calleree.rb', line 6 def initialize(config) @config = config @tracing = true ::Calleree.start end |
Instance Method Details
#add(caller, callee) ⇒ Object
58 59 60 61 |
# File 'lib/affected_tests/engine/calleree.rb', line 58 def add(caller, callee) cache[callee] ||= Set.new cache[callee].add(caller) end |
#cache ⇒ Object
63 64 65 |
# File 'lib/affected_tests/engine/calleree.rb', line 63 def cache Thread.current[:cache] ||= {} end |
#checkpoint(target_test_path) ⇒ Object
26 27 28 29 |
# File 'lib/affected_tests/engine/calleree.rb', line 26 def checkpoint(target_test_path) res = ::Calleree.result(clear: true) import(target_test_path, res) end |
#dump ⇒ Object
67 68 69 70 71 72 |
# File 'lib/affected_tests/engine/calleree.rb', line 67 def dump cache.transform_values(&:to_a) ensure ::Calleree.stop @tracing = false end |
#import(target_test_path, result) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/affected_tests/engine/calleree.rb', line 31 def import(target_test_path, result) caller_in_project = result.select do |(caller_info, _callee_info, _count)| caller_path = caller_info.first @config.target_path?(caller_path) end.map do |(caller_info, _callee_info, _count)| @config.format_path(caller_info.first) end called_in_project = result.select do |(_caller_info, callee_info, _count)| callee_path = callee_info.first @config.target_path?(callee_path) end.map do |(_caller_info, callee_info, _count)| @config.format_path(callee_info.first) end = (called_in_project + caller_in_project).uniq formatted_target_test_path = @config.format_path(target_test_path) .each do |path| next if path.start_with?(@config.test_dir_path) if path != formatted_target_test_path add(formatted_target_test_path, path) end end end |
#start_trace ⇒ Object
13 14 15 16 |
# File 'lib/affected_tests/engine/calleree.rb', line 13 def start_trace # Clear buffer in calleree ::Calleree.result(clear: true) end |
#stop_trace ⇒ Object
18 19 20 |
# File 'lib/affected_tests/engine/calleree.rb', line 18 def stop_trace # do nothing end |
#tracing? ⇒ Boolean
22 23 24 |
# File 'lib/affected_tests/engine/calleree.rb', line 22 def tracing? @tracing # Calleree doesn't have tracing status end |