openwferu 0.9.7 → 0.9.8
Sign up to get free protection for your applications and to get access to all the features.
- data/examples/engine_template.rb +182 -0
- data/examples/openwferu.rb +6 -7
- data/lib/openwfe/contextual.rb +8 -6
- data/lib/openwfe/engine/engine.rb +49 -14
- data/lib/openwfe/expool/expressionpool.rb +48 -17
- data/lib/openwfe/expool/history.rb +64 -14
- data/lib/openwfe/expool/journal.rb +66 -28
- data/lib/openwfe/expool/journal_replay.rb +190 -48
- data/lib/openwfe/expool/wfidgen.rb +51 -6
- data/lib/openwfe/expressions/condition.rb +49 -5
- data/lib/openwfe/expressions/environment.rb +9 -37
- data/lib/openwfe/expressions/expressionmap.rb +15 -1
- data/lib/openwfe/expressions/fe_concurrence.rb +4 -4
- data/lib/openwfe/expressions/fe_cron.rb +1 -5
- data/lib/openwfe/expressions/fe_do.rb +96 -26
- data/lib/openwfe/expressions/fe_equals.rb +190 -0
- data/lib/openwfe/expressions/fe_fqv.rb +25 -7
- data/lib/openwfe/expressions/fe_if.rb +262 -0
- data/lib/openwfe/expressions/fe_iterator.rb +3 -4
- data/lib/openwfe/expressions/fe_losfor.rb +0 -1
- data/lib/openwfe/expressions/fe_misc.rb +4 -5
- data/lib/openwfe/expressions/fe_participant.rb +2 -3
- data/lib/openwfe/expressions/fe_raw.rb +71 -31
- data/lib/openwfe/expressions/fe_reserve.rb +141 -0
- data/lib/openwfe/expressions/fe_sequence.rb +0 -1
- data/lib/openwfe/expressions/fe_sleep.rb +3 -58
- data/lib/openwfe/expressions/fe_subprocess.rb +6 -5
- data/lib/openwfe/expressions/fe_value.rb +20 -121
- data/lib/openwfe/expressions/fe_wait.rb +79 -0
- data/lib/openwfe/expressions/fe_when.rb +31 -96
- data/lib/openwfe/expressions/flowexpression.rb +112 -19
- data/lib/openwfe/expressions/raw_prog.rb +8 -116
- data/lib/openwfe/expressions/simplerep.rb +197 -0
- data/lib/openwfe/expressions/time.rb +266 -0
- data/lib/openwfe/expressions/timeout.rb +2 -2
- data/lib/openwfe/flowexpressionid.rb +22 -0
- data/lib/openwfe/listeners/socketlisteners.rb +15 -1
- data/lib/openwfe/participants/participantmap.rb +12 -1
- data/lib/openwfe/participants/participants.rb +7 -1
- data/lib/openwfe/rudefinitions.rb +1 -6
- data/lib/openwfe/service.rb +8 -0
- data/lib/openwfe/util/irb.rb +86 -0
- data/lib/openwfe/util/ometa.rb +3 -3
- data/lib/openwfe/util/safe.rb +26 -34
- data/lib/openwfe/util/scheduler.rb +133 -76
- data/lib/openwfe/utils.rb +1 -1
- data/lib/openwfe/version.rb +2 -2
- data/lib/openwfe/workitem.rb +38 -0
- data/lib/openwfe/worklist/storeparticipant.rb +27 -2
- data/test/console_test.rb +15 -0
- data/test/flowtestbase.rb +20 -28
- data/test/ft_12_blockparticipant.rb +24 -0
- data/test/ft_14b_subprocess.rb +18 -0
- data/test/ft_22_history.rb +22 -1
- data/test/ft_23_when.rb +29 -2
- data/test/ft_23b_when.rb +17 -0
- data/test/ft_23c_wait.rb +87 -0
- data/test/ft_2_concurrence.rb +15 -14
- data/test/ft_2b_concurrence.rb +4 -4
- data/test/ft_32_journal.rb +29 -6
- data/test/ft_32b_journal.rb +76 -0
- data/test/ft_36_subprocids.rb +96 -0
- data/test/ft_37_pnames.rb +55 -0
- data/test/ft_38_tag.rb +128 -0
- data/test/ft_39_reserve.rb +119 -0
- data/test/ft_3_equals.rb +20 -1
- data/test/ft_40_defined.rb +72 -0
- data/test/ft_41_case.rb +124 -0
- data/test/ft_4_misc.rb +17 -0
- data/test/ft_5_time.rb +15 -20
- data/test/ft_7_lose.rb +2 -3
- data/test/ft_8_forget.rb +1 -1
- data/test/ft_tests.rb +9 -0
- data/test/hparticipant_test.rb +47 -1
- data/test/nut_0_irb.rb +20 -0
- data/test/raw_prog_test.rb +6 -0
- data/test/safely_test.rb +31 -41
- data/test/wfid_test.rb +43 -0
- metadata +21 -4
- data/lib/openwfe/expressions/fe_utils.rb +0 -151
@@ -0,0 +1,119 @@
|
|
1
|
+
|
2
|
+
#
|
3
|
+
# Testing OpenWFEru
|
4
|
+
#
|
5
|
+
# John Mettraux at openwfe.org
|
6
|
+
#
|
7
|
+
|
8
|
+
require 'flowtestbase'
|
9
|
+
require 'openwfe/def'
|
10
|
+
|
11
|
+
include OpenWFE
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
class FlowTest39 < Test::Unit::TestCase
|
16
|
+
include FlowTestBase
|
17
|
+
|
18
|
+
#def setup
|
19
|
+
#end
|
20
|
+
|
21
|
+
#def teardown
|
22
|
+
#end
|
23
|
+
|
24
|
+
|
25
|
+
#
|
26
|
+
# Test 0
|
27
|
+
#
|
28
|
+
|
29
|
+
class TestReserve39a0 < ProcessDefinition
|
30
|
+
reserve :mutex => :toto do
|
31
|
+
_print "ok"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_0
|
36
|
+
dotest(TestReserve39a0, "ok", true)
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
#
|
41
|
+
# Test 1
|
42
|
+
#
|
43
|
+
|
44
|
+
class TestReserve39a1 < ProcessDefinition
|
45
|
+
sequence do
|
46
|
+
reserve :mutex => :toto do
|
47
|
+
_print "${r:'${toto}' != ''}"
|
48
|
+
end
|
49
|
+
_print "${r:'${toto}' == ''}"
|
50
|
+
_print "over."
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_1
|
55
|
+
dotest(TestReserve39a1, "true\ntrue\nover.", true)
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
#
|
60
|
+
# Test 2
|
61
|
+
#
|
62
|
+
|
63
|
+
class TestReserve39a2 < ProcessDefinition
|
64
|
+
#
|
65
|
+
# doesn't prove it enough though...
|
66
|
+
#
|
67
|
+
concurrence do
|
68
|
+
reserve :mutex => :toto do
|
69
|
+
sequence do
|
70
|
+
test_alpha
|
71
|
+
test_bravo
|
72
|
+
end
|
73
|
+
end
|
74
|
+
reserve :mutex => :toto do
|
75
|
+
sequence do
|
76
|
+
test_charly
|
77
|
+
test_delta
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_2
|
84
|
+
|
85
|
+
dotest(
|
86
|
+
TestReserve39a2,
|
87
|
+
[
|
88
|
+
"""
|
89
|
+
test-charly
|
90
|
+
test-delta
|
91
|
+
test-alpha
|
92
|
+
test-bravo
|
93
|
+
""".strip,
|
94
|
+
"""
|
95
|
+
test-alpha
|
96
|
+
test-bravo
|
97
|
+
test-charly
|
98
|
+
test-delta
|
99
|
+
""".strip,
|
100
|
+
],
|
101
|
+
true)
|
102
|
+
end
|
103
|
+
|
104
|
+
|
105
|
+
#
|
106
|
+
# Test 3
|
107
|
+
#
|
108
|
+
|
109
|
+
class TestReserve39a3 < ProcessDefinition
|
110
|
+
reserve :mutex => :toto do
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
def test_3
|
115
|
+
dotest(TestReserve39a3, "", true)
|
116
|
+
end
|
117
|
+
|
118
|
+
end
|
119
|
+
|
data/test/ft_3_equals.rb
CHANGED
@@ -99,7 +99,7 @@ true""")
|
|
99
99
|
end
|
100
100
|
|
101
101
|
def test_equals_1
|
102
|
-
dotest(
|
102
|
+
dotest(
|
103
103
|
'<process-definition name="'+name_of_test+'''" revision="0">
|
104
104
|
<sequence>
|
105
105
|
<set variable="a" value="true" />
|
@@ -115,5 +115,24 @@ true""")
|
|
115
115
|
true""")
|
116
116
|
end
|
117
117
|
|
118
|
+
def test_equals_2
|
119
|
+
dotest(
|
120
|
+
'<process-definition name="'+name_of_test+'''" revision="0">
|
121
|
+
<sequence>
|
122
|
+
<set variable="a" value="true" />
|
123
|
+
|
124
|
+
<equals variable="a" other-value="true" />
|
125
|
+
<print>${f:__result__}</print>
|
126
|
+
|
127
|
+
<equals variable="a" value="true" />
|
128
|
+
<print>${f:__result__}</print>
|
129
|
+
</sequence>
|
130
|
+
</process-definition>''',
|
131
|
+
"""
|
132
|
+
true
|
133
|
+
true
|
134
|
+
""".strip)
|
135
|
+
end
|
136
|
+
|
118
137
|
end
|
119
138
|
|
@@ -0,0 +1,72 @@
|
|
1
|
+
|
2
|
+
#
|
3
|
+
# Testing OpenWFEru
|
4
|
+
#
|
5
|
+
# John Mettraux at openwfe.org
|
6
|
+
#
|
7
|
+
|
8
|
+
require 'flowtestbase'
|
9
|
+
require 'openwfe/def'
|
10
|
+
|
11
|
+
include OpenWFE
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
class FlowTest40 < Test::Unit::TestCase
|
16
|
+
include FlowTestBase
|
17
|
+
|
18
|
+
#def setup
|
19
|
+
#end
|
20
|
+
|
21
|
+
#def teardown
|
22
|
+
#end
|
23
|
+
|
24
|
+
|
25
|
+
#
|
26
|
+
# Test 0
|
27
|
+
#
|
28
|
+
|
29
|
+
class TestDefined40a0 < ProcessDefinition
|
30
|
+
sequence do
|
31
|
+
|
32
|
+
defined :field => "nada"
|
33
|
+
_print "${f:__result__}"
|
34
|
+
|
35
|
+
set :field => "nada", :value => "stuff"
|
36
|
+
|
37
|
+
defined :field => "nada"
|
38
|
+
_print "${f:__result__}"
|
39
|
+
defined :field_value => "nada"
|
40
|
+
_print "${f:__result__}"
|
41
|
+
|
42
|
+
defined :field_match => "^na.*"
|
43
|
+
_print "${f:__result__}"
|
44
|
+
defined :field_match => "^Na.*"
|
45
|
+
_print "${f:__result__}"
|
46
|
+
defined :field_match => "da$"
|
47
|
+
_print "${f:__result__}"
|
48
|
+
|
49
|
+
undefined :field_value => "nada"
|
50
|
+
_print "${f:__result__}"
|
51
|
+
undefined :field_value => "other"
|
52
|
+
_print "${f:__result__}"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_0
|
57
|
+
dotest(
|
58
|
+
TestDefined40a0,
|
59
|
+
"""
|
60
|
+
false
|
61
|
+
true
|
62
|
+
true
|
63
|
+
true
|
64
|
+
false
|
65
|
+
true
|
66
|
+
false
|
67
|
+
true
|
68
|
+
""".strip)
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
data/test/ft_41_case.rb
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
|
2
|
+
#
|
3
|
+
# Testing OpenWFEru
|
4
|
+
#
|
5
|
+
# John Mettraux at openwfe.org
|
6
|
+
#
|
7
|
+
|
8
|
+
require 'flowtestbase'
|
9
|
+
require 'openwfe/def'
|
10
|
+
|
11
|
+
include OpenWFE
|
12
|
+
|
13
|
+
|
14
|
+
class FlowTest41 < Test::Unit::TestCase
|
15
|
+
include FlowTestBase
|
16
|
+
|
17
|
+
#def setup
|
18
|
+
#end
|
19
|
+
|
20
|
+
#def teardown
|
21
|
+
#end
|
22
|
+
|
23
|
+
|
24
|
+
#
|
25
|
+
# Test 0
|
26
|
+
#
|
27
|
+
|
28
|
+
class TestCase41a0 < ProcessDefinition
|
29
|
+
sequence do
|
30
|
+
_case do
|
31
|
+
reval "2 % 2 == 0"
|
32
|
+
_print "ok 0"
|
33
|
+
end
|
34
|
+
_case do
|
35
|
+
reval "2 % 2 == 1"
|
36
|
+
_print "bad 1"
|
37
|
+
_print "ok 1"
|
38
|
+
end
|
39
|
+
_case do
|
40
|
+
reval "2 % 2 == 1"
|
41
|
+
_print "bad 2"
|
42
|
+
reval "2 % 2 == 0"
|
43
|
+
_print "ok 2"
|
44
|
+
_print "bad 2"
|
45
|
+
end
|
46
|
+
_case do
|
47
|
+
reval "2 % 2 == 1"
|
48
|
+
_print "bad 2b"
|
49
|
+
reval "2 % 2 == 0"
|
50
|
+
_print "ok 2b"
|
51
|
+
end
|
52
|
+
_case do
|
53
|
+
reval "2 % 2 == 1"
|
54
|
+
_print "bad 3"
|
55
|
+
reval "2 % 2 == 3"
|
56
|
+
_print "bad 3"
|
57
|
+
_print "ok 3"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_0
|
63
|
+
dotest(
|
64
|
+
TestCase41a0,
|
65
|
+
"""
|
66
|
+
ok 0
|
67
|
+
ok 1
|
68
|
+
ok 2
|
69
|
+
ok 2b
|
70
|
+
ok 3
|
71
|
+
""".strip)
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
#
|
76
|
+
# Test 1
|
77
|
+
#
|
78
|
+
|
79
|
+
class TestCase41a1 < ProcessDefinition
|
80
|
+
sequence do
|
81
|
+
|
82
|
+
_if :test => "1 == 1"
|
83
|
+
_print "${f:__result__}"
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_1
|
88
|
+
dotest(
|
89
|
+
TestCase41a1,
|
90
|
+
"""
|
91
|
+
true
|
92
|
+
""".strip)
|
93
|
+
end
|
94
|
+
|
95
|
+
|
96
|
+
#
|
97
|
+
# Test 2
|
98
|
+
#
|
99
|
+
|
100
|
+
class TestCase41a2 < ProcessDefinition
|
101
|
+
sequence do
|
102
|
+
_case do
|
103
|
+
_if :test => "1 == 1"
|
104
|
+
_print "ok"
|
105
|
+
end
|
106
|
+
_case do
|
107
|
+
_if :test => "false"
|
108
|
+
_print "bad 1"
|
109
|
+
_print "ok 1"
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
def test_2
|
115
|
+
dotest(
|
116
|
+
TestCase41a2,
|
117
|
+
"""
|
118
|
+
ok
|
119
|
+
ok 1
|
120
|
+
""".strip)
|
121
|
+
end
|
122
|
+
|
123
|
+
end
|
124
|
+
|
data/test/ft_4_misc.rb
CHANGED
@@ -77,6 +77,23 @@ class FlowTest4 < Test::Unit::TestCase
|
|
77
77
|
</sequence>
|
78
78
|
</process-definition>''', "false")
|
79
79
|
end
|
80
|
+
|
81
|
+
class Reval4 < OpenWFE::ProcessDefinition
|
82
|
+
reval """
|
83
|
+
tracer = self.application_context['__tracer']
|
84
|
+
|
85
|
+
tracer << 'hello\n'
|
86
|
+
|
87
|
+
tracer << workitem.attributes.length.to_s
|
88
|
+
"""
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_reval_4
|
92
|
+
dotest(Reval4, "hello\n1")
|
93
|
+
end
|
94
|
+
|
95
|
+
#
|
96
|
+
# DRU tests
|
80
97
|
|
81
98
|
def test_dru_0
|
82
99
|
dotest(\
|
data/test/ft_5_time.rb
CHANGED
@@ -21,18 +21,20 @@ class FlowTest5 < Test::Unit::TestCase
|
|
21
21
|
|
22
22
|
def test_sleep_0
|
23
23
|
#def xxxx_sleep_0
|
24
|
-
dotest(
|
24
|
+
dotest(
|
25
25
|
'''<process-definition name="sleep_0" revision="0">
|
26
26
|
<sequence>
|
27
27
|
<sleep for="2s" />
|
28
28
|
<print>alpha</print>
|
29
29
|
</sequence>
|
30
|
-
</process-definition>''',
|
30
|
+
</process-definition>''',
|
31
|
+
"alpha",
|
32
|
+
true)
|
31
33
|
end
|
32
34
|
|
33
35
|
def test_sleep_1
|
34
36
|
#def xxxx_sleep_1
|
35
|
-
dotest(
|
37
|
+
dotest(
|
36
38
|
'''<process-definition name="sleep_1" revision="0">
|
37
39
|
<concurrence>
|
38
40
|
<sequence>
|
@@ -41,41 +43,34 @@ class FlowTest5 < Test::Unit::TestCase
|
|
41
43
|
</sequence>
|
42
44
|
<print>bravo</print>
|
43
45
|
</concurrence>
|
44
|
-
</process-definition>''',
|
45
|
-
|
46
|
+
</process-definition>''',
|
47
|
+
"""bravo
|
48
|
+
alpha""",
|
49
|
+
true)
|
46
50
|
end
|
47
51
|
|
48
52
|
def test_sleep_2
|
49
53
|
#def xxxx_sleep_2
|
50
|
-
dotest(
|
54
|
+
dotest(
|
51
55
|
'''<process-definition name="sleep_2" revision="0">
|
52
56
|
<sequence>
|
53
57
|
<sleep until="${ruby:Time.new() + 4}" />
|
54
58
|
<print>alpha</print>
|
55
59
|
</sequence>
|
56
|
-
</process-definition>''',
|
60
|
+
</process-definition>''',
|
61
|
+
"alpha",
|
62
|
+
true)
|
57
63
|
end
|
58
64
|
|
59
65
|
def test_sleep_3
|
60
66
|
#def xxxx_sleep_3
|
61
|
-
dotest(
|
67
|
+
dotest(
|
62
68
|
'''<process-definition name="sleep_3" revision="0">
|
63
69
|
<sequence>
|
64
70
|
<sleep for="900" />
|
65
71
|
<print>alpha</print>
|
66
72
|
</sequence>
|
67
|
-
</process-definition>''', "alpha",
|
68
|
-
end
|
69
|
-
|
70
|
-
def test_sleep_4
|
71
|
-
#def xxxx_sleep_4
|
72
|
-
dotest(\
|
73
|
-
'''<process-definition name="sleep_4" revision="0">
|
74
|
-
<sequence>
|
75
|
-
<sleep for="1100" />
|
76
|
-
<print>alpha</print>
|
77
|
-
</sequence>
|
78
|
-
</process-definition>''', "", 1, true)
|
73
|
+
</process-definition>''', "alpha", true)
|
79
74
|
end
|
80
75
|
|
81
76
|
end
|
data/test/ft_7_lose.rb
CHANGED
@@ -48,7 +48,7 @@ class FlowTest7 < Test::Unit::TestCase
|
|
48
48
|
</sequence>
|
49
49
|
</lose>
|
50
50
|
<sequence>
|
51
|
-
<sleep for="
|
51
|
+
<sleep for="400" />
|
52
52
|
<print>ok 2</print>
|
53
53
|
</sequence>
|
54
54
|
</concurrence>
|
@@ -64,7 +64,6 @@ class FlowTest7 < Test::Unit::TestCase
|
|
64
64
|
<concurrence count="1">
|
65
65
|
<lose>
|
66
66
|
<sequence>
|
67
|
-
<!--<sleep for="252" />-->
|
68
67
|
<sleep for="400" />
|
69
68
|
<!-- more than the 250 ms precision -->
|
70
69
|
<print>ok 4</print>
|
@@ -96,7 +95,7 @@ ok 3
|
|
96
95
|
ok 5
|
97
96
|
v1 :
|
98
97
|
done.""",
|
99
|
-
1.
|
98
|
+
1.7,
|
100
99
|
true)
|
101
100
|
end
|
102
101
|
|
data/test/ft_8_forget.rb
CHANGED
data/test/ft_tests.rb
CHANGED
@@ -38,6 +38,7 @@ require 'ft_19_csv'
|
|
38
38
|
require 'ft_22_history'
|
39
39
|
require 'ft_23_when'
|
40
40
|
require 'ft_23b_when'
|
41
|
+
require 'ft_23c_wait'
|
41
42
|
require 'ft_24_def'
|
42
43
|
require 'ft_25_cancel'
|
43
44
|
require 'ft_27_getflowpos'
|
@@ -46,4 +47,12 @@ require 'ft_30_socketlistener'
|
|
46
47
|
require 'ft_31_flowname'
|
47
48
|
require 'ft_34_cancelwfid'
|
48
49
|
require 'ft_35_localdefs'
|
50
|
+
require 'ft_36_subprocids'
|
51
|
+
require 'ft_37_pnames'
|
52
|
+
require 'ft_38_tag'
|
53
|
+
require 'ft_39_reserve'
|
54
|
+
require 'ft_40_defined'
|
55
|
+
require 'ft_41_case'
|
56
|
+
|
57
|
+
require 'ft_32_journal'
|
49
58
|
|
data/test/hparticipant_test.rb
CHANGED
@@ -52,7 +52,8 @@ class HParticipantTest < Test::Unit::TestCase
|
|
52
52
|
|
53
53
|
def test_hp_1
|
54
54
|
|
55
|
-
FileUtils.remove_dir "./work" if File.exist? "./work"
|
55
|
+
#FileUtils.remove_dir "./work" if File.exist? "./work"
|
56
|
+
FileUtils.rm_rf "work" if File.exist? "./work"
|
56
57
|
|
57
58
|
@engine.application_context[:work_directory] = "./work"
|
58
59
|
@hpAlice = YamlParticipant.new("alice", @engine.application_context)
|
@@ -115,5 +116,50 @@ class HParticipantTest < Test::Unit::TestCase
|
|
115
116
|
@engine.get_expression_storage.size == 1
|
116
117
|
end
|
117
118
|
|
119
|
+
def test_d_0
|
120
|
+
|
121
|
+
@hpAlice = HashParticipant.new
|
122
|
+
@hpBob = HashParticipant.new
|
123
|
+
|
124
|
+
@engine.register_participant(:alice, @hpAlice)
|
125
|
+
@engine.register_participant(:bob, @hpBob)
|
126
|
+
|
127
|
+
id = @engine.launch(HpDefinition0)
|
128
|
+
|
129
|
+
assert_equal @hpAlice.size, 1
|
130
|
+
assert_equal @hpBob.size, 0
|
131
|
+
|
132
|
+
wi = @hpAlice.first_workitem
|
133
|
+
|
134
|
+
@hpAlice.delegate wi, @hpBob
|
135
|
+
|
136
|
+
assert_equal @hpAlice.size, 0
|
137
|
+
assert_equal @hpBob.size, 1
|
138
|
+
|
139
|
+
wi = @hpBob.first_workitem
|
140
|
+
|
141
|
+
@hpBob.proceed wi
|
142
|
+
|
143
|
+
assert_equal @hpAlice.size, 0
|
144
|
+
assert_equal @hpBob.size, 1
|
145
|
+
|
146
|
+
wi = @hpBob.first_workitem
|
147
|
+
|
148
|
+
@hpBob.delegate wi.fei, @hpAlice
|
149
|
+
|
150
|
+
assert_equal @hpAlice.size, 1
|
151
|
+
assert_equal @hpBob.size, 0
|
152
|
+
|
153
|
+
wi = @hpAlice.first_workitem
|
154
|
+
|
155
|
+
@hpAlice.forward wi
|
156
|
+
|
157
|
+
assert_equal @hpAlice.size, 0
|
158
|
+
assert_equal @hpBob.size, 0
|
159
|
+
|
160
|
+
assert \
|
161
|
+
@engine.get_expression_storage.size == 1
|
162
|
+
end
|
163
|
+
|
118
164
|
end
|
119
165
|
|
data/test/nut_0_irb.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
|
2
|
+
#
|
3
|
+
# NUT = not a unit test
|
4
|
+
# some kind of a manual test
|
5
|
+
#
|
6
|
+
# John Mettraux at openwfe.org
|
7
|
+
#
|
8
|
+
# Mon Oct 9 22:19:44 JST 2006
|
9
|
+
#
|
10
|
+
|
11
|
+
require 'openwfe/util/irb'
|
12
|
+
require 'openwfe/engine/engine'
|
13
|
+
|
14
|
+
|
15
|
+
engine = OpenWFE::Engine.new
|
16
|
+
|
17
|
+
OpenWFE::trap_int_irb(binding())
|
18
|
+
|
19
|
+
sleep(20)
|
20
|
+
|
data/test/raw_prog_test.rb
CHANGED
@@ -184,6 +184,12 @@ end""".strip
|
|
184
184
|
assert \
|
185
185
|
TestDefinition3.do_make.to_code_s == CODE_DEF3,
|
186
186
|
"to_code_s() not working properly (3)"
|
187
|
+
|
188
|
+
r = OpenWFE::SimpleExpRepresentation.from_xml(s)
|
189
|
+
#puts r.class.name
|
190
|
+
#puts r.to_code_s
|
191
|
+
|
192
|
+
assert_equal r.to_code_s, CODE_DEF3
|
187
193
|
end
|
188
194
|
|
189
195
|
|
data/test/safely_test.rb
CHANGED
@@ -5,7 +5,8 @@
|
|
5
5
|
# John Mettraux at openwfe.org
|
6
6
|
#
|
7
7
|
|
8
|
-
require '
|
8
|
+
require 'tempfile'
|
9
|
+
|
9
10
|
require 'test/unit'
|
10
11
|
#require 'openwfe/utils'
|
11
12
|
require 'openwfe/util/safe'
|
@@ -19,56 +20,45 @@ class SafelyTest < Test::Unit::TestCase
|
|
19
20
|
#def teardown
|
20
21
|
#end
|
21
22
|
|
22
|
-
def test_safely_0
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
assert_nil dotest2("print ''", 2)
|
29
|
-
end
|
23
|
+
#def test_safely_0
|
24
|
+
# assert_not_nil dotest("print ''", 4)
|
25
|
+
# assert_not_nil dotest2("print ''", 4)
|
26
|
+
# assert_nil dotest("print ''", 2)
|
27
|
+
# assert_nil dotest2("print ''", 2)
|
28
|
+
#end
|
30
29
|
|
31
30
|
def test_safely_1
|
31
|
+
|
32
32
|
assert_not_nil dotest3(STDOUT, "self.print ''", 4)
|
33
33
|
assert_nil dotest3(STDOUT, "self.print ''", 2)
|
34
|
+
|
34
35
|
assert_not_nil dotest3(nil, "print ''", 4)
|
35
36
|
assert_nil dotest3(nil, "print ''", 2)
|
36
37
|
end
|
37
38
|
|
38
39
|
protected
|
39
40
|
|
40
|
-
def dotest (code, level)
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
end
|
61
|
-
|
62
|
-
def dotest2 (code, level)
|
63
|
-
|
64
|
-
begin
|
65
|
-
OpenWFE::load_eval_safely(code, level)
|
66
|
-
rescue Exception => e
|
67
|
-
return e
|
68
|
-
end
|
69
|
-
|
70
|
-
nil
|
71
|
-
end
|
41
|
+
#def dotest (code, level)
|
42
|
+
# tf = Tempfile.new "safely_test_temp.rb"
|
43
|
+
# tf.puts code
|
44
|
+
# tf.close
|
45
|
+
# e = nil
|
46
|
+
# begin
|
47
|
+
# OpenWFE::load_safely(tf.path, level)
|
48
|
+
# rescue Exception => e
|
49
|
+
# end
|
50
|
+
# File.delete(tf.path)
|
51
|
+
# e
|
52
|
+
#end
|
53
|
+
|
54
|
+
#def dotest2 (code, level)
|
55
|
+
# begin
|
56
|
+
# OpenWFE::load_eval_safely(code, level)
|
57
|
+
# rescue Exception => e
|
58
|
+
# return e
|
59
|
+
# end
|
60
|
+
# nil
|
61
|
+
#end
|
72
62
|
|
73
63
|
def dotest3 (instance, code, level)
|
74
64
|
|