Sha256: deaa8801b99dcf576307f4d41d28c9ce721257fca5ff14dcb9b70e8f1dc9ea2c

Contents?: true

Size: 1.05 KB

Versions: 6

Compression:

Stored size: 1.05 KB

Contents

module Retest
  module Runners
    class TestRunner < Runner
      def cached_test_file
        @cached_test_file
      end

      def cached_test_file=(value)
        @cached_test_file = value || @cached_test_file
      end

      def run(changed_file, repository:)
        self.cached_test_file = repository.find_test(changed_file)

        if cached_test_file
          log("Test File Selected: #{cached_test_file}")
          system_run command.gsub('<test>', cached_test_file)
        else
          log(<<~ERROR)
            404 - Test File Not Found
            Retest could not find a matching test file to run.
          ERROR
        end
      end

      def sync(added:, removed:)
        remove(removed)
      end

      private

      def remove(purged)
        return if purged.empty?

        if purged.is_a? Array
          purge_cache if purged.include? cached_test_file
        elsif purged.is_a? String
          purge_cache if purged == cached_test_file
        end
      end

      def purge_cache
        @cached_test_file = nil
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
retest-1.10.0 lib/retest/runners/test_runner.rb
retest-1.9.0 lib/retest/runners/test_runner.rb
retest-1.8.0 lib/retest/runners/test_runner.rb
retest-1.7.0 lib/retest/runners/test_runner.rb
retest-1.6.2 lib/retest/runners/test_runner.rb
retest-1.6.1 lib/retest/runners/test_runner.rb