Class: AppMap::Depends::TestFileInspector
- Inherits:
-
Object
- Object
- AppMap::Depends::TestFileInspector
- Defined in:
- lib/appmap/depends/test_file_inspector.rb
Defined Under Namespace
Classes: TestReport
Instance Attribute Summary collapse
-
#test_dir ⇒ Object
readonly
Returns the value of attribute test_dir.
-
#test_file_patterns ⇒ Object
readonly
Returns the value of attribute test_file_patterns.
Instance Method Summary collapse
-
#initialize(test_dir, test_file_patterns) ⇒ TestFileInspector
constructor
A new instance of TestFileInspector.
- #report ⇒ Object
Constructor Details
#initialize(test_dir, test_file_patterns) ⇒ TestFileInspector
Returns a new instance of TestFileInspector.
53 54 55 56 |
# File 'lib/appmap/depends/test_file_inspector.rb', line 53 def initialize(test_dir, test_file_patterns) @test_dir = test_dir @test_file_patterns = test_file_patterns end |
Instance Attribute Details
#test_dir ⇒ Object (readonly)
Returns the value of attribute test_dir.
50 51 52 |
# File 'lib/appmap/depends/test_file_inspector.rb', line 50 def test_dir @test_dir end |
#test_file_patterns ⇒ Object (readonly)
Returns the value of attribute test_file_patterns.
51 52 53 |
# File 'lib/appmap/depends/test_file_inspector.rb', line 51 def test_file_patterns @test_file_patterns end |
Instance Method Details
#report ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/appmap/depends/test_file_inspector.rb', line 58 def report = Dir.glob(File.join(test_dir, '**', 'metadata.json')) source_locations = Set.new changed_test_files = Set.new failed_test_files = Set.new .each do || = JSON.parse(File.read()) appmap_path = File.join(.split('/')[0...-1]) appmap_mtime = File.read(File.join(appmap_path, 'mtime')).to_i source_location = Util.normalize_path(['source_location']) test_status = ['test_status'] source_location_mtime = (File.stat(source_location).mtime.to_f * 1000).to_i rescue nil raise "Metadata #{} does not contain source_location" unless source_location raise "Metadata #{} does not contain test_status" unless test_status source_locations << source_location if source_location_mtime changed_test_files << source_location if source_location_mtime > appmap_mtime failed_test_files << source_location unless test_status == 'succeeded' end end test_files = Set.new(test_file_patterns.map(&Dir.method(:glob)).flatten) added_test_files = test_files - source_locations changed_test_files -= added_test_files removed_test_files = source_locations - test_files TestReport.new(, added_test_files, removed_test_files, changed_test_files, failed_test_files) end |