Class: AffectedTests::Engine::Rotoscope
- Inherits:
-
Object
- Object
- AffectedTests::Engine::Rotoscope
- Defined in:
- lib/affected_tests/engine/rotoscope.rb
Instance Method Summary collapse
- #add(caller, callee) ⇒ Object
- #buffer ⇒ Object
- #cache ⇒ Object
- #checkpoint(target_test_path) ⇒ Object
- #dump ⇒ Object
- #import(target_test_path, result) ⇒ Object
-
#initialize(config) ⇒ Rotoscope
constructor
A new instance of Rotoscope.
- #start_trace ⇒ Object
- #stop_trace ⇒ Object
- #tracing? ⇒ Boolean
Constructor Details
#initialize(config) ⇒ Rotoscope
Returns a new instance of Rotoscope.
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/affected_tests/engine/rotoscope.rb', line 6 def initialize(config) @config = config @rotoscope = ::Rotoscope.new do |call| next if self == call.receiver if call.caller_path && @config.target_path?(call.caller_path) buffer << call.caller_path end end @rotoscope.start_trace end |
Instance Method Details
#add(caller, callee) ⇒ Object
54 55 56 57 |
# File 'lib/affected_tests/engine/rotoscope.rb', line 54 def add(caller, callee) cache[callee] ||= Set.new cache[callee].add(caller) end |
#buffer ⇒ Object
59 60 61 |
# File 'lib/affected_tests/engine/rotoscope.rb', line 59 def buffer Thread.current[:buffer] ||= [] end |
#cache ⇒ Object
63 64 65 |
# File 'lib/affected_tests/engine/rotoscope.rb', line 63 def cache Thread.current[:cache] ||= {} end |
#checkpoint(target_test_path) ⇒ Object
32 33 34 35 36 |
# File 'lib/affected_tests/engine/rotoscope.rb', line 32 def checkpoint(target_test_path) diff = buffer import(target_test_path, diff) buffer.clear end |
#dump ⇒ Object
67 68 69 70 |
# File 'lib/affected_tests/engine/rotoscope.rb', line 67 def dump @rotoscope.stop_trace cache.transform_values(&:to_a) end |
#import(target_test_path, result) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/affected_tests/engine/rotoscope.rb', line 38 def import(target_test_path, result) = result.uniq.map do |caller_path| @config.format_path(caller_path) end 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
19 20 21 22 |
# File 'lib/affected_tests/engine/rotoscope.rb', line 19 def start_trace # Clear buffer buffer.clear end |
#stop_trace ⇒ Object
24 25 26 |
# File 'lib/affected_tests/engine/rotoscope.rb', line 24 def stop_trace # do nothing end |
#tracing? ⇒ Boolean
28 29 30 |
# File 'lib/affected_tests/engine/rotoscope.rb', line 28 def tracing? @rotoscope.tracing? end |