affected_tests 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/lib/affected_tests/rspec.rb +5 -4
- data/lib/affected_tests/version.rb +1 -1
- data/lib/affected_tests.rb +29 -25
- metadata +3 -3
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 96f592851e15e03100476ea65886d785a8baf5c8fa954beb0c628c3b4db99fa5
         | 
| 4 | 
            +
              data.tar.gz: a25451d7b286eeed185ea9dee6783512364252607efbc5b26055f687811bdc6d
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 27bd7c5b5b591a7f082a849830350621b24a178db62b338862ed609332e79618a26c6a3c8e8409c3c5573840bb7f6c84475f47ec5a3bfeb61a2cc397601ca0c7
         | 
| 7 | 
            +
              data.tar.gz: 98dc67e1439bb8a7cc6bc10700028dd99e6e6ea7ddf0c0c59a510b73cee33f1fe0ee50404d1de6cd729003a55f30dbef4a9834c9d5bfc5b81914f7a049e885fc
         | 
    
        data/Gemfile.lock
    CHANGED
    
    
    
        data/lib/affected_tests/rspec.rb
    CHANGED
    
    | @@ -1,13 +1,14 @@ | |
| 1 1 | 
             
            # frozen_string_literal: true
         | 
| 2 2 |  | 
| 3 3 | 
             
            RSpec.configure do |config|
         | 
| 4 | 
            -
              config. | 
| 5 | 
            -
                AffectedTests. | 
| 4 | 
            +
              config.prepend_before(:each) do
         | 
| 5 | 
            +
                AffectedTests.start_trace
         | 
| 6 6 | 
             
              end
         | 
| 7 7 |  | 
| 8 | 
            -
              config. | 
| 8 | 
            +
              config.append_after(:each) do
         | 
| 9 | 
            +
                AffectedTests.stop_trace
         | 
| 9 10 | 
             
                target_spec = self.class.declaration_locations.last[0]
         | 
| 10 | 
            -
                AffectedTests. | 
| 11 | 
            +
                AffectedTests.checkpoint(target_spec)
         | 
| 11 12 | 
             
              end
         | 
| 12 13 |  | 
| 13 14 | 
             
              config.after(:suite) do
         | 
    
        data/lib/affected_tests.rb
    CHANGED
    
    | @@ -3,7 +3,7 @@ | |
| 3 3 | 
             
            require "set"
         | 
| 4 4 | 
             
            require "json"
         | 
| 5 5 |  | 
| 6 | 
            -
            require " | 
| 6 | 
            +
            require "rotoscope"
         | 
| 7 7 |  | 
| 8 8 | 
             
            require_relative "affected_tests/version"
         | 
| 9 9 |  | 
| @@ -14,50 +14,50 @@ module AffectedTests | |
| 14 14 | 
             
                @project_path = project_path
         | 
| 15 15 | 
             
                @test_dir_path = test_dir_path
         | 
| 16 16 | 
             
                @output_path = output_path
         | 
| 17 | 
            +
                @rotoscope = Rotoscope.new do |call|
         | 
| 18 | 
            +
                  next if self == call.receiver
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                  if call.caller_path && target_path?(call.caller_path)
         | 
| 21 | 
            +
                    buffer << call.caller_path
         | 
| 22 | 
            +
                  end
         | 
| 23 | 
            +
                end
         | 
| 17 24 | 
             
              end
         | 
| 18 25 |  | 
| 19 | 
            -
              def  | 
| 20 | 
            -
                 | 
| 26 | 
            +
              def start_trace
         | 
| 27 | 
            +
                @rotoscope.start_trace
         | 
| 21 28 | 
             
              end
         | 
| 22 29 |  | 
| 23 | 
            -
              def  | 
| 24 | 
            -
                 | 
| 25 | 
            -
             | 
| 26 | 
            -
                  target_path?(caller_path)
         | 
| 27 | 
            -
                end.map do |(caller_info, _callee_info, _count)|
         | 
| 28 | 
            -
                  format_path(caller_info.first)
         | 
| 29 | 
            -
                end
         | 
| 30 | 
            +
              def stop_trace
         | 
| 31 | 
            +
                @rotoscope.stop_trace
         | 
| 32 | 
            +
              end
         | 
| 30 33 |  | 
| 31 | 
            -
             | 
| 32 | 
            -
             | 
| 33 | 
            -
                   | 
| 34 | 
            -
                end.map do |(_caller_info, callee_info, _count)|
         | 
| 35 | 
            -
                  format_path(callee_info.first)
         | 
| 34 | 
            +
              def import_from_rotoscope(target_test_path, result)
         | 
| 35 | 
            +
                all_related_paths = result.uniq.map do |caller_path|
         | 
| 36 | 
            +
                  format_path(caller_path)
         | 
| 36 37 | 
             
                end
         | 
| 37 38 |  | 
| 38 | 
            -
                 | 
| 39 | 
            -
             | 
| 40 | 
            -
                target_test_file_path = format_path(target_test_path)
         | 
| 39 | 
            +
                formatted_target_test_path = format_path(target_test_path)
         | 
| 41 40 |  | 
| 42 41 | 
             
                all_related_paths.each do |path|
         | 
| 43 42 | 
             
                  next if path.start_with?(@test_dir_path)
         | 
| 44 43 |  | 
| 45 | 
            -
                  if path !=  | 
| 46 | 
            -
                    add( | 
| 44 | 
            +
                  if path != formatted_target_test_path
         | 
| 45 | 
            +
                    add(formatted_target_test_path, path)
         | 
| 47 46 | 
             
                  end
         | 
| 48 47 | 
             
                end
         | 
| 49 48 | 
             
              end
         | 
| 50 49 |  | 
| 51 | 
            -
              def  | 
| 52 | 
            -
                 | 
| 53 | 
            -
                 | 
| 50 | 
            +
              def checkpoint(target_test_path)
         | 
| 51 | 
            +
                diff = buffer
         | 
| 52 | 
            +
                import_from_rotoscope(target_test_path, diff)
         | 
| 53 | 
            +
                buffer.clear
         | 
| 54 54 | 
             
              end
         | 
| 55 55 |  | 
| 56 56 | 
             
              def dump
         | 
| 57 57 | 
             
                data = { revision: revision, map: cache.transform_values(&:to_a) }
         | 
| 58 58 | 
             
                File.write(@output_path, JSON.dump(data))
         | 
| 59 59 | 
             
              ensure
         | 
| 60 | 
            -
                 | 
| 60 | 
            +
                @rotoscope.stop_trace if @rotoscope.tracing?
         | 
| 61 61 | 
             
              end
         | 
| 62 62 |  | 
| 63 63 | 
             
              def format_path(path)
         | 
| @@ -82,8 +82,12 @@ module AffectedTests | |
| 82 82 | 
             
                end
         | 
| 83 83 | 
             
              end
         | 
| 84 84 |  | 
| 85 | 
            +
              def buffer
         | 
| 86 | 
            +
                Thread.current[:buffer] ||= []
         | 
| 87 | 
            +
              end
         | 
| 88 | 
            +
             | 
| 85 89 | 
             
              def cache
         | 
| 86 | 
            -
                 | 
| 90 | 
            +
                Thread.current[:cache] ||= {}
         | 
| 87 91 | 
             
              end
         | 
| 88 92 |  | 
| 89 93 | 
             
              def bundler_path
         | 
    
        metadata
    CHANGED
    
    | @@ -1,17 +1,17 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: affected_tests
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0. | 
| 4 | 
            +
              version: 0.2.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Shia
         | 
| 8 8 | 
             
            autorequire:
         | 
| 9 9 | 
             
            bindir: exe
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2022-07- | 
| 11 | 
            +
            date: 2022-07-20 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 | 
            -
              name:  | 
| 14 | 
            +
              name: rotoscope
         | 
| 15 15 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 16 16 | 
             
                requirements:
         | 
| 17 17 | 
             
                - - ">="
         |