test/functional/eft_8_undo.rb in ruote-2.2.0 vs test/functional/eft_8_undo.rb in ruote-2.3.0

- old
+ new

@@ -3,39 +3,48 @@ # testing ruote # # Sun Jun 14 14:48:03 JST 2009 # -require File.join(File.dirname(__FILE__), 'base') +require File.expand_path('../base', __FILE__) require 'ruote/participant' class EftUndoTest < Test::Unit::TestCase include FunctionalBase def test_undo_ref - pdef = Ruote.process_definition do + pdef = Ruote.define do concurrence do alpha :tag => 'kilroy' undo :ref => 'kilroy' end - echo 'over' + echo 'over.' end - alpha = @engine.register_participant :alpha, Ruote::StorageParticipant + alpha = @dashboard.register(:alpha, Ruote::StorageParticipant) - #noisy + wfid = @dashboard.launch(pdef) + r = @engine.wait_for(wfid) - assert_trace %w[ over ], pdef + assert_equal 'terminated', r['action'] + assert_equal 'over.', @tracer.to_s assert_equal 0, alpha.size assert_equal 1, logger.log.select { |e| e['action'] == 'entered_tag' }.size assert_equal 1, logger.log.select { |e| e['action'] == 'cancel' }.size assert_equal 1, logger.log.select { |e| e['action'] == 'left_tag' }.size + + assert_equal 1, r['variables']['__past_tags__'].size + + kilroy = r['variables']['__past_tags__'].first + + assert_equal 'kilroy', kilroy[0] + assert_equal 'cancelled', kilroy[2] end def test_undo pdef = Ruote.process_definition do @@ -45,14 +54,12 @@ cancel :kilroy end echo 'over' end - alpha = @engine.register_participant :alpha, Ruote::StorageParticipant + alpha = @dashboard.register_participant :alpha, Ruote::StorageParticipant - #noisy - assert_trace %w[ over ], pdef assert_equal 0, alpha.size assert_equal 1, logger.log.select { |e| e['action'] == 'entered_tag' }.size @@ -68,12 +75,10 @@ echo 'out' end echo '.' end - #noisy - assert_trace '.', pdef end def test_undo_missing_tag @@ -91,12 +96,10 @@ set 'v:nada' => [] cancel :nada echo '.' end - #@engine.noisy = true - assert_trace '.', pdef end def test_undo_tag_pointing_to_missing_fei @@ -104,11 +107,45 @@ set 'v:nada' => { 'wfid' => '${wfid}', 'expid' => '${expid}', 'engine_id' => '${engine_id}' } cancel :nada echo '.' end - #@engine.noisy = true - assert_trace '.', pdef + end + + def test_undo_no_tag + + pdef = Ruote.process_definition do + cancel + echo 'x' + end + + wfid = @dashboard.launch(pdef) + r = @dashboard.wait_for(wfid) + + assert_equal 'terminated', r['action'] + assert_equal 'x', @tracer.to_s + end + + def test_kill + + @dashboard.register :alpha, Ruote::StorageParticipant + + pdef = Ruote.define do + concurrence do + alpha :tag => :kilroy, :on_cancel => :report + kill :kilroy + end + echo 'over.' + define 'report' do + echo 'xxx' + end + end + + wfid = @dashboard.launch(pdef) + r = @dashboard.wait_for(wfid) + + assert_equal 'terminated', r['action'] + assert_equal 'over.', @tracer.to_s end end