ruote 2.1.11 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.txt +60 -0
- data/CREDITS.txt +22 -4
- data/LICENSE.txt +1 -1
- data/README.rdoc +6 -7
- data/Rakefile +58 -59
- data/TODO.txt +137 -65
- data/couch_url.txt +1 -0
- data/jruby_issue.txt +32 -0
- data/lib/ruote.rb +1 -1
- data/lib/ruote/context.rb +12 -10
- data/lib/ruote/engine.rb +280 -145
- data/lib/ruote/engine/process_error.rb +5 -5
- data/lib/ruote/engine/process_status.rb +47 -28
- data/lib/ruote/exp/command.rb +7 -10
- data/lib/ruote/exp/commanded.rb +2 -2
- data/lib/ruote/exp/condition.rb +130 -43
- data/lib/ruote/exp/fe_add_branches.rb +2 -2
- data/lib/ruote/exp/fe_apply.rb +1 -1
- data/lib/ruote/exp/fe_cancel_process.rb +3 -3
- data/lib/ruote/exp/fe_command.rb +3 -3
- data/lib/ruote/exp/fe_concurrence.rb +4 -4
- data/lib/ruote/exp/fe_concurrent_iterator.rb +17 -5
- data/lib/ruote/exp/fe_cron.rb +3 -3
- data/lib/ruote/exp/fe_cursor.rb +5 -5
- data/lib/ruote/exp/fe_define.rb +3 -3
- data/lib/ruote/exp/fe_echo.rb +3 -3
- data/lib/ruote/exp/fe_equals.rb +2 -2
- data/lib/ruote/exp/fe_error.rb +2 -2
- data/lib/ruote/exp/fe_filter.rb +519 -0
- data/lib/ruote/exp/fe_forget.rb +9 -2
- data/lib/ruote/exp/fe_given.rb +154 -0
- data/lib/ruote/exp/fe_if.rb +16 -13
- data/lib/ruote/exp/fe_inc.rb +3 -3
- data/lib/ruote/exp/fe_iterator.rb +4 -4
- data/lib/ruote/exp/fe_let.rb +75 -0
- data/lib/ruote/exp/fe_listen.rb +68 -12
- data/lib/ruote/exp/fe_lose.rb +110 -0
- data/lib/ruote/exp/fe_noop.rb +1 -1
- data/lib/ruote/exp/{fe_when.rb → fe_once.rb} +25 -21
- data/lib/ruote/exp/fe_participant.rb +14 -17
- data/lib/ruote/exp/fe_redo.rb +10 -6
- data/lib/ruote/exp/fe_ref.rb +1 -1
- data/lib/ruote/exp/fe_registerp.rb +112 -0
- data/lib/ruote/exp/fe_reserve.rb +3 -3
- data/lib/ruote/exp/fe_restore.rb +2 -2
- data/lib/ruote/exp/fe_save.rb +2 -2
- data/lib/ruote/exp/fe_sequence.rb +3 -4
- data/lib/ruote/exp/fe_set.rb +16 -7
- data/lib/ruote/exp/fe_subprocess.rb +23 -1
- data/lib/ruote/exp/fe_that.rb +92 -0
- data/lib/ruote/exp/fe_undo.rb +3 -3
- data/lib/ruote/exp/fe_unregisterp.rb +71 -0
- data/lib/ruote/exp/fe_wait.rb +2 -2
- data/lib/ruote/exp/flowexpression.rb +153 -78
- data/lib/ruote/exp/iterator.rb +2 -2
- data/lib/ruote/exp/merge.rb +2 -2
- data/lib/ruote/exp/ro_attributes.rb +14 -12
- data/lib/ruote/exp/ro_filters.rb +136 -0
- data/lib/ruote/exp/ro_persist.rb +51 -35
- data/lib/ruote/exp/ro_variables.rb +18 -27
- data/lib/ruote/fei.rb +73 -33
- data/lib/ruote/id/mnemo_wfid_generator.rb +1 -1
- data/lib/ruote/id/wfid_generator.rb +11 -4
- data/lib/ruote/log/default_history.rb +122 -0
- data/lib/ruote/log/pretty.rb +36 -8
- data/lib/ruote/log/storage_history.rb +37 -5
- data/lib/ruote/log/test_logger.rb +26 -24
- data/lib/ruote/log/wait_logger.rb +5 -3
- data/lib/ruote/part/block_participant.rb +22 -11
- data/lib/ruote/part/engine_participant.rb +6 -7
- data/lib/ruote/part/local_participant.rb +6 -12
- data/lib/ruote/part/no_op_participant.rb +4 -4
- data/lib/ruote/part/null_participant.rb +4 -4
- data/lib/ruote/part/smtp_participant.rb +4 -4
- data/lib/ruote/part/storage_participant.rb +40 -20
- data/lib/ruote/part/template.rb +4 -4
- data/lib/ruote/participant.rb +0 -1
- data/lib/ruote/{parser.rb → reader.rb} +30 -25
- data/lib/ruote/{parser → reader}/ruby_dsl.rb +28 -11
- data/lib/ruote/{parser → reader}/xml.rb +6 -5
- data/lib/ruote/receiver/base.rb +35 -13
- data/lib/ruote/storage/base.rb +20 -18
- data/lib/ruote/storage/composite_storage.rb +10 -10
- data/lib/ruote/storage/fs_storage.rb +17 -10
- data/lib/ruote/storage/hash_storage.rb +29 -18
- data/lib/ruote/svc/dispatch_pool.rb +41 -14
- data/lib/ruote/svc/dollar_sub.rb +50 -17
- data/lib/ruote/svc/error_handler.rb +19 -11
- data/lib/ruote/svc/expression_map.rb +4 -4
- data/lib/ruote/svc/participant_list.rb +105 -100
- data/lib/ruote/svc/tracker.rb +58 -18
- data/lib/ruote/svc/treechecker.rb +51 -24
- data/lib/ruote/tree_dot.rb +4 -4
- data/lib/ruote/util/filter.rb +440 -0
- data/lib/ruote/util/hashdot.rb +4 -4
- data/lib/ruote/util/look.rb +2 -6
- data/lib/ruote/util/lookup.rb +9 -7
- data/lib/ruote/util/misc.rb +40 -8
- data/lib/ruote/util/ometa.rb +1 -1
- data/lib/ruote/util/serializer.rb +4 -4
- data/lib/ruote/util/subprocess.rb +29 -9
- data/lib/ruote/util/time.rb +4 -4
- data/lib/ruote/util/tree.rb +3 -3
- data/lib/ruote/version.rb +2 -2
- data/lib/ruote/worker.rb +55 -32
- data/lib/ruote/workitem.rb +64 -11
- data/ruote.gemspec +31 -302
- data/test/bm/launch_bench.rb +37 -0
- data/test/functional/base.rb +60 -18
- data/test/functional/concurrent_base.rb +2 -2
- data/test/functional/ct_0_concurrence.rb +1 -1
- data/test/functional/ct_1_iterator.rb +1 -1
- data/test/functional/ct_2_cancel.rb +1 -1
- data/test/functional/eft_0_process_definition.rb +2 -2
- data/test/functional/eft_10_cancel_process.rb +1 -1
- data/test/functional/eft_11_wait.rb +19 -11
- data/test/functional/eft_12_listen.rb +79 -13
- data/test/functional/eft_13_iterator.rb +13 -10
- data/test/functional/eft_14_cursor.rb +98 -9
- data/test/functional/eft_15_loop.rb +6 -4
- data/test/functional/eft_16_if.rb +12 -0
- data/test/functional/eft_18_concurrent_iterator.rb +31 -32
- data/test/functional/eft_19_reserve.rb +4 -4
- data/test/functional/eft_1_echo.rb +9 -0
- data/test/functional/eft_20_save.rb +4 -4
- data/test/functional/{eft_28_when.rb → eft_28_once.rb} +33 -7
- data/test/functional/eft_30_ref.rb +17 -2
- data/test/functional/eft_31_registerp.rb +130 -0
- data/test/functional/eft_32_lose.rb +93 -0
- data/test/functional/eft_33_let.rb +31 -0
- data/test/functional/eft_34_given.rb +123 -0
- data/test/functional/eft_35_filter.rb +269 -0
- data/test/functional/eft_3_participant.rb +4 -6
- data/test/functional/eft_4_set.rb +16 -2
- data/test/functional/eft_5_subprocess.rb +2 -4
- data/test/functional/eft_6_concurrence.rb +29 -29
- data/test/functional/eft_8_undo.rb +39 -3
- data/test/functional/eft_9_redo.rb +94 -2
- data/test/functional/ft_10_dollar.rb +81 -2
- data/test/functional/ft_11_recursion.rb +13 -17
- data/test/functional/ft_12_launchitem.rb +9 -5
- data/test/functional/ft_13_variables.rb +7 -9
- data/test/functional/ft_14_re_apply.rb +6 -9
- data/test/functional/ft_15_timeout.rb +18 -18
- data/test/functional/ft_16_participant_params.rb +1 -3
- data/test/functional/ft_17_conditional.rb +25 -2
- data/test/functional/ft_18_kill.rb +65 -12
- data/test/functional/ft_1_process_status.rb +147 -71
- data/test/functional/ft_20_storage_participant.rb +0 -1
- data/test/functional/ft_21_forget.rb +82 -1
- data/test/functional/{ft_24_block_participants.rb → ft_24_block_participant.rb} +42 -11
- data/test/functional/ft_25_receiver.rb +47 -17
- data/test/functional/{ft_26_participant_timeout.rb → ft_26_participant_rtimeout.rb} +56 -19
- data/test/functional/ft_29_part_template.rb +6 -5
- data/test/functional/ft_2_errors.rb +21 -37
- data/test/functional/ft_30_smtp_participant.rb +1 -1
- data/test/functional/ft_31_part_blocking.rb +8 -6
- data/test/functional/ft_34_cursor_rewind.rb +13 -10
- data/test/functional/ft_35_add_service.rb +1 -1
- data/test/functional/ft_36_storage_history.rb +24 -1
- data/test/functional/ft_37_default_history.rb +109 -0
- data/test/functional/ft_38_participant_more.rb +10 -10
- data/test/functional/ft_39_wait_for.rb +12 -9
- data/test/functional/ft_3_participant_registration.rb +111 -32
- data/test/functional/ft_40_wait_logger.rb +2 -1
- data/test/functional/ft_41_participants.rb +30 -4
- data/test/functional/ft_43_participant_on_reply.rb +6 -23
- data/test/functional/ft_45_participant_accept.rb +4 -4
- data/test/functional/ft_46_launch_single.rb +36 -2
- data/test/functional/ft_47_wfid_generator.rb +54 -0
- data/test/functional/ft_48_lose.rb +112 -0
- data/test/functional/ft_49_engine_on_error.rb +201 -0
- data/test/functional/ft_4_cancel.rb +66 -6
- data/test/functional/ft_50_engine_config.rb +22 -0
- data/test/functional/ft_51_misc.rb +67 -0
- data/test/functional/ft_52_case.rb +134 -0
- data/test/functional/ft_53_engine_on_terminate.rb +95 -0
- data/test/functional/ft_54_patterns.rb +104 -0
- data/test/functional/{ft_37_engine_participant.rb → ft_55_engine_participant.rb} +4 -5
- data/test/functional/ft_56_filter_attribute.rb +259 -0
- data/test/functional/ft_5_on_error.rb +77 -30
- data/test/functional/ft_6_on_cancel.rb +66 -11
- data/test/functional/ft_7_tags.rb +94 -5
- data/test/functional/ft_8_participant_consumption.rb +36 -5
- data/test/functional/ft_9_subprocesses.rb +10 -10
- data/test/functional/rt_1_listen.rb +3 -3
- data/test/functional/{rt_3_when.rb → rt_3_once.rb} +4 -4
- data/test/functional/storage_helper.rb +15 -13
- data/test/functional/test.rb +1 -3
- data/test/test_helper.rb +0 -8
- data/test/unit/storage.rb +154 -10
- data/test/unit/{ut_0_ruby_parser.rb → ut_0_ruby_reader.rb} +61 -11
- data/test/unit/ut_11_lookup.rb +7 -0
- data/test/unit/ut_13_serializer.rb +1 -1
- data/test/unit/ut_15_util.rb +23 -0
- data/test/unit/{ut_16_parser.rb → ut_16_reader.rb} +11 -13
- data/test/unit/ut_1_fei.rb +57 -10
- data/test/unit/ut_20_composite_storage.rb +25 -11
- data/test/unit/ut_21_participant_list.rb +47 -0
- data/test/unit/ut_22_filter.rb +903 -0
- data/test/unit/ut_3_wait_logger.rb +2 -6
- data/test/unit/ut_6_condition.rb +164 -17
- data/test/unit/ut_7_workitem.rb +28 -0
- data/test/unit/ut_8_tree_to_dot.rb +1 -1
- data/test/unit/{ut_9_xml_parser.rb → ut_9_xml_reader.rb} +5 -5
- metadata +108 -84
- data/.gitignore +0 -4
- data/examples/barley.rb +0 -391
- data/examples/flickr_report.rb +0 -107
- data/examples/pong.rb +0 -37
- data/examples/ruote_quickstart.rb +0 -43
- data/examples/web_first_page.rb +0 -68
- data/lib/ruote/part/hash_participant.rb +0 -91
- data/test/README.rdoc +0 -15
- data/test/functional/crunner.sh +0 -19
- data/test/pdef.xml +0 -7
- data/test/unit/ut_2_wfidgen.rb +0 -21
@@ -0,0 +1,37 @@
|
|
1
|
+
|
2
|
+
# a ruote launch benchmark, as discussed with @hassox
|
3
|
+
# http://ruote.rubyforge.org/irclogs/ruote_2010-10-20.txt
|
4
|
+
|
5
|
+
puts
|
6
|
+
puts RUBY_VERSION
|
7
|
+
puts
|
8
|
+
|
9
|
+
require 'rubygems'
|
10
|
+
require 'benchmark'
|
11
|
+
require 'fileutils'
|
12
|
+
require 'ruote' # gem install ruote
|
13
|
+
require 'ruote/storage/fs_storage'
|
14
|
+
|
15
|
+
FileUtils.rm_rf('bench')
|
16
|
+
|
17
|
+
engine = Ruote::Engine.new(Ruote::FsStorage.new('bench'))
|
18
|
+
|
19
|
+
pdef = Ruote.process_definition do
|
20
|
+
alpha :task => 'walk the dog'
|
21
|
+
alpha :task => 'walk the dog'
|
22
|
+
alpha :task => 'walk the dog'
|
23
|
+
alpha :task => 'walk the dog'
|
24
|
+
alpha :task => 'walk the dog'
|
25
|
+
alpha :task => 'walk the dog'
|
26
|
+
alpha :task => 'walk the dog'
|
27
|
+
alpha :task => 'walk the dog'
|
28
|
+
alpha :task => 'walk the dog'
|
29
|
+
alpha :task => 'walk the dog'
|
30
|
+
end
|
31
|
+
|
32
|
+
Benchmark.benchmark(' ' * 31 + Benchmark::Tms::CAPTION, 31) do |b|
|
33
|
+
b.report('1000 launches') do
|
34
|
+
1000.times { engine.launch(pdef) }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
data/test/functional/base.rb
CHANGED
@@ -10,15 +10,30 @@ require 'fileutils'
|
|
10
10
|
require File.join(File.dirname(__FILE__), '..', 'test_helper.rb')
|
11
11
|
require File.join(File.dirname(__FILE__), 'storage_helper.rb')
|
12
12
|
|
13
|
-
require 'ruote
|
14
|
-
|
15
|
-
|
13
|
+
require 'ruote'
|
14
|
+
|
15
|
+
|
16
|
+
trap 'USR2' do
|
17
|
+
|
18
|
+
require 'irb'
|
19
|
+
require 'irb/completion'
|
20
|
+
|
21
|
+
IRB.setup(nil)
|
22
|
+
ws = IRB::WorkSpace.new(binding)
|
23
|
+
irb = IRB::Irb.new(ws)
|
24
|
+
IRB::conf[:MAIN_CONTEXT] = irb.context
|
25
|
+
irb.eval_input
|
26
|
+
end
|
27
|
+
|
28
|
+
puts "pid #{$$}"
|
16
29
|
|
17
30
|
|
18
31
|
module FunctionalBase
|
19
32
|
|
20
33
|
def setup
|
21
34
|
|
35
|
+
p self.class if ARGV.include?('-T') or ARGV.include?('-N')
|
36
|
+
|
22
37
|
#require 'ruote/util/look'
|
23
38
|
#Ruote::Look.dump_lsof
|
24
39
|
#Ruote::Look.dump_lsof_count
|
@@ -31,13 +46,21 @@ module FunctionalBase
|
|
31
46
|
determine_storage(
|
32
47
|
's_logger' => [ 'ruote/log/test_logger', 'Ruote::TestLogger' ])))
|
33
48
|
|
34
|
-
|
49
|
+
$_test = self
|
50
|
+
$_engine = @engine
|
51
|
+
#
|
52
|
+
# handy when hijacking (https://github.com/ileitch/hijack)
|
53
|
+
# or flinging USR2 at the test process
|
35
54
|
|
36
55
|
@tracer = Tracer.new
|
37
56
|
|
57
|
+
tracer = @tracer
|
58
|
+
@engine.context.instance_eval { @tracer = tracer }
|
59
|
+
|
38
60
|
@engine.add_service('tracer', @tracer)
|
61
|
+
@engine.add_service('stash', {})
|
39
62
|
|
40
|
-
noisy if ARGV.include?('-
|
63
|
+
noisy if ARGV.include?('-N')
|
41
64
|
|
42
65
|
#noisy # uncommented, it makes all the tests noisy
|
43
66
|
end
|
@@ -49,7 +72,12 @@ module FunctionalBase
|
|
49
72
|
@engine.context.storage.close if @engine.context.storage.respond_to?(:close)
|
50
73
|
end
|
51
74
|
|
52
|
-
def
|
75
|
+
def stash
|
76
|
+
|
77
|
+
@engine.context.stash
|
78
|
+
end
|
79
|
+
|
80
|
+
def assert_log_count(count, &block)
|
53
81
|
|
54
82
|
c = @engine.context.logger.log.select(&block).size
|
55
83
|
|
@@ -61,7 +89,12 @@ module FunctionalBase
|
|
61
89
|
# assert_trace(*expected_traces, pdef)
|
62
90
|
# assert_trace(*expected_traces, fields, pdef)
|
63
91
|
#
|
64
|
-
def assert_trace
|
92
|
+
def assert_trace(*args)
|
93
|
+
|
94
|
+
if args.last == :clear
|
95
|
+
args.pop
|
96
|
+
@tracer.clear
|
97
|
+
end
|
65
98
|
|
66
99
|
pdef = args.pop
|
67
100
|
fields = args.last.is_a?(Hash) ? args.pop : {}
|
@@ -69,15 +102,16 @@ module FunctionalBase
|
|
69
102
|
|
70
103
|
wfid = @engine.launch(pdef, fields)
|
71
104
|
|
72
|
-
wait_for(wfid)
|
73
|
-
|
74
|
-
#yield(@engine) if block_given?
|
105
|
+
r = wait_for(wfid)
|
75
106
|
|
76
107
|
assert_engine_clean(wfid)
|
77
108
|
|
109
|
+
trace = r['workitem']['fields']['_trace']
|
110
|
+
trace = trace ? trace.join('') : @tracer.to_s
|
111
|
+
|
78
112
|
if expected_traces.length > 0
|
79
|
-
ok, nok = expected_traces.partition { |et|
|
80
|
-
assert_equal(nok.first,
|
113
|
+
ok, nok = expected_traces.partition { |et| trace == et }
|
114
|
+
assert_equal(nok.first, trace) if ok.empty?
|
81
115
|
end
|
82
116
|
|
83
117
|
assert(true)
|
@@ -93,24 +127,24 @@ module FunctionalBase
|
|
93
127
|
|
94
128
|
protected
|
95
129
|
|
96
|
-
def noisy
|
130
|
+
def noisy(on=true)
|
97
131
|
|
98
132
|
puts "\nnoisy " + caller[0] if on
|
99
133
|
@engine.context.logger.noisy = true
|
100
134
|
end
|
101
135
|
|
102
|
-
def wait_for
|
136
|
+
def wait_for(*wfid_or_part)
|
103
137
|
|
104
138
|
@engine.wait_for(*wfid_or_part)
|
105
139
|
end
|
106
140
|
|
107
|
-
def assert_engine_clean
|
141
|
+
def assert_engine_clean(wfid)
|
108
142
|
|
109
143
|
assert_no_errors(wfid)
|
110
144
|
assert_no_remaining_expressions(wfid)
|
111
145
|
end
|
112
146
|
|
113
|
-
def assert_no_errors
|
147
|
+
def assert_no_errors(wfid)
|
114
148
|
|
115
149
|
errors = @engine.storage.get_many('errors', /#{wfid}$/)
|
116
150
|
|
@@ -131,7 +165,7 @@ module FunctionalBase
|
|
131
165
|
flunk 'remaining process error(s)'
|
132
166
|
end
|
133
167
|
|
134
|
-
def assert_no_remaining_expressions
|
168
|
+
def assert_no_remaining_expressions(wfid)
|
135
169
|
|
136
170
|
expcount = @engine.storage.get_many('expressions').size
|
137
171
|
return if expcount == 0
|
@@ -169,6 +203,14 @@ module FunctionalBase
|
|
169
203
|
end
|
170
204
|
end
|
171
205
|
|
206
|
+
# Re-opening workitem for a shortcut to a '_trace' field
|
207
|
+
#
|
208
|
+
class Ruote::Workitem
|
209
|
+
def trace
|
210
|
+
@h['fields']['_trace'] ||= []
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
172
214
|
class Tracer
|
173
215
|
attr_reader :s
|
174
216
|
def initialize
|
@@ -187,7 +229,7 @@ class Tracer
|
|
187
229
|
def clear
|
188
230
|
@s = ''
|
189
231
|
end
|
190
|
-
def puts
|
232
|
+
def puts(s)
|
191
233
|
@s << "#{s}\n"
|
192
234
|
end
|
193
235
|
end
|
@@ -7,7 +7,7 @@
|
|
7
7
|
|
8
8
|
require File.join(File.dirname(__FILE__), 'base')
|
9
9
|
|
10
|
-
require 'ruote/
|
10
|
+
require 'ruote/participant'
|
11
11
|
|
12
12
|
|
13
13
|
class EftProcessDefinitionTest < Test::Unit::TestCase
|
@@ -28,7 +28,7 @@ class EftProcessDefinitionTest < Test::Unit::TestCase
|
|
28
28
|
participant :ref => :alpha
|
29
29
|
end
|
30
30
|
|
31
|
-
alpha = @engine.register_participant :alpha, Ruote::
|
31
|
+
alpha = @engine.register_participant :alpha, Ruote::StorageParticipant
|
32
32
|
|
33
33
|
#noisy
|
34
34
|
|
@@ -24,17 +24,22 @@ class EftWaitTest < Test::Unit::TestCase
|
|
24
24
|
|
25
25
|
#noisy
|
26
26
|
|
27
|
-
ts = []
|
28
|
-
|
27
|
+
@engine.context.stash[:ts] = []
|
28
|
+
|
29
|
+
@engine.register_participant(:alpha) { stash[:ts] << Time.now }
|
29
30
|
|
30
31
|
assert_trace 'done.', pdef
|
31
32
|
|
32
|
-
|
33
|
-
|
33
|
+
d = (
|
34
|
+
@engine.context.stash[:ts][1].sec - @engine.context.stash[:ts][0].sec
|
35
|
+
) % 60
|
36
|
+
|
37
|
+
deltas = [ 2, 3 ]
|
38
|
+
deltas << 4 if @engine.storage.class.name.match(/^Ruote::Couch::/)
|
34
39
|
|
35
40
|
assert(
|
36
|
-
|
37
|
-
"delta is #{d}, which isn't
|
41
|
+
deltas.include?(d),
|
42
|
+
"delta is #{d}, which isn't in #{deltas.inspect}")
|
38
43
|
end
|
39
44
|
|
40
45
|
def test_cancel_wait
|
@@ -63,6 +68,10 @@ class EftWaitTest < Test::Unit::TestCase
|
|
63
68
|
|
64
69
|
def test_wait_until
|
65
70
|
|
71
|
+
@engine.context.stash[:ts] = []
|
72
|
+
|
73
|
+
@engine.register_participant(:alpha) { stash[:ts] << Time.now }
|
74
|
+
|
66
75
|
pdef = Ruote.process_definition do
|
67
76
|
sequence do
|
68
77
|
alpha
|
@@ -74,13 +83,12 @@ class EftWaitTest < Test::Unit::TestCase
|
|
74
83
|
|
75
84
|
#noisy
|
76
85
|
|
77
|
-
ts = []
|
78
|
-
@engine.register_participant(:alpha) { ts << Time.now }
|
79
|
-
|
80
86
|
assert_trace 'done.', pdef
|
81
87
|
|
82
|
-
|
83
|
-
|
88
|
+
ts0 = @engine.context.stash[:ts][0]
|
89
|
+
ts1 = @engine.context.stash[:ts][1]
|
90
|
+
|
91
|
+
assert(ts1 - ts0 > 1.0, "#{ts1 - ts0} should be > 1.0")
|
84
92
|
end
|
85
93
|
|
86
94
|
def test_wait_until_now
|
@@ -16,7 +16,7 @@ class EftListenTest < Test::Unit::TestCase
|
|
16
16
|
pdef = Ruote.process_definition do
|
17
17
|
concurrence do
|
18
18
|
sequence do
|
19
|
-
listen :to => '
|
19
|
+
listen :to => '/^al.*/'
|
20
20
|
echo '1'
|
21
21
|
end
|
22
22
|
sequence do
|
@@ -44,7 +44,7 @@ class EftListenTest < Test::Unit::TestCase
|
|
44
44
|
|
45
45
|
pdef = Ruote.process_definition do
|
46
46
|
concurrence do
|
47
|
-
listen :to =>
|
47
|
+
listen :to => /^al.*/ do
|
48
48
|
bravo
|
49
49
|
end
|
50
50
|
sequence do
|
@@ -58,7 +58,7 @@ class EftListenTest < Test::Unit::TestCase
|
|
58
58
|
@tracer << "a\n"
|
59
59
|
end
|
60
60
|
@engine.register_participant :bravo do |workitem|
|
61
|
-
@tracer << "#{workitem.fei.wfid}|#{workitem.fei.
|
61
|
+
@tracer << "#{workitem.fei.wfid}|#{workitem.fei.subid}"
|
62
62
|
@tracer << "\n"
|
63
63
|
end
|
64
64
|
|
@@ -68,10 +68,9 @@ class EftListenTest < Test::Unit::TestCase
|
|
68
68
|
|
69
69
|
wait_for(:bravo)
|
70
70
|
wait_for(:bravo)
|
71
|
-
wait_for(
|
72
|
-
|
73
|
-
sleep 0.001
|
71
|
+
wait_for(3)
|
74
72
|
|
73
|
+
#sleep 0.001
|
75
74
|
#p @tracer.to_s
|
76
75
|
|
77
76
|
a = @tracer.to_a
|
@@ -94,11 +93,11 @@ class EftListenTest < Test::Unit::TestCase
|
|
94
93
|
pdef = Ruote.process_definition do
|
95
94
|
concurrence do
|
96
95
|
sequence do
|
97
|
-
listen :to =>
|
96
|
+
listen :to => /^al.*/, :merge => false
|
98
97
|
bravo
|
99
98
|
end
|
100
99
|
sequence do
|
101
|
-
listen :to => '
|
100
|
+
listen :to => '/^al.*/', :upon => 'reply'
|
102
101
|
bravo
|
103
102
|
end
|
104
103
|
sequence do
|
@@ -130,7 +129,7 @@ class EftListenTest < Test::Unit::TestCase
|
|
130
129
|
set :f => 'other', :val => 'nothing'
|
131
130
|
concurrence do
|
132
131
|
sequence do
|
133
|
-
listen :to => '
|
132
|
+
listen :to => '/^al.*/', :merge => 'override', :upon => 'reply'
|
134
133
|
bravo
|
135
134
|
end
|
136
135
|
sequence do
|
@@ -171,12 +170,12 @@ class EftListenTest < Test::Unit::TestCase
|
|
171
170
|
|
172
171
|
#noisy
|
173
172
|
|
174
|
-
count = 0
|
173
|
+
stash[:count] = 0
|
175
174
|
|
176
175
|
@engine.register_participant :alpha do |wi|
|
177
176
|
@tracer << "alpha\n"
|
178
|
-
wi.fields['who'] = 'toto' if count > 0
|
179
|
-
count
|
177
|
+
wi.fields['who'] = 'toto' if stash[:count] > 0
|
178
|
+
stash[:count] += 1
|
180
179
|
end
|
181
180
|
|
182
181
|
wfid = @engine.launch(pdef)
|
@@ -185,7 +184,9 @@ class EftListenTest < Test::Unit::TestCase
|
|
185
184
|
|
186
185
|
assert_equal %w[ alpha alpha toto ].join("\n"), @tracer.to_s
|
187
186
|
assert_equal 3, @engine.process(wfid).expressions.size
|
188
|
-
|
187
|
+
|
188
|
+
assert_not_nil(
|
189
|
+
@engine.context.logger.log.find { |l| l['action'] == 'ceased' })
|
189
190
|
end
|
190
191
|
|
191
192
|
def test_listen_cancel
|
@@ -268,5 +269,70 @@ class EftListenTest < Test::Unit::TestCase
|
|
268
269
|
ps = @engine.process(lwfid)
|
269
270
|
assert_equal(3, ps.expressions.size)
|
270
271
|
end
|
272
|
+
|
273
|
+
def test_listen_to_tag
|
274
|
+
|
275
|
+
listening = Ruote.process_definition do
|
276
|
+
concurrence do
|
277
|
+
listen :to => :first_phase, :upon => :leaving do
|
278
|
+
echo 'left'
|
279
|
+
end
|
280
|
+
listen :to => :first_phase, :upon => :entering do
|
281
|
+
echo 'entered'
|
282
|
+
end
|
283
|
+
end
|
284
|
+
end
|
285
|
+
emitting = Ruote.process_definition do
|
286
|
+
sequence :tag => :first_phase do
|
287
|
+
echo 'in'
|
288
|
+
end
|
289
|
+
echo 'edone.'
|
290
|
+
end
|
291
|
+
|
292
|
+
#noisy
|
293
|
+
|
294
|
+
lwfid = @engine.launch(listening)
|
295
|
+
ewfid = @engine.launch(emitting)
|
296
|
+
|
297
|
+
wait_for(ewfid)
|
298
|
+
|
299
|
+
assert_equal(%w[ in entered edone. left ], @tracer.to_a)
|
300
|
+
end
|
301
|
+
|
302
|
+
def test_listen_and_doesnt_match
|
303
|
+
|
304
|
+
pdef = Ruote.define do
|
305
|
+
concurrence :count => 1 do
|
306
|
+
listen :to => 'stone', :upon => 'entering' do
|
307
|
+
echo 'stone'
|
308
|
+
end
|
309
|
+
sequence :tag => 'milestone' do
|
310
|
+
echo 'milestone'
|
311
|
+
end
|
312
|
+
end
|
313
|
+
end
|
314
|
+
|
315
|
+
assert_trace "milestone", pdef
|
316
|
+
end
|
317
|
+
|
318
|
+
def test_listen_and_do_match
|
319
|
+
|
320
|
+
pdef = Ruote.define do
|
321
|
+
concurrence :count => 1 do
|
322
|
+
listen :to => /stone/, :upon => 'entering' do
|
323
|
+
echo 'stone'
|
324
|
+
end
|
325
|
+
sequence :tag => 'milestone' do
|
326
|
+
echo 'milestone'
|
327
|
+
end
|
328
|
+
end
|
329
|
+
end
|
330
|
+
|
331
|
+
wfid = @engine.launch(pdef)
|
332
|
+
|
333
|
+
@engine.wait_for(wfid)
|
334
|
+
|
335
|
+
assert_equal %w[ milestone stone ], @tracer.to_a
|
336
|
+
end
|
271
337
|
end
|
272
338
|
|