Sha256: 22cd9e558c744b9ae8e6056d3b3388e481b2b0974ea44cf1765750d12fdc7584

Contents?: true

Size: 1.5 KB

Versions: 15

Compression:

Stored size: 1.5 KB

Contents

module DeepTest
  module Test
    class SupervisedTestSuite
      def initialize(suite, blackboard)
        @suite = suite
        @blackboard = blackboard
      end

      def run(result, &progress_block)
        yield ::Test::Unit::TestSuite::STARTED, @suite.name
        tests_by_name = {}
        add_tests @suite, tests_by_name
        read_results result, tests_by_name, &progress_block
        yield ::Test::Unit::TestSuite::FINISHED, @suite.name
      end

      def size
        @suite.size
      end

      def add_tests(test_suite, tests_by_name)
        if test_suite.respond_to? :tests
          test_suite.tests.each do |test| 
            add_tests(test, tests_by_name)
          end
        else
          tests_by_name[test_suite.name] = test_suite
          @blackboard.write_work Test::WorkUnit.new(test_suite)
        end
      end

      def read_results(result, tests_by_name)
        DeepTest.logger.debug("SupervisedTestSuite: going to read #{tests_by_name.size} results")

        missing_tests = 
          ResultReader.new(@blackboard).read(tests_by_name) do |test, remote_result|
            remote_result.add_to result
            yield ::Test::Unit::TestCase::FINISHED, test.name if block_given?
          end

        missing_tests.each do |name, test_case|
          result.add_error ::Test::Unit::Error.new(name, WorkUnitNeverReceivedError.new)
        end
      ensure
        DeepTest.logger.debug("SupervisedTestSuite: exiting with #{missing_tests.size} results left")
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 4 rubygems

Version Path
jason-o-matic-deep_test-1.2.2.1 lib/deep_test/test/supervised_test_suite.rb
jason-o-matic-deep_test-1.2.2.2 lib/deep_test/test/supervised_test_suite.rb
jason-o-matic-deep_test-1.2.2.3 lib/deep_test/test/supervised_test_suite.rb
jason-o-matic-deep_test-1.2.2.4 lib/deep_test/test/supervised_test_suite.rb
jason-o-matic-deep_test-1.2.2.5 lib/deep_test/test/supervised_test_suite.rb
jason-o-matic-deep_test-1.2.2.6 lib/deep_test/test/supervised_test_suite.rb
jperkins-deep_test-1.2.2 lib/deep_test/test/supervised_test_suite.rb
jstorimer-deep-test-1.4.0 lib/deep_test/test/supervised_test_suite.rb
jstorimer-deep-test-1.3.0 lib/deep_test/test/supervised_test_suite.rb
jstorimer-deep-test-1.2.0 lib/deep_test/test/supervised_test_suite.rb
jstorimer-deep-test-1.1.0 lib/deep_test/test/supervised_test_suite.rb
jstorimer-deep-test-1.0.0 lib/deep_test/test/supervised_test_suite.rb
deep_test-1.2.2 lib/deep_test/test/supervised_test_suite.rb
deep_test-1.2.1 lib/deep_test/test/supervised_test_suite.rb
deep_test-1.2.0 lib/deep_test/test/supervised_test_suite.rb