Sha256: cb62fbecfaed3537e34398abb2d5747d33990701f4a0be1793f9b830ee48f8df

Contents?: true

Size: 1.82 KB

Versions: 2

Compression:

Stored size: 1.82 KB

Contents

# Copyright (c) 2007-2008 Li Xiao <iam@li-xiao.com>
# 
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# 
#     http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

module DTR
  module Agent
    class Runner < ProcessRoot
      include DRbUndumped
      include Service::Runner

      attr_reader :name

      def initialize(name)
        super
        @name = name
      end
      
      def start
        #start service first, so that all logs can be sync with master process
        start_service

        ENV['DTR_RUNNER_NAME'] = name
        DTR.info "Start #{self} at #{DTR.root}, pid: #{Process.pid}"
        DTR.configuration.working_env.load_environment do
          provide
          DTR.info {"=> Runner provided"}
          while DTR.configuration.runners_should_be_working?
            sleep(1)
          end
        end
      rescue
        DTR.error($!.message)
        DTR.error($!.backtrace.join("\n"))
      ensure
        #make sure exit process for drb may cause this process hang on
        exit!(0)
      end

      def run(test, result, &progress_block)
        DTR.debug {"running #{test}..."}
        Agent::TestCase.new(test, result, &progress_block).run
        DTR.debug {"done #{test}"}
      ensure
        provide
        DTR.debug {"=> Runner provided"}
      end

      def provide
        provide_runner(self)
      end

      def to_s
        "Runner #{@name}"
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
xli-dtr-1.1.0 lib/dtr/agent/runner.rb
dtr-1.1.0 lib/dtr/agent/runner.rb