Sha256: f8e9289f13bf242e879b12bebeb8cdba8f9028c126a8fe5fb4ff000b1bff67f1

Contents?: true

Size: 1.68 KB

Versions: 2

Compression:

Stored size: 1.68 KB

Contents

#
# testing ruote
#
# Thu Jan  6 21:49:01 JST 2011
#

require File.join(File.dirname(__FILE__), 'base')

#require 'ruote/participant'


class FtEngineOnTerminateTest < Test::Unit::TestCase
  include FunctionalBase

  def test_no_on_terminate

    assert_nil @engine.on_terminate
  end

  def test_on_terminate

    @engine.on_terminate = 'supervisor'

    assert_equal(
      [ 'define', {}, [ [ 'supervisor', {}, [] ] ] ],
      @engine.on_terminate)
  end

  def test_on_terminate_tree

    @engine.on_terminate = Ruote.define do
      echo '${__terminate__.wfid} terminated'
    end

    #@engine.noisy = true

    wfid = @engine.launch(Ruote.define do
      echo 'main'
    end)

    @engine.wait_for(wfid)
    sleep 1

    assert_equal [ 'main', "#{wfid} terminated" ], @tracer.to_a
  end

  # on_terminate processes are not triggered for on_error processes.
  #
  def test_no_on_terminate_when_on_error

    @engine.on_error = Ruote.define do
      echo 'on_error'
    end
    @engine.on_terminate = Ruote.define do
      echo 'on_terminate'
    end

    #noisy

    wfid = @engine.launch(Ruote.define do
      echo 'main'
      error 'in main'
    end)

    @engine.wait_for(wfid)
    sleep 1

    assert_equal [ 'main', 'on_error' ], @tracer.to_a
  end

  # on_error processes are triggered for on_terminate processes as well.
  #
  def test_on_error_when_on_terminate

    @engine.on_error = Ruote.define do
      echo 'on_error'
    end
    @engine.on_terminate = Ruote.define do
      error 'in on_terminate'
    end

    #noisy

    wfid = @engine.launch(Ruote.define do
      echo 'main'
    end)

    @engine.wait_for(wfid)
    sleep 1

    assert_equal [ 'main', 'on_error' ], @tracer.to_a
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
ruote-maestrodev-2.2.1 test/functional/ft_53_engine_on_terminate.rb
ruote-2.2.0 test/functional/ft_53_engine_on_terminate.rb