Sha256: 364a6eb57822678f28805600d214a200b430d8394b8f36a172ea2fbddcebb536

Contents?: true

Size: 1018 Bytes

Versions: 24

Compression:

Stored size: 1018 Bytes

Contents

module DeepTest
  class SimpleTestBlackboard
    attr_accessor :debug, :simulate_result_overdue_error

    def initialize
      @work_units = []
      @test_results = []
      @semaphore = Mutex.new
    end

    def take_result
      raise DeepTest::Server::ResultOverdueError if @simulate_result_overdue_error
      @semaphore.synchronize do
        log_and_return "take_result", @test_results.shift
      end
    end

    def take_work
      @semaphore.synchronize do
        log_and_return "take_work", @work_units.shift
      end
    end

    def write_result(result)
      @semaphore.synchronize do
        log_and_return "write_result", result
        @test_results.push result
      end
    end

    def write_work(work_unit)
      @semaphore.synchronize do
        log_and_return "write_work", work_unit
        @work_units.push work_unit
      end
    end

    def log_and_return(message, object)
      if debug && object
        puts "* #{message} #{object.inspect}"
      end
      object
    end
  end
end

Version data entries

24 entries across 24 versions & 4 rubygems

Version Path
jason-o-matic-deep_test-1.2.2.1 test/simple_test_blackboard.rb
jason-o-matic-deep_test-1.2.2.10 test/simple_test_blackboard.rb
jason-o-matic-deep_test-1.2.2.11 test/simple_test_blackboard.rb
jason-o-matic-deep_test-1.2.2.12 test/simple_test_blackboard.rb
jason-o-matic-deep_test-1.2.2.13 test/simple_test_blackboard.rb
jason-o-matic-deep_test-1.2.2.14 test/simple_test_blackboard.rb
jason-o-matic-deep_test-1.2.2.2 test/simple_test_blackboard.rb
jason-o-matic-deep_test-1.2.2.3 test/simple_test_blackboard.rb
jason-o-matic-deep_test-1.2.2.4 test/simple_test_blackboard.rb
jason-o-matic-deep_test-1.2.2.5 test/simple_test_blackboard.rb
jason-o-matic-deep_test-1.2.2.6 test/simple_test_blackboard.rb
jason-o-matic-deep_test-1.2.2.7 test/simple_test_blackboard.rb
jason-o-matic-deep_test-1.2.2.8 test/simple_test_blackboard.rb
jason-o-matic-deep_test-1.2.2.9 test/simple_test_blackboard.rb
jperkins-deep_test-1.2.2 test/simple_test_blackboard.rb
jason-o-matic-deep_test-1.2.2.15 test/simple_test_blackboard.rb
jstorimer-deep-test-1.4.0 test/simple_test_blackboard.rb
jstorimer-deep-test-1.3.0 test/simple_test_blackboard.rb
jstorimer-deep-test-1.2.0 test/simple_test_blackboard.rb
jstorimer-deep-test-1.1.0 test/simple_test_blackboard.rb