weel 1.99.160 → 1.99.161

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c454d5f4cf369c43d4e1902ff7a7959b8a346ef5f2b5cb35443d496f9b785bc1
4
- data.tar.gz: 8bad731af306b1a96213ba758859c9b7738cf8984110c1aa9783901f9d2bef69
3
+ metadata.gz: 3802932f39357695d6c7829e3492c3b380ff4d6b92c0758c26fd63805039f361
4
+ data.tar.gz: 5d6fc0c6fb14fd5784ee695f3aba53e0adf63276df93ff19245e50def2533384
5
5
  SHA512:
6
- metadata.gz: cc1190238dd186630bcff388a92087e2516175351a504886bddbf169cd4a59d480f21fd95f6dec24a7ed50e3cdcac66da9a3296114d81059f5a4335ca74c6954
7
- data.tar.gz: 0f21bb6cdc0bd136e1f981b2c3034b1a80ce6dbfe7a98175b6cafdd36d20b01f6942ca0162b4aa981b23d9eeb6a018d06a3cc9a8c077f367c51e459d96ec4f97
6
+ metadata.gz: da14a8ad3488c5cc8941a94600562f0c3b2c6c8ac307843d31f84d2d0e9dc55702b81cde34814ac8398a424a358a5e994a210e3ba89ee7bbc6f42530f9e818a5
7
+ data.tar.gz: 35e42352ca70a2db9c05d8bddfce45b2f648fea9b5b1b8f1d20c514a30ac7e94b0ac56713b9b91a60a52285c8b9d45d7990130227cf9d338e6eb718e90c00ca9
data/lib/weel.rb CHANGED
@@ -29,7 +29,6 @@ class WEEL
29
29
  initialize_endpoints if methods.include?(:initialize_endpoints)
30
30
  initialize_connectionwrapper if methods.include?(:initialize_connectionwrapper)
31
31
  initialize_control if methods.include?(:initialize_control)
32
- initialize_flow_data if methods.include?(:initialize_flow_data)
33
32
  end # }}}
34
33
 
35
34
  module Signal # {{{
@@ -236,8 +235,6 @@ class WEEL
236
235
  attr_reader :additional
237
236
  end # }}}
238
237
  class ManipulateHash # {{{
239
- attr_reader :__weel_touched, :__weel_changed
240
-
241
238
  include WEEL::HashExt
242
239
 
243
240
  def initialize(values,touched,changed)
@@ -298,23 +295,6 @@ class WEEL
298
295
  @__weel_values = values
299
296
  end
300
297
  end # }}}
301
- class ReadOnlyHash # {{{
302
- include WEEL::HashExt
303
-
304
- def initialize(values)
305
- @__weel_values = values.transform_values do |v|
306
- if Object.const_defined?(:XML) && XML.const_defined?(:Smart) && v.is_a?(XML::Smart::Dom)
307
- v.root.to_doc
308
- else
309
- begin
310
- v.deep_dup
311
- rescue
312
- v.to_s rescue nil
313
- end
314
- end
315
- end
316
- end
317
- end # }}}
318
298
 
319
299
  class ProcString #{{{
320
300
  attr_reader :code
@@ -325,10 +305,11 @@ class WEEL
325
305
 
326
306
  class ConnectionWrapperBase # {{{
327
307
  def self::loop_guard(arguments,lid,count); false; end
328
- def self::inform_state_change(arguments,newstate,data); end
308
+ def self::inform_state_change(arguments,newstate); end
329
309
  def self::inform_syntax_error(arguments,err,code); end
330
310
  def self::inform_connectionwrapper_error(arguments,err); end
331
311
  def self::inform_position_change(arguments,ipc={}); end
312
+ def self::inform_activity_minimal(arguments,what,uuid,label,position); end
332
313
 
333
314
  def initialize(arguments,position=nil,continue=nil); end
334
315
 
@@ -357,11 +338,13 @@ class WEEL
357
338
  def test_condition(eid,dataelements,endpoints,local,additional,code,args={},props={}); ReadStructure.new(dataelements,endpoints,local,additional).instance_eval(code); end
358
339
  def manipulate(readonly,lock,dataelements,endpoints,status,local,additional,code,where,result=nil,options=nil)
359
340
  lock.synchronize do
360
- if readonly
361
- ReadStructure.new(dataelements,endpoints,local,additional).instance_eval(code,where,1)
341
+ struct = if readonly
342
+ ReadStructure.new(dataelements,endpoints,local,additional)
362
343
  else
363
- ManipulateStructure.new(dataelements,endpoints,local,additional).instance_eval(code,where,1)
344
+ ManipulateStructure.new(dataelements,endpoints,status,local,additional)
364
345
  end
346
+ struct.instance_eval(code,where,1)
347
+ struct
365
348
  end
366
349
  end
367
350
 
@@ -453,11 +436,7 @@ class WEEL
453
436
  self.description = block
454
437
  end
455
438
  end # }}}
456
- def self::flow(flow_data=nil) # {{{
457
- define_method :initialize_flow_data do
458
- self.flow_data = flow_data
459
- end if flow_data
460
- end #}}}
439
+ def self::flow; end # only syntax: control flow do ... end
461
440
 
462
441
  class DSLRealization # {{{
463
442
  def initialize #{{{
@@ -474,7 +453,7 @@ class WEEL
474
453
  @__weel_lock = Mutex.new
475
454
  end #}}}
476
455
  attr_accessor :__weel_search_positions, :__weel_positions, :__weel_main, :__weel_data, :__weel_endpoints, :__weel_connectionwrapper, :__weel_connectionwrapper_args
477
- attr_reader :__weel_state, :__weel_status, :__weel_status
456
+ attr_reader :__weel_state, :__weel_status
478
457
  def __weel_abandon? = @__weel_abandon
479
458
 
480
459
  # DSL-Construct for translating expressions into static parameters
@@ -666,26 +645,30 @@ class WEEL
666
645
  return if searchmode
667
646
  return if self.__weel_state == :stopping || self.__weel_state == :finishing || self.__weel_state == :stopped || Thread.current[:nolongernecessary]
668
647
 
648
+ unless Thread.current[:branch_parent]
649
+ self.__weel_state = :stopping
650
+ @__weel_connectionwrapper::inform_syntax_error(@__weel_connectionwrapper_args,Exception.new("wait_for_signal (#{position}) is only possible inside a parallel_branch"),nil)
651
+ return
652
+ end
653
+
669
654
  # gather traces in threads to point to join
670
- if Thread.current[:branch_parent] && Thread.current[:branch_traces_id]
655
+ if Thread.current[:branch_traces_id]
671
656
  Thread.current[:branch_parent][:branch_traces][Thread.current[:branch_traces_id]] ||= []
672
657
  Thread.current[:branch_parent][:branch_traces][Thread.current[:branch_traces_id]] << position
673
658
  end
674
659
 
675
660
  uuid = SecureRandom.uuid
676
- wp = __weel_progress position, SecureRandom.uuid
661
+ wp = __weel_progress position, uuid
677
662
 
678
663
  @__weel_connectionwrapper::inform_activity_minimal @__weel_connectionwrapper_args,'calling',uuid,label,position
679
664
 
680
665
  Thread.current[:branch_parent][:nudge].pop
681
666
  if self.__weel_state != :stopping
667
+ @__weel_connectionwrapper::inform_activity_minimal @__weel_connectionwrapper_args, 'done', uuid, label, position
682
668
  if Thread.current[:nolongernecessary]
683
- @__weel_connectionwrapper::inform_activity_minimal @__weel_connectionwrapper_args, 'done', uuid, label, position
684
669
  Thread.current[:branch_position] = nil
685
670
  @__weel_positions.delete wp
686
671
  @__weel_connectionwrapper::inform_position_change @__weel_connectionwrapper_args, :unmark => [wp]
687
- else
688
- @__weel_connectionwrapper::inform_activity_minimal @__weel_connectionwrapper_args, 'done', uuid, label, position
689
672
  end
690
673
  end
691
674
  __weel_activity_ensure
@@ -822,16 +805,22 @@ class WEEL
822
805
  def __weel_progress(position, uuid, skip=false) #{{{
823
806
  ipc = {}
824
807
  branch = Thread.current
825
- if Thread.current[:branch_parent] && Thread.current[:branch_parent][:branch_position]
826
- @__weel_positions.delete Thread.current[:branch_parent][:branch_position]
827
- ipc[:unmark] ||= []
828
- ipc[:unmark] << Thread.current[:branch_parent][:branch_position] rescue nil
829
- Thread.current[:branch_parent][:branch_position] = nil
808
+ if (parent = Thread.current[:branch_parent])
809
+ pbp = parent[:mutex].synchronize do
810
+ tmp = parent[:branch_position]
811
+ parent[:branch_position] = nil
812
+ tmp
813
+ end
814
+ if pbp
815
+ @__weel_positions.delete pbp
816
+ ipc[:unmark] ||= []
817
+ ipc[:unmark] << pbp
818
+ end
830
819
  end
831
820
  if Thread.current[:branch_position]
832
821
  @__weel_positions.delete Thread.current[:branch_position]
833
822
  ipc[:unmark] ||= []
834
- ipc[:unmark] << Thread.current[:branch_position] rescue nil
823
+ ipc[:unmark] << Thread.current[:branch_position]
835
824
  end
836
825
  wp = if branch[:branch_search_now] == true
837
826
  branch[:branch_search_now] = false
@@ -845,7 +834,6 @@ class WEEL
845
834
  @__weel_search_positions.each do |k,ele| # some may still be in active search but lets unmark them for good measure
846
835
  ipc[:unmark] ||= []
847
836
  ipc[:unmark] << ele
848
- true
849
837
  end
850
838
  ipc[:unmark].uniq! if ipc[:unmark]
851
839
 
@@ -883,11 +871,6 @@ class WEEL
883
871
  connectionwrapper.activity_manipulate_handle(parameters)
884
872
  connectionwrapper.inform_activity_manipulate
885
873
  struct = connectionwrapper.manipulate(false,@__weel_lock,@__weel_data,@__weel_endpoints,@__weel_status,Thread.current[:local],connectionwrapper.additional,finalize,'Activity ' + position.to_s)
886
- if signal
887
- 1.upto(Thread.current[:branch_parent][:nudge].num_waiting) do
888
- Thread.current[:branch_parent][:nudge].push(nil)
889
- end
890
- end
891
874
  connectionwrapper.inform_manipulate_change(
892
875
  ((struct && struct.changed_status) ? @__weel_status : nil),
893
876
  ((struct && struct.changed_data.any?) ? struct.changed_data.uniq : nil),
@@ -953,7 +936,7 @@ class WEEL
953
936
  struct = connectionwrapper.manipulate(false,@__weel_lock,@__weel_data,@__weel_endpoints,@__weel_status,Thread.current[:local],connectionwrapper.additional,code,'Activity ' + position.to_s + ' ' + cmess,activity_result_value,activity_result_options)
954
937
  Signal::Proceed
955
938
  end
956
- if signal
939
+ if signal && Thread.current[:branch_parent] # outside a parallel_branch nobody can wait for the signal
957
940
  1.upto(Thread.current[:branch_parent][:nudge].num_waiting) do
958
941
  Thread.current[:branch_parent][:nudge].push(nil)
959
942
  end
@@ -1027,16 +1010,9 @@ class WEEL
1027
1010
  end
1028
1011
  end
1029
1012
  end
1030
- Thread.current[:continue].clear if Thread.current[:continue] && Thread.current[:continue].is_a?(Continue)
1013
+ Thread.current[:continue].clear if Thread.current[:continue]
1031
1014
  end # }}}
1032
1015
 
1033
- def __weel_recursive_print(thread,indent='')# {{{
1034
- if thread[:branches]
1035
- thread[:branches].each do |b|
1036
- __weel_recursive_print(b,indent+' ')
1037
- end
1038
- end
1039
- end # }}}
1040
1016
  def __weel_recursive_continue(thread)# {{{
1041
1017
  return unless thread
1042
1018
  if thread[:nudge]
@@ -1050,7 +1026,7 @@ class WEEL
1050
1026
  if thread.alive? && thread[:branch_event]
1051
1027
  ### we dont mutex here anymore, although we did; we are not sure why we originally did it. Branch_event will always exist.
1052
1028
  ### thread[:mutex].synchronize do
1053
- thread[:branch_event].continue unless thread[:branch_event].nil?
1029
+ thread[:branch_event].continue
1054
1030
  ### end
1055
1031
  end
1056
1032
  if thread[:branches]
@@ -1103,7 +1079,7 @@ class WEEL
1103
1079
  def __weel_finalize #{{{
1104
1080
  __weel_recursive_join(@__weel_main)
1105
1081
  @__weel_state = :stopped
1106
- @__weel_connectionwrapper::inform_state_change @__weel_connectionwrapper_args, @__weel_state, @__weel_data
1082
+ @__weel_connectionwrapper::inform_state_change @__weel_connectionwrapper_args, @__weel_state
1107
1083
  end #}}}
1108
1084
 
1109
1085
  def __weel_state=(newState)# {{{
@@ -1112,7 +1088,7 @@ class WEEL
1112
1088
  @__weel_positions = Array.new if newState == :running
1113
1089
  @__weel_state = newState
1114
1090
 
1115
- @__weel_connectionwrapper::inform_state_change @__weel_connectionwrapper_args, @__weel_state, @__weel_data
1091
+ @__weel_connectionwrapper::inform_state_change @__weel_connectionwrapper_args, @__weel_state
1116
1092
 
1117
1093
  if newState == :stopping || newState == :finishing
1118
1094
  __weel_recursive_continue(@__weel_main)
@@ -1155,13 +1131,6 @@ public
1155
1131
  def state # {{{
1156
1132
  @dslr.__weel_state
1157
1133
  end # }}}
1158
- def state_signal # {{{
1159
- connectionwrapper::inform_state_change connectionwrapper_args, state, data
1160
- state
1161
- end # }}}
1162
- def abandon # {{{
1163
- @dslr.__weel_state = :abandoned
1164
- end # }}}
1165
1134
 
1166
1135
  # get/set workflow description
1167
1136
  def description(&blk)
@@ -1170,7 +1139,7 @@ public
1170
1139
  def description=(code) # {{{
1171
1140
  (class << self; self; end).class_eval do
1172
1141
  remove_method :__weel_control_flow if method_defined? :__weel_control_flow
1173
- define_method :__weel_control_flow do |state,final_state=:finished|
1142
+ define_method :__weel_control_flow do |state|
1174
1143
  @dslr.__weel_positions.clear
1175
1144
  @dslr.__weel_state = state
1176
1145
  begin
@@ -1234,7 +1203,7 @@ public
1234
1203
  @dslr.__weel_endpoints
1235
1204
  end # }}}
1236
1205
  def endpoint(new_endpoints) # {{{
1237
- unless new_endpoints.nil? || !new_endpoints.is_a?(Hash) || !new_endpoints.length == 1
1206
+ unless new_endpoints.nil? || !new_endpoints.is_a?(Hash) || new_endpoints.length != 1
1238
1207
  new_endpoints.each{ |k,v| @dslr.__weel_endpoints[k] = v }
1239
1208
  end
1240
1209
  nil
@@ -22,14 +22,14 @@ class TestConnectionWrapper < WEEL::ConnectionWrapperBase
22
22
  @t = nil
23
23
  end
24
24
 
25
- def prepare(readonly, endpoints, parameters, replay=false)
26
- @__myhandler_endpoint = readonly.endpoints[endpoints]
27
- parameters
25
+ def prepare(lock,dataelements,endpoints,status,local,additional,code,exec_endpoints,exec_parameters)
26
+ @__myhandler_endpoint = endpoints[exec_endpoints]
27
+ exec_parameters
28
28
  end
29
29
 
30
30
  # executes a ws-call to the given endpoint with the given parameters. the call
31
- # can be executed asynchron, see finished_call & return_value
32
- def activity_handle(passthrough, parameters) #{{{
31
+ # can be executed asynchron, the result is handed to weel through continue
32
+ def activity_handle(passthrough, parameters, dataelements) #{{{
33
33
  $long_track << "CALL #{@__myhandler_position}: passthrough=[#{passthrough}], endpoint=[#{@__myhandler_endpoint}], parameters=[#{parameters.inspect}]\n"
34
34
  $short_track << "C#{@__myhandler_position}"
35
35
 
@@ -44,10 +44,10 @@ class TestConnectionWrapper < WEEL::ConnectionWrapperBase
44
44
  @__myhandler_returnValue = parameters.has_key?(:result) ? parameters[:result] : 'Handler_Dummy_Result'
45
45
  Thread.new do
46
46
  while parameters[:again].call
47
- @__myhandler_continue.continue WEEL::Signal::Again
47
+ @__myhandler_continue.continue WEEL::Signal::UpdateAgain, @__myhandler_returnValue
48
48
  sleep 1
49
49
  end
50
- @__myhandler_continue.continue
50
+ @__myhandler_continue.continue WEEL::Signal::Proceed, @__myhandler_returnValue
51
51
  end
52
52
  return
53
53
  end
@@ -55,19 +55,14 @@ class TestConnectionWrapper < WEEL::ConnectionWrapperBase
55
55
  @t = Thread.new do
56
56
  parameters[:call].call
57
57
  @__myhandler_returnValue = parameters.has_key?(:result) ? parameters[:result] : 'Handler_Dummy_Result'
58
- @__myhandler_continue.continue
58
+ @__myhandler_continue.continue WEEL::Signal::Proceed, @__myhandler_returnValue
59
59
  end
60
60
  # give nothing back
61
61
  else
62
62
  @__myhandler_returnValue = parameters.has_key?(:result) ? parameters[:result] : 'Handler_Dummy_Result'
63
- @__myhandler_continue.continue
63
+ @__myhandler_continue.continue WEEL::Signal::Proceed, @__myhandler_returnValue
64
64
  end
65
65
  end #}}}
66
-
67
- # returns the result of the last handled call
68
- def activity_result_value #{{{
69
- @__myhandler_returnValue
70
- end #}}}
71
66
  # Called if the WS-Call should be interrupted. The decision how to deal
72
67
  # with this situation is given to the handler. To provide the possibility
73
68
  # of a continue the Handler will be asked for a passthrough
@@ -84,16 +79,13 @@ class TestConnectionWrapper < WEEL::ConnectionWrapperBase
84
79
  @__myhandler_passthrough
85
80
  end #}}}
86
81
 
87
- # Called if the execution of the actual activity_handle is not necessary anymore
88
- # It is definit that the call will not be continued.
82
+ # Called (after activity_stop) if the execution of the actual activity_handle
83
+ # is not necessary anymore. It is definit that the call will not be continued.
89
84
  # At this stage, this is only the case if parallel branches are not needed
90
85
  # anymore to continue the workflow
91
- def activity_no_longer_necessary #{{{
86
+ def inform_activity_cancelled #{{{
92
87
  $long_track += "NO_LONGER_NECCESARY #{@__myhandler_position}\n"
93
88
  $short_track << "NLN#{@__myhandler_position}"
94
- @t.exit if @t
95
- @__myhandler_returnValue = "No longer necessary"
96
- @__myhandler_stopped = true
97
89
  end #}}}
98
90
  # Is called if a Activity is executed correctly
99
91
  def inform_activity_manipulate #{{{
data/test/TestMixin.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  module SimTestMixin #{{{
2
2
  def setup
3
3
  $long_track = ""
4
- $short_track = ""
4
+ $short_track = String.new
5
5
  @wf = nil
6
6
  end
7
7
 
@@ -33,7 +33,7 @@ end #}}}
33
33
  module TestMixin #{{{
34
34
  def setup
35
35
  $long_track = ""
36
- $short_track = ""
36
+ $short_track = String.new
37
37
  @wf = TestWorkflow.new
38
38
  end
39
39
 
data/test/TestWorkflow.rb CHANGED
@@ -11,25 +11,21 @@ class TestWorkflow < WEEL
11
11
  data :x => 'begin_'
12
12
 
13
13
  control flow do
14
- call :a1_1, :endpoint1 do |result|
15
- data.x += "#{result}"
16
- end
17
- parallel :wait do
18
- parallel_branch do
14
+ call :a1_1, :endpoint1, finalize: 'data.x += "#{result}"'
15
+ parallel :p1 do
16
+ parallel_branch :p1_1 do
19
17
  call :a2_1_1, :endpoint1
20
18
  end
21
- parallel_branch do
19
+ parallel_branch :p1_2 do
22
20
  call :a2_2_1, :endpoint1
23
21
  end
24
22
  end
25
- manipulate :a3 do
26
- data.x += '_end'
27
- end
28
- choose do
29
- alternative data.x != nil do
23
+ manipulate :a3, "data.x += '_end'"
24
+ choose :c1 do
25
+ alternative :c1_1, 'data.x != nil' do
30
26
  call :a4a, :endpoint1
31
27
  end
32
- otherwise do
28
+ otherwise :c1_2 do
33
29
  call :a4b, :endpoint1
34
30
  end
35
31
  end
@@ -6,14 +6,14 @@ class TestChoose < Test::Unit::TestCase
6
6
 
7
7
  def test_choose_alternative
8
8
  @wf.description do
9
- choose do
10
- alternative true do
9
+ choose :c1 do
10
+ alternative :c1_1, true do
11
11
  call :a_1, :endpoint1
12
12
  end
13
- alternative false do
13
+ alternative :c1_2, false do
14
14
  call :a_2, :endpoint1
15
15
  end
16
- otherwise do
16
+ otherwise :c1_3 do
17
17
  call :a_3, :endpoint1
18
18
  end
19
19
  end
@@ -10,7 +10,7 @@ class TestCodeReplace < Test::Unit::TestCase
10
10
  call :a_test_1_2, :endpoint1
11
11
  call :a_test_1_3, :endpoint1
12
12
  end
13
- @wf.search WEEL::Position.new(:a_test_1_1, :at)
13
+ @wf.search WEEL::Position.new(:a_test_1_1, 0, :at)
14
14
  @wf.start.join
15
15
  wf_assert("CALL a_test_1_1:")
16
16
  wf_assert("CALL a_test_1_2:")
@@ -19,7 +19,7 @@ class TestCodeReplace < Test::Unit::TestCase
19
19
  end
20
20
  def test_wfdescription_string
21
21
  @wf.description = "call :b_test_1_1, :endpoint1"
22
- @wf.search WEEL::Position.new(:b_test_1_1, :at)
22
+ @wf.search WEEL::Position.new(:b_test_1_1, 0, :at)
23
23
  @wf.start.join
24
24
  wf_assert("DONE b_test_1_1")
25
25
  wf_sassert("|running|Cb_test_1_1Db_test_1_1|finished|")
@@ -31,7 +31,7 @@ class TestCodeReplace < Test::Unit::TestCase
31
31
  end
32
32
 
33
33
  assert(ret.class == Proc, "wf_description should be nil => not available. codeblock was given!")
34
- @wf.search WEEL::Position.new(:c_test_1_2, :at)
34
+ @wf.search WEEL::Position.new(:c_test_1_2, 0, :at)
35
35
  @wf.start.join
36
36
  wf_sassert("|running|Cc_test_1_2Dc_test_1_2|finished|")
37
37
  end
@@ -6,14 +6,14 @@ class TestParallel < Test::Unit::TestCase
6
6
 
7
7
  def test_parallel_simple
8
8
  @wf.description do
9
- parallel do
10
- parallel_branch do
9
+ parallel :p1 do
10
+ parallel_branch :p1_1 do
11
11
  call :a_1, :endpoint1, parameters: { :call => Proc.new{ sleep 0.5 } }
12
12
  end
13
- parallel_branch do
13
+ parallel_branch :p1_2 do
14
14
  call :a_2, :endpoint1, parameters: { :call => Proc.new{ sleep 0.5 } }
15
15
  end
16
- parallel_branch do
16
+ parallel_branch :p1_3 do
17
17
  call :a_3, :endpoint1, parameters: { :call => Proc.new{ sleep 0.5 } }
18
18
  end
19
19
  end
@@ -30,11 +30,11 @@ class TestParallel < Test::Unit::TestCase
30
30
  end
31
31
  def test_parallel_wait
32
32
  @wf.description do
33
- parallel :wait do
34
- parallel_branch do
33
+ parallel :p1 do
34
+ parallel_branch :p1_1 do
35
35
  call :a_1, :endpoint1, parameters: { :call => Proc.new{ sleep 0.2 } }
36
36
  end
37
- parallel_branch do
37
+ parallel_branch :p1_2 do
38
38
  call :a_2, :endpoint1, parameters: { :call => Proc.new{ sleep 0.5 } }
39
39
  end
40
40
  end
@@ -48,12 +48,12 @@ class TestParallel < Test::Unit::TestCase
48
48
  end
49
49
  def test_parallel_nowait
50
50
  @wf.description do
51
- parallel :wait => 1 do
52
- parallel_branch do
51
+ parallel :p1, :wait => 1 do
52
+ parallel_branch :p1_1 do
53
53
  sleep 0.5
54
54
  call :a_1, :endpoint1
55
55
  end
56
- parallel_branch do
56
+ parallel_branch :p1_2 do
57
57
  call :a_2, :endpoint1, parameters: { :call => Proc.new{ sleep 8.5 } }
58
58
  end
59
59
  end
@@ -62,15 +62,15 @@ class TestParallel < Test::Unit::TestCase
62
62
  @wf.start.join
63
63
  wf_assert('CALL a_1')
64
64
  wf_assert('CALL a_2')
65
- wf_sassert('NLNa_2Ca_3Da_3|finished|')
65
+ wf_sassert('Sa_2NLNa_2Da_2Ca_3Da_3|finished|')
66
66
  end
67
67
  def test_parallel_no_longer_necessary
68
68
  @wf.description do
69
- parallel :wait => 1 do
70
- parallel_branch do
69
+ parallel :p1, :wait => 1 do
70
+ parallel_branch :p1_1 do
71
71
  call :a_1, :endpoint1, parameters: { :call => Proc.new{ sleep 0.2 } }
72
72
  end
73
- parallel_branch do
73
+ parallel_branch :p1_2 do
74
74
  call :a_2, :endpoint1, parameters: { :call => Proc.new{ sleep 0.5 } }
75
75
  call :a_2_2, :endpoint1
76
76
  end
@@ -80,7 +80,8 @@ class TestParallel < Test::Unit::TestCase
80
80
  @wf.start.join
81
81
  wf_assert('CALL a_1')
82
82
  wf_assert('CALL a_2')
83
- wf_sassert('NLNa_2Ca_3Da_3|finished|')
83
+ wf_assert('CALL a_2_2',false)
84
+ wf_sassert('Sa_2NLNa_2Da_2Ca_3Da_3|finished|')
84
85
  end
85
86
  def test_parallel_nested
86
87
  # |- :a_1
@@ -91,19 +92,19 @@ class TestParallel < Test::Unit::TestCase
91
92
  # |-|- :a_2_3
92
93
  # |- => :a_3
93
94
  @wf.description do
94
- parallel :wait do
95
- parallel_branch do call :a_1, :endpoint1 end
96
- parallel_branch do
97
- parallel :wait do
98
- parallel_branch do
99
- parallel :wait do
100
- parallel_branch do call :a_2_1_1, :endpoint1, parameters: { :call => Proc.new {sleep 0.2} } end
101
- parallel_branch do call :a_2_1_2, :endpoint1, parameters: { :call => Proc.new {sleep 0.4} } end
95
+ parallel :p1 do
96
+ parallel_branch :p1_1 do call :a_1, :endpoint1 end
97
+ parallel_branch :p1_2 do
98
+ parallel :p2 do
99
+ parallel_branch :p2_1 do
100
+ parallel :p3 do
101
+ parallel_branch :p3_1 do call :a_2_1_1, :endpoint1, parameters: { :call => Proc.new {sleep 0.2} } end
102
+ parallel_branch :p3_2 do call :a_2_1_2, :endpoint1, parameters: { :call => Proc.new {sleep 0.4} } end
102
103
  end
103
104
  call :a_2_1_3, :endpoint1, parameters: { :call => Proc.new {sleep 0.8} }
104
105
  end
105
- parallel_branch do call :a_2_2, :endpoint1, parameters: { :call => Proc.new {sleep 0.8} } end
106
- parallel_branch do call :a_2_3, :endpoint1, parameters: { :call => Proc.new {sleep 1.0} } end
106
+ parallel_branch :p2_2 do call :a_2_2, :endpoint1, parameters: { :call => Proc.new {sleep 0.8} } end
107
+ parallel_branch :p2_3 do call :a_2_3, :endpoint1, parameters: { :call => Proc.new {sleep 1.0} } end
107
108
  end
108
109
  end
109
110
  end
@@ -0,0 +1,80 @@
1
+ require 'test/unit'
2
+ require 'timeout'
3
+ require File.expand_path(::File.dirname(__FILE__) + '/../../lib/weel')
4
+
5
+ # Two sibling parallel branches share their parent thread. When both make
6
+ # progress at the same time, __weel_progress in each of them looks at the
7
+ # parent's :branch_position to unmark it. Without the take-and-clear under the
8
+ # parent's mutex, both can see it set, one clears it, and the other then
9
+ # reports nil in ipc[:unmark].
10
+ #
11
+ # The race is forced deterministically: positions is replaced by an array whose
12
+ # delete blocks the first branch that deletes the parent's position, until the
13
+ # second branch has completely finished its progress.
14
+ class TestProgressRace < Test::Unit::TestCase
15
+ class RecordingWrapper < WEEL::ConnectionWrapperBase
16
+ @@ipcs = Queue.new
17
+ def self::ipcs; @@ipcs; end
18
+ def self::inform_position_change(arguments,ipc={})
19
+ @@ipcs << ipc
20
+ end
21
+ end
22
+
23
+ class GatedPositions < Array
24
+ attr_reader :blocked
25
+ def initialize(gated)
26
+ super()
27
+ @gated = gated
28
+ @first = true
29
+ @lock = Mutex.new
30
+ @blocked = Queue.new # signalled when the first branch waits
31
+ @release = Queue.new # opened by the test
32
+ end
33
+ def open; @release << true; end
34
+ def delete(obj)
35
+ wait = @lock.synchronize { (obj.equal?(@gated) && @first).tap { @first = false } }
36
+ if wait
37
+ @blocked << true
38
+ @release.pop
39
+ end
40
+ super
41
+ end
42
+ end
43
+
44
+ def test_sibling_progress_never_unmarks_nil
45
+ wf = WEEL.new
46
+ wf.connectionwrapper = RecordingWrapper
47
+ dslr = wf.instance_variable_get(:@dslr)
48
+
49
+ parent_pos = WEEL::Position.new(:parent_activity, 'parent-uuid')
50
+ positions = GatedPositions.new(parent_pos)
51
+ positions << parent_pos
52
+ dslr.__weel_positions = positions
53
+
54
+ parent = Thread.new { sleep } # stands in for the thread that runs parallel
55
+ parent[:mutex] = Mutex.new
56
+ parent[:branch_position] = parent_pos
57
+
58
+ branch = lambda do |name|
59
+ Thread.new do
60
+ Thread.current[:branch_parent] = parent
61
+ dslr.send(:__weel_progress, name, "#{name}-uuid")
62
+ end
63
+ end
64
+
65
+ a = branch.call(:a1)
66
+ Timeout.timeout(5) { positions.blocked.pop } # a1 sits inside the unmark of the parent position
67
+ b = branch.call(:a2)
68
+ assert_not_nil b.join(5), 'second branch did not finish'
69
+ positions.open
70
+ assert_not_nil a.join(5), 'first branch did not finish'
71
+
72
+ unmarked = []
73
+ unmarked.concat(RecordingWrapper.ipcs.pop[:unmark] || []) until RecordingWrapper.ipcs.empty?
74
+
75
+ assert_not_include unmarked, nil, 'a branch reported nil as an unmarked position'
76
+ assert_equal [parent_pos], unmarked, 'the parent position must be unmarked exactly once'
77
+ ensure
78
+ parent&.kill
79
+ end
80
+ end
@@ -10,24 +10,24 @@ class TestSearch < Test::Unit::TestCase
10
10
  call :a1_2, :endpoint1
11
11
  call :a1_3, :endpoint1
12
12
  end
13
- @wf.search WEEL::Position.new(:a1_2, :at)
13
+ @wf.search WEEL::Position.new(:a1_2, 0, :at)
14
14
  @wf.start.join
15
15
  wf_sassert("|running|Ca1_2Da1_2Ca1_3Da1_3|finished|")
16
16
  end
17
17
  def test_search_impact_dual
18
18
  @wf.description do
19
19
  call :a1, :endpoint1
20
- parallel do
21
- parallel_branch do
20
+ parallel :p1 do
21
+ parallel_branch :p1_1 do
22
22
  call :a2_1, :endpoint1
23
23
  end
24
- parallel_branch do
24
+ parallel_branch :p1_2 do
25
25
  call :a2_2, :endpoint1
26
26
  end
27
27
  end
28
28
  call :a3, :endpoint1
29
29
  end
30
- @wf.search [WEEL::Position.new(:a2_1, :at), WEEL::Position.new(:a2_2, :at)]
30
+ @wf.search [WEEL::Position.new(:a2_1, 0, :at), WEEL::Position.new(:a2_2, 0, :at)]
31
31
  @wf.start.join
32
32
  wf_assert("DONE a1",false)
33
33
  wf_assert("DONE a2_1",true)
@@ -24,7 +24,7 @@ class TestWorkflowControl < Test::Unit::TestCase
24
24
  call :a_test_1_2, :endpoint1, parameters: { :call => Proc.new{ sleep 0.5 }, :async => true }
25
25
  call :a_test_1_3, :endpoint1
26
26
  end
27
- @wf.search WEEL::Position.new(:a_test_1_1, :at)
27
+ @wf.search WEEL::Position.new(:a_test_1_1, 0, :at)
28
28
  wf = @wf.start
29
29
  sleep(0.2)
30
30
  @wf.stop.join
@@ -45,7 +45,7 @@ class TestWorkflowControl < Test::Unit::TestCase
45
45
  call :a_test_1_2, :endpoint1, parameters: { :call => Proc.new{ sleep 0.5 } }
46
46
  call :a_test_1_3, :endpoint1
47
47
  end
48
- @wf.search WEEL::Position.new(:a_test_1_1, :at)
48
+ @wf.search WEEL::Position.new(:a_test_1_1, 0, :at)
49
49
  wf = @wf.start
50
50
  sleep(0.2)
51
51
  @wf.stop.join
@@ -10,26 +10,24 @@ class TestGeneralsynchonizingmergeLoopsearch < Test::Unit::TestCase
10
10
  @wf.data[:costs] = 0
11
11
  @wf.data[:persons] = 3
12
12
  @wf.description do
13
- call :a1, :endpoint1 do
13
+ call :a1, :endpoint1, finalize: <<-END
14
14
  data.airline = 'Aeroflot'
15
15
  data.costs += 101
16
16
  status.update 1, 'Hotel'
17
- end
18
- parallel do
19
- loop pre_test{data.persons > 0} do
20
- parallel_branch data.persons do |p|
21
- call :a2, :endpoint1 do
17
+ END
18
+ parallel :p1 do
19
+ loop :l1, pre_test('data.persons > 0') do
20
+ parallel_branch :p1_1 do |p|
21
+ call :a2, :endpoint1, finalize: <<-END
22
22
  data.hotels << 'Rathaus'
23
23
  data.costs += 200
24
- end
25
- end
26
- manipulate :a3 do
27
- data.persons -= 1
24
+ END
28
25
  end
26
+ manipulate :a3, 'data.persons -= 1'
29
27
  end
30
28
  end
31
- choose do
32
- alternative data.costs > 400 do
29
+ choose :c1 do
30
+ alternative :c1_1, 'data.costs > 400' do
33
31
  call :a4, :endpoint1
34
32
  end
35
33
  end
@@ -45,31 +43,29 @@ class TestGeneralsynchonizingmergeLoopsearch < Test::Unit::TestCase
45
43
  @wf.data[:costs] = 802
46
44
  @wf.data[:persons] = 2
47
45
  @wf.description do
48
- call :a1, :endpoint1 do
46
+ call :a1, :endpoint1, finalize: <<-END
49
47
  data.airline = 'Aeroflot'
50
48
  data.costs += 101
51
49
  status.update 1, 'Hotel'
52
- end
53
- parallel do
54
- loop pre_test{data.persons > 0} do
55
- parallel_branch data.persons do |p|
56
- call :a2, :endpoint1 do
50
+ END
51
+ parallel :p1 do
52
+ loop :l1, pre_test('data.persons > 0') do
53
+ parallel_branch :p1_1 do |p|
54
+ call :a2, :endpoint1, finalize: <<-END
57
55
  data.hotels << 'Rathaus'
58
56
  data.costs += 200
59
- end
60
- end
61
- manipulate :a3 do
62
- data.persons -= 1
57
+ END
63
58
  end
59
+ manipulate :a3, 'data.persons -= 1'
64
60
  end
65
61
  end
66
- choose do
67
- alternative data.costs > 700 do
62
+ choose :c1 do
63
+ alternative :c1_1, 'data.costs > 700' do
68
64
  call :a4, :endpoint1
69
65
  end
70
66
  end
71
67
  end
72
- @wf.search [WEEL::Position.new(:a3, :at)]
68
+ @wf.search [WEEL::Position.new(:a3, 0, :at)]
73
69
  @wf.start.join
74
70
 
75
71
  wf_rsassert('\|running\|Ma3Da3Ma3Da3Ca2.*?Ca2.*Da2Ca4Da4\|finished\|')
@@ -81,31 +77,29 @@ class TestGeneralsynchonizingmergeLoopsearch < Test::Unit::TestCase
81
77
  @wf.data[:costs] = 802
82
78
  @wf.data[:persons] = 2
83
79
  @wf.description do
84
- call :a1, :endpoint1 do
80
+ call :a1, :endpoint1, finalize: <<-END
85
81
  data.airline = 'Aeroflot'
86
82
  data.costs += 101
87
83
  status.update 1, 'Hotel'
88
- end
89
- parallel do
90
- loop pre_test{data.persons > 0} do
91
- parallel_branch data.persons do |p|
92
- call :a2, :endpoint1 do
84
+ END
85
+ parallel :p1 do
86
+ loop :l1, pre_test('data.persons > 0') do
87
+ parallel_branch :p1_1 do |p|
88
+ call :a2, :endpoint1, finalize: <<-END
93
89
  data.hotels << 'Rathaus'
94
90
  data.costs += 200
95
- end
96
- end
97
- manipulate :a3 do
98
- data.persons -= 1
91
+ END
99
92
  end
93
+ manipulate :a3, 'data.persons -= 1'
100
94
  end
101
95
  end
102
- choose do
103
- alternative data.costs > 700 do
96
+ choose :c1 do
97
+ alternative :c1_1, 'data.costs > 700' do
104
98
  call :a4, :endpoint1
105
99
  end
106
100
  end
107
101
  end
108
- @wf.search [WEEL::Position.new(:a2, :at)]
102
+ @wf.search [WEEL::Position.new(:a2, 0, :at)]
109
103
  @wf.start.join
110
104
 
111
105
  wf_rsassert('\|running\|Ca2Ma2Da2Ca4Da4\|finished\|')
@@ -8,19 +8,19 @@ class TestParallelStop < Test::Unit::TestCase
8
8
  @wf.data[:hotels] = []
9
9
  @wf.data[:costs] = 0
10
10
  @wf.description do
11
- parallel do
12
- parallel_branch do
13
- call :a1, :endpoint1 do
11
+ parallel :p1 do
12
+ parallel_branch :p1_1 do
13
+ call :a1, :endpoint1, finalize: <<-END
14
14
  data.hotels << 'Rathaus'
15
15
  data.costs += 200
16
- end
16
+ END
17
17
  call :a3, :stop
18
18
  end
19
- parallel_branch do
20
- call :a2, :endpoint2 do
19
+ parallel_branch :p1_2 do
20
+ call :a2, :endpoint2, finalize: <<-END
21
21
  data.hotels << 'Graf Stadion'
22
22
  data.costs += 200
23
- end
23
+ END
24
24
  call :a4, :stop
25
25
  end
26
26
  end
@@ -7,7 +7,7 @@ class TestAdventureSearch < Test::Unit::TestCase
7
7
  def test_search_adventure
8
8
  @wf.data[:oee] = 0.25
9
9
  @wf.description = File.read(__dir__ + '/dsl1')
10
- @wf.search [WEEL::Position.new(:a2, :at), WEEL::Position.new(:a13, :at)]
10
+ @wf.search [WEEL::Position.new(:a2, 0, :at), WEEL::Position.new(:a13, 0, :at)]
11
11
  @wf.start.join
12
12
 
13
13
  wf_assert("DONE a2",true)
@@ -6,12 +6,10 @@ class TestAgain < Test::Unit::TestCase
6
6
 
7
7
  def test_again
8
8
  @wf.data[:a] = 0
9
+ $again_count = 0
9
10
  @wf.description do
10
- call :a_1, :again, parameters: { :again => Proc.new{data.a < 2} }, update: -> do
11
- data.a += 1
12
- end, finalize: -> do
13
- data.a += 1
14
- end
11
+ # the handler asks :again before each answer: twice update, then finalize
12
+ call :a_1, :again, parameters: { :again => Proc.new{ ($again_count += 1) < 3 } }, update: 'data.a += 1', finalize: 'data.a += 1'
15
13
  end
16
14
  @wf.start.join
17
15
  wf_assert("CALL a_1")
data/test/exec/tc_exec.rb CHANGED
@@ -11,9 +11,7 @@ class TestChoose < Test::Unit::TestCase
11
11
  manipulate :a_1, <<-end
12
12
  data.a = 1
13
13
  end
14
- call :a_2, :endpoint1 do
15
- data.b = 1
16
- end
14
+ call :a_2, :endpoint1, finalize: 'data.b = 1'
17
15
  end
18
16
  @wf.start.join
19
17
  wf_assert("MANIPULATE a_1")
@@ -8,14 +8,14 @@ class TestSpeed1 < Test::Unit::TestCase
8
8
  1.upto(10000) do
9
9
  wf = TestWorkflow.new
10
10
  wf.description do
11
- choose do
12
- alternative true do
11
+ choose :c1 do
12
+ alternative :c1_1, true do
13
13
  call :a_1, :endpoint1
14
14
  end
15
- alternative false do
15
+ alternative :c1_2, false do
16
16
  call :a_2, :endpoint1
17
17
  end
18
- otherwise do
18
+ otherwise :c1_3 do
19
19
  call :a_3, :endpoint1
20
20
  end
21
21
  end
@@ -7,25 +7,23 @@ class TestWFPGeneralSynchronizingMerge < Test::Unit::TestCase
7
7
  def test_generalsyncmerge
8
8
  @wf.data[:cont] = true
9
9
  @wf.description do
10
- parallel do
11
- parallel_branch do
10
+ parallel :p1 do
11
+ parallel_branch :p1_1 do
12
12
  call :a1_1, :endpoint1, parameters: { :call => Proc.new{sleep 0.2} }
13
13
  end
14
- parallel_branch do
14
+ parallel_branch :p1_2 do
15
15
  call :a1_2, :endpoint1, parameters: { :call => Proc.new{sleep 0.4} }
16
16
  end
17
- choose do
18
- alternative(true) do
19
- loop post_test{data.break} do
20
- parallel_branch do
17
+ choose :c1 do
18
+ alternative(:c1_1, true) do
19
+ loop :l1, post_test('data.break') do
20
+ parallel_branch :p1_3 do
21
21
  call :a2_1, :endpoint1
22
- end
23
- call(:a2_decide, :endpoint1, parameters: { :result => false}) do |e|
24
- data.break = e
25
22
  end
26
- end
23
+ call(:a2_decide, :endpoint1, parameters: { :result => false}, finalize: 'data.break = result')
24
+ end
27
25
  end
28
- otherwise do
26
+ otherwise :c1_2 do
29
27
  call :a2_2, :endpoint1, parameters: { :call => Proc.new{sleep 0.1} }
30
28
  end
31
29
  end
@@ -6,20 +6,20 @@ class TestWFPLocalSynchronizingMerge < Test::Unit::TestCase
6
6
 
7
7
  def test_localsyncmerge
8
8
  @wf.description do
9
- parallel do
10
- parallel_branch do
9
+ parallel :p1 do
10
+ parallel_branch :p1_1 do
11
11
  call :a1_1, :endpoint1, parameters: { :call => Proc.new{sleep 0.2} }
12
12
  end
13
- parallel_branch do
13
+ parallel_branch :p1_2 do
14
14
  call :a1_2, :endpoint1, parameters: { :call => Proc.new{sleep 0.4} }
15
15
  end
16
- choose do
17
- alternative(false) do
18
- parallel_branch do
16
+ choose :c1 do
17
+ alternative(:c1_1, false) do
18
+ parallel_branch :p1_3 do
19
19
  call :a2_1, :endpoint1
20
- end
20
+ end
21
21
  end
22
- otherwise do
22
+ otherwise :c1_2 do
23
23
  call :a2_2, :endpoint1, parameters: { :call => Proc.new{sleep 0.1} }
24
24
  end
25
25
  end
@@ -7,11 +7,11 @@ class TestWFPMultiChoice < Test::Unit::TestCase
7
7
  def test_multichoice_chained
8
8
  @wf.data :x => 1
9
9
  @wf.description do
10
- choose do
11
- alternative(data.x == 1) do
10
+ choose :c1 do
11
+ alternative(:c1_1, 'data.x == 1') do
12
12
  call :a1_1, :endpoint1
13
13
  end
14
- alternative(data.x > 0) do
14
+ alternative(:c1_2, 'data.x > 0') do
15
15
  call :a1_2, :endpoint1
16
16
  end
17
17
  end
@@ -23,16 +23,16 @@ class TestWFPMultiChoice < Test::Unit::TestCase
23
23
  def test_multichoice_parallel
24
24
  @wf.data :x => 1
25
25
  @wf.description do
26
- choose do
27
- parallel do
28
- parallel_branch do
29
- alternative(data.x == 1) do
26
+ choose :c1 do
27
+ parallel :p1 do
28
+ parallel_branch :p1_1 do
29
+ alternative(:c1_1, 'data.x == 1') do
30
30
  call :a1_1, :endpoint1
31
31
  Thread.pass
32
32
  end
33
33
  end
34
- parallel_branch do
35
- alternative(data.x > 0) do
34
+ parallel_branch :p1_2 do
35
+ alternative(:c1_2, 'data.x > 0') do
36
36
  call :a1_2, :endpoint1, parameters: { :call => Proc.new{sleep 0.5} }
37
37
  end
38
38
  end
@@ -7,12 +7,12 @@ class TestWFPStructuredDiscriminator < Test::Unit::TestCase
7
7
 
8
8
  def test_cancelling_discriminator
9
9
  @wf.description do
10
- parallel :wait => 1 do
11
- parallel_branch do
10
+ parallel :p1, :wait => 1 do
11
+ parallel_branch :p1_1 do
12
12
  sleep 0.5
13
13
  call :a_1_1, :endpoint1
14
14
  end
15
- parallel_branch do
15
+ parallel_branch :p1_2 do
16
16
  call :a_1_2, :endpoint1, parameters: { :call => Proc.new{sleep 8.2} }
17
17
  end
18
18
  end
@@ -7,20 +7,20 @@ class TestWFPCancellingStructuredPartialJoin < Test::Unit::TestCase
7
7
 
8
8
  def test_cancelling_structured_partial_join
9
9
  @wf.description do
10
- parallel :wait => 3 do
11
- parallel_branch do
10
+ parallel :p1, :wait => 3 do
11
+ parallel_branch :p1_1 do
12
12
  call :a_1, :endpoint1
13
13
  end
14
- parallel_branch do
14
+ parallel_branch :p1_2 do
15
15
  call :a_2, :endpoint1, parameters: { :call => Proc.new{sleep 0.2} }
16
16
  end
17
- parallel_branch do
17
+ parallel_branch :p1_3 do
18
18
  call :a_3, :endpoint1
19
19
  end
20
- parallel_branch do
20
+ parallel_branch :p1_4 do
21
21
  call :a_4, :endpoint1, parameters: { :call => Proc.new{sleep 0.6} }
22
22
  end
23
- parallel_branch do
23
+ parallel_branch :p1_5 do
24
24
  call :a_5, :endpoint1
25
25
  end
26
26
  end
@@ -6,11 +6,11 @@ class TestWFPExclusiveChoice < Test::Unit::TestCase
6
6
 
7
7
  def test_exclusive_choice
8
8
  @wf.description do
9
- choose do
10
- alternative(true) do
9
+ choose :c1, :exclusive do
10
+ alternative(:c1_1, true) do
11
11
  call :a1_1, :endpoint1
12
12
  end
13
- otherwise do
13
+ otherwise :c1_2 do
14
14
  call :a1_2, :endpoint1
15
15
  end
16
16
  end
@@ -6,11 +6,11 @@ class TestWFPParallel < Test::Unit::TestCase
6
6
 
7
7
  def test_parallel_split
8
8
  @wf.description do
9
- parallel :wait do
10
- parallel_branch do
9
+ parallel :p1 do
10
+ parallel_branch :p1_1 do
11
11
  call :a1_1, :endpoint1
12
12
  end
13
- parallel_branch do
13
+ parallel_branch :p1_2 do
14
14
  call :a1_2, :endpoint1
15
15
  end
16
16
  end
@@ -7,13 +7,9 @@ class TestWFPInterleavedParallelRouting < Test::Unit::TestCase
7
7
 
8
8
  def test_loop
9
9
  @wf.description do
10
- manipulate :a1 do
11
- data.x = 0
12
- end
13
- loop pre_test{data.x < 3} do
14
- call :a2, :endpoint1 do
15
- data.x += 1
16
- end
10
+ manipulate :a1, 'data.x = 0'
11
+ loop :l1, pre_test('data.x < 3') do
12
+ call :a2, :endpoint1, finalize: 'data.x += 1'
17
13
  end
18
14
  call :a3, :endpoint1
19
15
  end
@@ -24,18 +20,14 @@ class TestWFPInterleavedParallelRouting < Test::Unit::TestCase
24
20
  end
25
21
  def test_loop_search
26
22
  @wf.description do
27
- manipulate :a1 do
28
- data.x = 0
29
- end
30
- loop pre_test{data.x < 3} do
23
+ manipulate :a1, 'data.x = 0'
24
+ loop :l1, pre_test('data.x < 3') do
31
25
  call :a2_1, :endpoint1
32
- manipulate :a2_2 do
33
- data.x += 1
34
- end
26
+ manipulate :a2_2, 'data.x += 1'
35
27
  end
36
28
  call :a3, :endpoint1
37
29
  end
38
- @wf.search WEEL::Position.new(:a2_2, :at)
30
+ @wf.search WEEL::Position.new(:a2_2, 0, :at)
39
31
  @wf.data :x => 2
40
32
  @wf.start.join
41
33
  wf_sassert('|running|Ma2_2Da2_2Ca3Da3|finished|');
@@ -44,18 +36,14 @@ class TestWFPInterleavedParallelRouting < Test::Unit::TestCase
44
36
  end
45
37
  def test_loop_jump_over
46
38
  @wf.description do
47
- manipulate :a1 do
48
- data.x = 0
49
- end
50
- loop pre_test{data.x < 3} do
39
+ manipulate :a1, 'data.x = 0'
40
+ loop :l1, pre_test('data.x < 3') do
51
41
  call :a2_1, :endpoint1
52
- manipulate :a2_2 do
53
- data.x += 1
54
- end
42
+ manipulate :a2_2, 'data.x += 1'
55
43
  end
56
44
  call :a3, :endpoint1
57
45
  end
58
- @wf.search WEEL::Position.new(:a3, :at)
46
+ @wf.search WEEL::Position.new(:a3, 0, :at)
59
47
  @wf.data :x => 0
60
48
  @wf.start.join
61
49
  wf_sassert('|running|Ca3Da3|finished|');
@@ -7,24 +7,20 @@ class TestWFPDeferredChoice < Test::Unit::TestCase
7
7
 
8
8
  def test_sequence
9
9
  @wf.description do
10
- parallel :wait=>1 do
11
- parallel_branch do
12
- call :a1_1, :endpoint1, parameters: { :call => Proc.new{sleep 0.5} } do
13
- data.choice = 1
14
- end
10
+ parallel :p1, :wait=>1 do
11
+ parallel_branch :p1_1 do
12
+ call :a1_1, :endpoint1, parameters: { :call => Proc.new{sleep 0.5} }, finalize: 'data.choice = 1'
15
13
  Thread.pass
16
14
  end
17
- parallel_branch do
18
- call :a1_2, :endpoint1, parameters: { :call => Proc.new{sleep 1.0} } do
19
- data.choice = 2
20
- end
15
+ parallel_branch :p1_2 do
16
+ call :a1_2, :endpoint1, parameters: { :call => Proc.new{sleep 1.0} }, finalize: 'data.choice = 2'
21
17
  end
22
18
  end
23
- choose do
24
- alternative(data.choice == 1) do
19
+ choose :c1 do
20
+ alternative(:c1_1, 'data.choice == 1') do
25
21
  call :a2_1, :endpoint1
26
22
  end
27
- alternative(data.choice == 2) do
23
+ alternative(:c1_2, 'data.choice == 2') do
28
24
  call :a2_2, :endpoint1
29
25
  end
30
26
  end
@@ -33,7 +29,7 @@ class TestWFPDeferredChoice < Test::Unit::TestCase
33
29
  wf_assert('CALL a1_1')
34
30
  wf_assert('DONE a1_1')
35
31
  wf_assert('MANIPULATE a1_1')
36
- wf_sassert('NLNa1_2Ca2_1Da2_1|finished|')
32
+ wf_sassert('Sa1_2NLNa1_2Da1_2Ca2_1Da2_1|finished|')
37
33
  data = @wf.data
38
34
  assert(data[:choice] == 1, "data[:choice] has not the correct value [#{data[:x]}]")
39
35
  end
@@ -7,17 +7,17 @@ class TestWFPInterleavedParallelRouting < Test::Unit::TestCase
7
7
 
8
8
  def test_interleaved
9
9
  @wf.description do
10
- parallel do
11
- parallel_branch do
12
- critical(:section1) do
10
+ parallel :p1 do
11
+ parallel_branch :p1_1 do
12
+ critical(:cr1, :section1) do
13
13
  call :a1, :endpoint1
14
14
  end
15
- critical(:section1) do
15
+ critical(:cr2, :section1) do
16
16
  call :a3, :endpoint1
17
17
  end
18
18
  end
19
- parallel_branch do
20
- critical(:section1) do
19
+ parallel_branch :p1_2 do
20
+ critical(:cr3, :section1) do
21
21
  call :a2, :endpoint1
22
22
  end
23
23
  end
data/weel.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "weel"
3
- s.version = "1.99.160"
3
+ s.version = "1.99.161"
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.license = "LGPL-3.0-or-later"
6
6
  s.summary = "Workflow Execution Engine Library (WEEL)"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: weel
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.99.160
4
+ version: 1.99.161
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juergen eTM Mangler
@@ -82,6 +82,7 @@ files:
82
82
  - test/basic/tc_endpoint.rb
83
83
  - test/basic/tc_handler.rb
84
84
  - test/basic/tc_parallel.rb
85
+ - test/basic/tc_progress_race.rb
85
86
  - test/basic/tc_search.rb
86
87
  - test/basic/tc_state.rb
87
88
  - test/basic/tc_wf_control.rb
@@ -142,6 +143,7 @@ test_files:
142
143
  - test/basic/tc_endpoint.rb
143
144
  - test/basic/tc_handler.rb
144
145
  - test/basic/tc_parallel.rb
146
+ - test/basic/tc_progress_race.rb
145
147
  - test/basic/tc_search.rb
146
148
  - test/basic/tc_state.rb
147
149
  - test/basic/tc_wf_control.rb