Class: TestMap::FileRecorder
- Inherits:
-
Object
- Object
- TestMap::FileRecorder
- Defined in:
- lib/test_map/file_recorder.rb
Overview
FileRecorder records files accessed during test execution.
Instance Method Summary collapse
-
#initialize ⇒ FileRecorder
constructor
A new instance of FileRecorder.
-
#results ⇒ Object
TODO: also add custom filters, e.g.
- #stop ⇒ Object
- #trace(&block) ⇒ Object
Constructor Details
#initialize ⇒ FileRecorder
Returns a new instance of FileRecorder.
6 |
# File 'lib/test_map/file_recorder.rb', line 6 def initialize = @files = [] |
Instance Method Details
#results ⇒ Object
TODO: also add custom filters, e.g. for vendor directories
26 27 28 29 30 31 32 |
# File 'lib/test_map/file_recorder.rb', line 26 def results raise NotTracedError.default unless @trace @files.filter { _1.start_with? Dir.pwd } .map { _1.sub("#{Dir.pwd}/", '') } .then { Filter.call _1 } end |
#stop ⇒ Object
23 |
# File 'lib/test_map/file_recorder.rb', line 23 def stop = @trace&.disable |
#trace(&block) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/test_map/file_recorder.rb', line 8 def trace(&block) raise TraceInUseError.default if @trace&.enabled? @trace = TracePoint.new(:call) do |tp| TestMap.logger.debug "#{tp.path}:#{tp.lineno}" @files << tp.path end if block_given? @trace.enable { block.call } else @trace.enable end end |