test/functional/ct_2_cancel.rb in ruote-2.1.9 vs test/functional/ct_2_cancel.rb in ruote-2.1.10
- old
+ new
@@ -25,45 +25,52 @@
#noisy
wfid = @engine0.launch(pdef)
- @engine0.step 6
+ @engine0.step 7
- @engine1.cancel_expression(
- { 'engine_id' => 'engine', 'wfid' => wfid, 'expid' => '0_0' })
+ dispatched_seen = false
+ reply_msg = nil
- msgs = nil
loop do
- msgs = @storage.get_msgs
- break if msgs.size == 2
- #p msgs.collect { |m| m['fei']['expid'] }.uniq
- #break if
- # msgs.size == 2 &&
- # msgs.collect { |m| m['fei']['expid'] }.uniq == %w[ 0_0 ]
+ m = @engine0.next_msg
+ ma = m['action']
+ if ma == 'dispatched'
+ dispatched_seen = true
+ @engine0.do_process(m)
+ break if reply_msg
+ elsif ma == 'reply'
+ reply_msg = m
+ break
+ else
+ @engine0.do_process(m)
+ end
end
- #msgs.each { |m| p m }
- #puts
+ #p dispatched_seen
- t1 = Thread.new { @engine1.do_step(msgs[1]) }
- t0 = Thread.new { @engine0.do_step(msgs[0]) }
- t1.join
- t0.join
+ @engine0.cancel_expression(
+ { 'engine_id' => 'engine', 'wfid' => wfid, 'expid' => '0_0' })
- #puts
+ msgs = @engine0.gather_msgs
- @engine0.step 4
+ msgs = msgs - [ reply_msg ]
- sleep 0.010
+ assert_equal 1, msgs.size
+ assert_equal 'cancel', msgs.first['action']
- assert_equal 0, @storage.get_msgs.size
+ t1 = Thread.new { @engine1.do_process(msgs.first) }
+ t0 = Thread.new { @engine0.do_process(reply_msg) }
+ t1.join
+ t0.join
- exps = @storage.get_many('expressions')
- exps.each { |exp|
- p [ exp['fei']['expid'], exp['original_tree'] ]
- } if exps.size > 0
+ loop do
+ m = @engine0.next_msg
+ @engine0.do_process(m)
+ break if m['action'] == 'terminated'
+ end
- assert_equal 0, exps.size
+ assert_nil @engine0.process(wfid)
end
end