pione 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -2
- data/History.txt +6 -0
- data/Rakefile +1 -1
- data/bin/pione-broker +1 -1
- data/bin/pione-clean +1 -1
- data/bin/pione-client +1 -1
- data/bin/pione-log +1 -1
- data/bin/pione-relay +1 -1
- data/bin/pione-relay-account-db +1 -1
- data/bin/pione-relay-client-db +1 -1
- data/bin/pione-syntax-checker +1 -1
- data/bin/pione-task-worker +1 -1
- data/bin/pione-tuple-space-provider +1 -1
- data/bin/pione-tuple-space-receiver +1 -1
- data/bin/pione-tuple-space-viewer +1 -1
- data/bin/pione-val +1 -1
- data/example/CTFCorrection/CTFCorrection.pione +78 -0
- data/example/CTFCorrection/package.yml +1 -0
- data/example/HelloWorld/scenario/output/message.txt +1 -0
- data/example/LoopByTouch/LoopByTouch.pione +10 -18
- data/example/LoopByTouch/PairLoop.pione +18 -0
- data/example/LoopByTouch/SingleLoop.pione +5 -0
- data/example/LoopByTouch/TripletLoop.pione +24 -0
- data/example/MakePair/scenario/output/comb-1-2.pair +0 -0
- data/example/MakePair/scenario/output/comb-1-3.pair +0 -0
- data/example/MakePair/scenario/output/comb-1-4.pair +0 -0
- data/example/MakePair/scenario/output/comb-1-5.pair +0 -0
- data/example/MakePair/scenario/output/comb-2-3.pair +0 -0
- data/example/MakePair/scenario/output/comb-2-4.pair +0 -0
- data/example/MakePair/scenario/output/comb-2-5.pair +0 -0
- data/example/MakePair/scenario/output/comb-3-4.pair +0 -0
- data/example/MakePair/scenario/output/comb-3-5.pair +0 -0
- data/example/MakePair/scenario/output/comb-4-5.pair +0 -0
- data/example/MakePair/scenario/output/perm-1-2.pair +0 -0
- data/example/MakePair/scenario/output/perm-1-3.pair +0 -0
- data/example/MakePair/scenario/output/perm-1-4.pair +0 -0
- data/example/MakePair/scenario/output/perm-1-5.pair +0 -0
- data/example/MakePair/scenario/output/perm-2-1.pair +0 -0
- data/example/MakePair/scenario/output/perm-2-3.pair +0 -0
- data/example/MakePair/scenario/output/perm-2-4.pair +0 -0
- data/example/MakePair/scenario/output/perm-2-5.pair +0 -0
- data/example/MakePair/scenario/output/perm-3-1.pair +0 -0
- data/example/MakePair/scenario/output/perm-3-2.pair +0 -0
- data/example/MakePair/scenario/output/perm-3-4.pair +0 -0
- data/example/MakePair/scenario/output/perm-3-5.pair +0 -0
- data/example/MakePair/scenario/output/perm-4-1.pair +0 -0
- data/example/MakePair/scenario/output/perm-4-2.pair +0 -0
- data/example/MakePair/scenario/output/perm-4-3.pair +0 -0
- data/example/MakePair/scenario/output/perm-4-5.pair +0 -0
- data/example/MakePair/scenario/output/perm-5-1.pair +0 -0
- data/example/MakePair/scenario/output/perm-5-2.pair +0 -0
- data/example/MakePair/scenario/output/perm-5-3.pair +0 -0
- data/example/MakePair/scenario/output/perm-5-4.pair +0 -0
- data/example/MakePair/scenario/output/succ-1-2.pair +0 -0
- data/example/MakePair/scenario/output/succ-2-3.pair +0 -0
- data/example/MakePair/scenario/output/succ-3-4.pair +0 -0
- data/example/MakePair/scenario/output/succ-4-5.pair +0 -0
- data/example/SyntaxError/output_line_error.pione +6 -0
- data/example/WorkflowPatterns/38_GeneralSynchronizingMerge/GeneralSynchronizingMerge.pione +94 -0
- data/lib/pione.rb +1 -10
- data/lib/pione/agent/process-manager.rb +6 -5
- data/lib/pione/agent/rule-provider.rb +7 -9
- data/lib/pione/agent/task-worker.rb +1 -1
- data/lib/pione/command.rb +1 -0
- data/lib/pione/command/basic-command.rb +12 -77
- data/lib/pione/command/child-process.rb +19 -13
- data/lib/pione/command/daemon-process.rb +0 -9
- data/lib/pione/command/front-owner-command.rb +0 -6
- data/lib/pione/command/option.rb +243 -0
- data/lib/pione/command/pione-broker.rb +10 -5
- data/lib/pione/command/pione-clean.rb +4 -0
- data/lib/pione/command/pione-client.rb +257 -210
- data/lib/pione/command/pione-log.rb +38 -19
- data/lib/pione/command/pione-relay-account-db.rb +42 -17
- data/lib/pione/command/pione-relay-client-db.rb +35 -14
- data/lib/pione/command/pione-relay.rb +16 -8
- data/lib/pione/command/pione-syntax-checker.rb +33 -13
- data/lib/pione/command/pione-task-worker.rb +26 -23
- data/lib/pione/command/pione-tuple-space-provider.rb +8 -17
- data/lib/pione/command/pione-tuple-space-receiver.rb +13 -3
- data/lib/pione/command/pione-tuple-space-viewer.rb +42 -23
- data/lib/pione/command/pione-val.rb +15 -7
- data/lib/pione/component/document.rb +49 -70
- data/lib/pione/component/package.rb +125 -83
- data/lib/pione/location/basic-location.rb +1 -0
- data/lib/pione/model/assignment.rb +11 -0
- data/lib/pione/model/parameters.rb +10 -0
- data/lib/pione/model/variable.rb +14 -0
- data/lib/pione/parser/common-parser.rb +4 -0
- data/lib/pione/parser/document-parser.rb +4 -3
- data/lib/pione/parser/rule-definition-parser.rb +2 -1
- data/lib/pione/patch/rinda-patch.rb +1 -1
- data/lib/pione/rule-handler/action-handler.rb +6 -1
- data/lib/pione/rule-handler/basic-handler.rb +0 -6
- data/lib/pione/rule-handler/flow-handler.rb +14 -9
- data/lib/pione/system/global.rb +3 -0
- data/lib/pione/system/package-cache.rb +18 -0
- data/lib/pione/transformer/document-transformer.rb +26 -3
- data/lib/pione/transformer/rule-definition-transformer.rb +10 -2
- data/lib/pione/tuple-space/presence-notifier.rb +4 -3
- data/lib/pione/uri-scheme.rb +11 -0
- data/lib/pione/uri-scheme/git-scheme.rb +12 -0
- data/lib/pione/util.rb +2 -0
- data/lib/pione/util/package-parameters-list.rb +32 -0
- data/lib/pione/util/process-info.rb +21 -0
- data/lib/pione/version.rb +1 -1
- data/pione.gemspec +1 -1
- data/test/agent/spec_rule-provider.rb +57 -44
- data/test/command/command-behavior.rb +15 -0
- data/test/command/spec_pione-client.rb +56 -0
- data/test/command/spec_pione-val.domain.dump +0 -0
- data/test/command/spec_pione-val.rb +22 -0
- data/test/component/spec_document.pione +51 -0
- data/test/component/spec_document.rb +41 -70
- data/test/component/spec_package.rb +18 -3
- data/test/parser/spec_document-parser.yml +15 -0
- data/test/parser/spec_rule-definition-parser.yml +7 -2
- data/test/rule-handler/spec_action-handler.rb +6 -6
- data/test/rule-handler/spec_flow-handler.pione +25 -0
- data/test/rule-handler/spec_flow-handler.rb +35 -95
- data/test/rule-handler/spec_update-criteria.rb +2 -2
- data/test/test-util.rb +68 -4
- data/test/transformer/spec_block-transformer.rb +1 -1
- data/test/transformer/spec_document-transformer.rb +50 -0
- data/test/transformer/spec_expr-transformer.rb +1 -1
- data/test/transformer/spec_flow-element-transformer.rb +13 -13
- data/test/transformer/spec_literal-transformer.rb +1 -1
- data/test/transformer/spec_rule-definition-transformer.rb +31 -19
- data/test/uri-scheme/spec_git-scheme.rb +20 -0
- data/test/util/spec_id.rb +6 -6
- data/test/util/spec_package-parameters-list.rb +59 -0
- data/test/util/spec_package-parameters-list_1.pione +17 -0
- data/test/util/spec_package-parameters-list_2.pione +13 -0
- data/test/util/spec_package-parameters-list_3.pione +12 -0
- data/test/util/spec_package-parameters-list_4.pione +6 -0
- data/test/util/spec_process-info.rb +56 -0
- metadata +79 -16
- data/lib/pione/option.rb +0 -13
- data/lib/pione/option/child-process-option.rb +0 -19
- data/lib/pione/option/common-option.rb +0 -31
- data/lib/pione/option/option-interface.rb +0 -73
- data/lib/pione/option/presence-notifier-option.rb +0 -16
- data/lib/pione/option/task-worker-owner-option.rb +0 -24
- data/lib/pione/option/tuple-space-provider-option.rb +0 -28
- data/lib/pione/option/tuple-space-provider-owner-option.rb +0 -18
- data/lib/pione/option/tuple-space-receiver-option.rb +0 -8
data/lib/pione/version.rb
CHANGED
data/pione.gemspec
CHANGED
@@ -30,7 +30,7 @@ Gem::Specification.new do |gem|
|
|
30
30
|
gem.add_dependency "uuidtools", "~> 2.1.4"
|
31
31
|
gem.add_dependency "highline", "~> 1.6.15"
|
32
32
|
gem.add_dependency "hamster", "~> 0.4.3"
|
33
|
-
gem.add_dependency "naming", "~> 0.0
|
33
|
+
gem.add_dependency "naming", "~> 0.1.0"
|
34
34
|
gem.add_dependency "forwardablex", "~> 0.1.4"
|
35
35
|
gem.add_dependency "temppath", "~> 0.1.1"
|
36
36
|
gem.add_dependency "ruby-xes", "~> 0.1.0"
|
@@ -1,65 +1,78 @@
|
|
1
1
|
require_relative '../test-util'
|
2
|
-
require 'pione/agent/rule-provider'
|
3
2
|
|
4
|
-
describe "Agent::RuleProvider" do
|
3
|
+
describe "Pione::Agent::RuleProvider" do
|
5
4
|
before do
|
6
|
-
|
7
|
-
@
|
8
|
-
doc = Component::Document.
|
9
|
-
Rule
|
5
|
+
@ts = create_tuple_space_server
|
6
|
+
@agent = Agent[:rule_provider].new(@ts)
|
7
|
+
doc = Component::Document.load(<<-DOCUMENT)
|
8
|
+
Rule A
|
10
9
|
input '*.a'
|
11
|
-
output '{$
|
12
|
-
Action
|
13
|
-
|
14
|
-
|
10
|
+
output '{$I[1]}.result'
|
11
|
+
Action
|
12
|
+
echo A > {$O[1]}
|
13
|
+
End
|
15
14
|
|
16
|
-
Rule
|
17
|
-
input '*.
|
18
|
-
output '{$
|
19
|
-
Action
|
20
|
-
|
21
|
-
|
15
|
+
Rule B
|
16
|
+
input '*.b'
|
17
|
+
output '{$I[1]}.result'
|
18
|
+
Action
|
19
|
+
echo B > {$[1]}
|
20
|
+
End
|
21
|
+
DOCUMENT
|
22
|
+
@rule_a = doc.find('A')
|
23
|
+
@rule_b = doc.find('B')
|
24
|
+
@agent.read_rules(doc)
|
25
|
+
end
|
26
|
+
|
27
|
+
after do
|
28
|
+
@agent.terminate
|
29
|
+
@ts.terminate
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should have rules" do
|
33
|
+
@agent.known_rules.should.include "&Main:A"
|
34
|
+
@agent.known_rules.should.include "&Main:B"
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should add a rule" do
|
38
|
+
doc = Component::Document.load(<<-DOCUMENT)
|
39
|
+
Rule C
|
40
|
+
input '*.c'
|
41
|
+
output '{$I[1]}.result'
|
42
|
+
Action
|
43
|
+
echo C > {$O[1]}
|
44
|
+
End
|
22
45
|
DOCUMENT
|
23
|
-
@
|
24
|
-
@
|
25
|
-
@provider.read_document(doc)
|
46
|
+
@agent.read_rules(doc)
|
47
|
+
@agent.known_rules.should.include "&Main:C"
|
26
48
|
end
|
27
49
|
|
28
|
-
it "should provide
|
50
|
+
it "should provide requested rule" do
|
51
|
+
@agent.start
|
52
|
+
|
29
53
|
# wait provider's setup
|
30
|
-
@
|
54
|
+
@agent.wait_till(:request_waiting)
|
55
|
+
|
31
56
|
# write a request
|
32
|
-
write_and_wait_to_be_taken(Tuple[:request_rule].new(rule_path: '&
|
57
|
+
write_and_wait_to_be_taken(Tuple[:request_rule].new(rule_path: '&Main:A'))
|
33
58
|
check_exceptions
|
59
|
+
|
34
60
|
# check rule tuple
|
35
61
|
should.not.raise(Rinda::RequestExpiredError) do
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
rule.content.should == @rule_abc
|
62
|
+
tuple = read!(Tuple[:rule].new(rule_path: '&Main:A'))
|
63
|
+
tuple.content.class.should == Component::ActionRule
|
64
|
+
tuple.content.should == @rule_a
|
40
65
|
end
|
66
|
+
|
41
67
|
# write another request
|
42
|
-
write_and_wait_to_be_taken(Tuple[:request_rule].new(rule_path: '&
|
68
|
+
write_and_wait_to_be_taken(Tuple[:request_rule].new(rule_path: '&Main:B'))
|
43
69
|
check_exceptions
|
44
|
-
# check rule tuple
|
45
|
-
should.not.raise(Rinda::RequestExpiredError) do
|
46
|
-
rule = read(Tuple[:rule].new(rule_path: '&main:xyz'))
|
47
|
-
rule.status.should == :known
|
48
|
-
rule.content.class.should == Rule::ActionRule
|
49
|
-
rule.content.should == @rule_xyz
|
50
|
-
end
|
51
|
-
end
|
52
70
|
|
53
|
-
|
54
|
-
# wait provider's setup
|
55
|
-
@provider.wait_till(:request_waiting)
|
56
|
-
# write a request
|
57
|
-
write_and_wait_to_be_taken(Tuple[:request_rule].new(rule_path: "aaa"))
|
58
|
-
check_exceptions
|
59
|
-
# check unknown rule tuple
|
71
|
+
# check rule tuple
|
60
72
|
should.not.raise(Rinda::RequestExpiredError) do
|
61
|
-
|
62
|
-
|
73
|
+
tuple = read!(Tuple[:rule].new(rule_path: '&Main:B'))
|
74
|
+
tuple.content.class.should == Component::ActionRule
|
75
|
+
tuple.content.should == @rule_b
|
63
76
|
end
|
64
77
|
end
|
65
78
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
shared "command" do
|
2
|
+
it "should show a help message" do
|
3
|
+
res = TestUtil::Command.succeed do
|
4
|
+
Command::PioneVal.run ["--help"]
|
5
|
+
end
|
6
|
+
res.stdout.string.should.start_with "Usage"
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should show a version message" do
|
10
|
+
res = TestUtil::Command.succeed do
|
11
|
+
Command::PioneVal.run ["--version"]
|
12
|
+
end
|
13
|
+
res.stdout.string.should.include Pione::VERSION
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require_relative '../test-util'
|
2
|
+
require_relative 'command-behavior'
|
3
|
+
|
4
|
+
describe "Pione::Command::PioneClient" do
|
5
|
+
behaves_like "command"
|
6
|
+
|
7
|
+
### is this wrong?
|
8
|
+
# it "should execute a PIONE document" do
|
9
|
+
# path = Temppath.create
|
10
|
+
# args = ["example/HelloWorld/HelloWorld.pione", "-o", path.to_s]
|
11
|
+
# res = TestUtil::Command.succeed do
|
12
|
+
# Pione::Command::PioneClient.run args
|
13
|
+
# end
|
14
|
+
# Location[path + "message.txt"].should.exist
|
15
|
+
# Location[path + "message.txt"].read.should.start_with "Hello, world!"
|
16
|
+
# end
|
17
|
+
|
18
|
+
it "should execute a PIONE document with stand alone mode" do
|
19
|
+
path = Temppath.create
|
20
|
+
args = ["example/HelloWorld/HelloWorld.pione", "-o", path.to_s, "--stand-alone"]
|
21
|
+
res = TestUtil::Command.succeed do
|
22
|
+
Pione::Command::PioneClient.run args
|
23
|
+
end
|
24
|
+
Location[path + "message.txt"].should.exist
|
25
|
+
Location[path + "message.txt"].read.should.start_with "Hello, world!"
|
26
|
+
end
|
27
|
+
|
28
|
+
# it "should execute a PIONE package" do
|
29
|
+
# path = Temppath.create
|
30
|
+
# args = ["example/HelloWorld/", "-o", path.to_s]
|
31
|
+
# res = TestUtil::Command.succeed do
|
32
|
+
# Pione::Command::PioneClient.run args
|
33
|
+
# end
|
34
|
+
# Location[path + "message.txt"].should.exist
|
35
|
+
# Location[path + "message.txt"].read.should.start_with "Hello, world!"
|
36
|
+
# end
|
37
|
+
|
38
|
+
it "should execute a PIONE package with stand alone mode" do
|
39
|
+
path = Temppath.create
|
40
|
+
args = ["example/HelloWorld/", "-o", path.to_s, "--stand-alone"]
|
41
|
+
res = TestUtil::Command.succeed do
|
42
|
+
Pione::Command::PioneClient.run args
|
43
|
+
end
|
44
|
+
Location[path + "message.txt"].should.exist
|
45
|
+
Location[path + "message.txt"].read.should.start_with "Hello, world!"
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should show parameters list of package" do
|
49
|
+
args = ["example/HelloWorld/HelloWorld.pione", "--list-params"]
|
50
|
+
res = TestUtil::Command.succeed do
|
51
|
+
Pione::Command::PioneClient.run args
|
52
|
+
end
|
53
|
+
res.stdout.string.size.should > 0
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
Binary file
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require_relative '../test-util'
|
2
|
+
require_relative 'command-behavior'
|
3
|
+
|
4
|
+
describe "Pione::Command::PioneVal" do
|
5
|
+
behaves_like "command"
|
6
|
+
|
7
|
+
it "should get value" do
|
8
|
+
res = TestUtil::Command.succeed do
|
9
|
+
Command::PioneVal.run ["1 + 1"]
|
10
|
+
end
|
11
|
+
res.stdout.string.chomp.should == "2"
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should get variable from domain info" do
|
15
|
+
domain_info = TestUtil::DIR + "command" + "spec_pione-val.domain.dump"
|
16
|
+
res = TestUtil::Command.succeed do
|
17
|
+
Command::PioneVal.run ["$O[1]", "--domain-info", domain_info.path.to_s]
|
18
|
+
end
|
19
|
+
res.stdout.string.chomp.should == "message.txt"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
@@ -0,0 +1,51 @@
|
|
1
|
+
Param
|
2
|
+
$P1 := "a"
|
3
|
+
$P2 := "b"
|
4
|
+
$P3 := "c"
|
5
|
+
End
|
6
|
+
|
7
|
+
param $P4 := "d"
|
8
|
+
param $P5 := "e"
|
9
|
+
|
10
|
+
$P6 := "f"
|
11
|
+
|
12
|
+
$X := 1
|
13
|
+
|
14
|
+
Rule Main
|
15
|
+
input '*.txt'
|
16
|
+
output '*.result'
|
17
|
+
Flow
|
18
|
+
rule RuleA
|
19
|
+
rule RuleB
|
20
|
+
rule RuleC
|
21
|
+
End
|
22
|
+
|
23
|
+
Rule RuleA
|
24
|
+
input '*.txt'
|
25
|
+
output '{$I[1,1]}.a'
|
26
|
+
Action
|
27
|
+
command_a {$I[1]} > {$O[1]}
|
28
|
+
End
|
29
|
+
|
30
|
+
Rule RuleB
|
31
|
+
input '*.a'
|
32
|
+
output '{$I[1,1]}.b'
|
33
|
+
Action
|
34
|
+
command_b {$I[1]} > {$O[1]}
|
35
|
+
End
|
36
|
+
|
37
|
+
Rule RuleC
|
38
|
+
input '*.b'
|
39
|
+
output '{$I[1,1]}.result'
|
40
|
+
Action
|
41
|
+
command_c {$I[1]} > {$O[1]}
|
42
|
+
End
|
43
|
+
|
44
|
+
Rule TestParams
|
45
|
+
input '*.input'
|
46
|
+
output '{$*}.output'
|
47
|
+
param $P1
|
48
|
+
Action
|
49
|
+
echo `echo {$I[1]}` {$P1} > {$O[1]}
|
50
|
+
End
|
51
|
+
|
@@ -1,93 +1,64 @@
|
|
1
1
|
require_relative '../test-util'
|
2
2
|
|
3
|
-
|
4
|
-
Param
|
5
|
-
$P1 := "a"
|
6
|
-
$P2 := "b"
|
7
|
-
$P3 := "c"
|
8
|
-
End
|
3
|
+
document_location = Location[File.dirname(__FILE__)] + "spec_document.pione"
|
9
4
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
Rule Main
|
16
|
-
input '*.txt'
|
17
|
-
output '*.result'
|
18
|
-
Flow
|
19
|
-
rule RuleA
|
20
|
-
rule RuleB
|
21
|
-
rule RuleC
|
22
|
-
End
|
23
|
-
|
24
|
-
Rule RuleA
|
25
|
-
input '*.txt'
|
26
|
-
output '{$I[1,1]}.a'
|
27
|
-
Action
|
28
|
-
command_a {$I[1]} > {$O[1]}
|
29
|
-
End
|
30
|
-
|
31
|
-
Rule RuleB
|
32
|
-
input '*.a'
|
33
|
-
output '{$I[1,1]}.b'
|
34
|
-
Action
|
35
|
-
command_b {$I[1]} > {$O[1]}
|
36
|
-
End
|
5
|
+
describe 'Pione::Component::Document' do
|
6
|
+
before do
|
7
|
+
@document = Component::Document.load(document_location)
|
8
|
+
end
|
37
9
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
10
|
+
it 'should load a document from a file' do
|
11
|
+
@document.rules.map{|rule| rule.name}.tap do |x|
|
12
|
+
x.should.include "Main"
|
13
|
+
x.should.include "RuleA"
|
14
|
+
x.should.include "RuleB"
|
15
|
+
x.should.include "RuleC"
|
16
|
+
end
|
17
|
+
end
|
45
18
|
|
46
|
-
|
47
|
-
|
48
|
-
doc = Component::Document.parse(src)
|
49
|
-
doc.rules.size.should == 4
|
19
|
+
it 'should load a document from a string' do
|
20
|
+
Component::Document.load(document_location.read).should == @document
|
50
21
|
end
|
51
22
|
|
52
|
-
it 'should
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
temp.close(false)
|
57
|
-
doc = Component::Document.load(path)
|
58
|
-
doc.rules.size.should == 4
|
23
|
+
it 'should load a document with package name' do
|
24
|
+
document = Component::Document.load(document_location, "Test")
|
25
|
+
document.package_name.should == "Test"
|
26
|
+
document.find("Main").package_name == "Test"
|
59
27
|
end
|
60
28
|
|
61
|
-
it 'should get
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
doc["&main:RuleC"].should.kind_of(Component::Rule)
|
29
|
+
it 'should get rule by name' do
|
30
|
+
@document.find("Main").should.kind_of(Component::FlowRule)
|
31
|
+
@document.find("RuleA").should.kind_of(Component::ActionRule)
|
32
|
+
@document.find("RuleB").should.kind_of(Component::ActionRule)
|
33
|
+
@document.find("RuleC").should.kind_of(Component::ActionRule)
|
67
34
|
end
|
68
35
|
|
69
36
|
it 'should have document parameters' do
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
user_params =
|
37
|
+
@document.params["P1"].should == PioneString.new("a").to_seq
|
38
|
+
@document.params["P2"].should == PioneString.new("b").to_seq
|
39
|
+
@document.params["P3"].should == PioneString.new("c").to_seq
|
40
|
+
@document.params["P4"].should == PioneString.new("d").to_seq
|
41
|
+
@document.params["P5"].should == PioneString.new("e").to_seq
|
42
|
+
@document.params["P6"].should == PioneString.new("f").to_seq
|
43
|
+
user_params = @document.params.data.select{|var, val| var.user_param}.map{|var, val| var.name}
|
77
44
|
user_params.sort.should == ["P1", "P2", "P3", "P4", "P5"]
|
78
45
|
end
|
79
46
|
|
80
47
|
it 'should have document variable bindings' do
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
48
|
+
@document.find("Main").condition.params["X"].should == 1.to_pione.to_seq
|
49
|
+
@document.find("RuleA").condition.params["X"].should == 1.to_pione.to_seq
|
50
|
+
@document.find("RuleB").condition.params["X"].should == 1.to_pione.to_seq
|
51
|
+
@document.find("RuleC").condition.params["X"].should == 1.to_pione.to_seq
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'should create root rule' do
|
55
|
+
root = @document.create_root_rule(@document.find("Main"), Model::Parameters.empty)
|
56
|
+
root.should.kind_of(Component::RootRule)
|
86
57
|
end
|
87
58
|
|
88
59
|
it 'should raise variable binding error' do
|
89
60
|
should.raise(VariableBindingError) do
|
90
|
-
Component::Document.
|
61
|
+
Component::Document.load <<-PIONE
|
91
62
|
$X := 1
|
92
63
|
$X := 2
|
93
64
|
PIONE
|
@@ -34,12 +34,14 @@ describe "Pione::Component::Package" do
|
|
34
34
|
end
|
35
35
|
|
36
36
|
it "should get rules" do
|
37
|
-
@package.rules.
|
38
|
-
|
37
|
+
@package.rules.map{|rule| rule.path}.tap do |x|
|
38
|
+
x.should.include("&TestPackage:Main")
|
39
|
+
x.should.include("&TestPackage:Count")
|
40
|
+
end
|
39
41
|
end
|
40
42
|
|
41
43
|
it "should get a main rule" do
|
42
|
-
@package.
|
44
|
+
@package.find_rule("Main").path.should == "&TestPackage:Main"
|
43
45
|
end
|
44
46
|
|
45
47
|
it "should upload package files" do
|
@@ -75,3 +77,16 @@ describe "Pione::Component::PackageScenario" do
|
|
75
77
|
@scenario.name.should == "TestCase1"
|
76
78
|
end
|
77
79
|
end
|
80
|
+
|
81
|
+
describe "Pione::Component::PackageReader" do
|
82
|
+
it "should read package directory" do
|
83
|
+
path = Location[File.expand_path("../spec_package", __FILE__)] + "TestPackage"
|
84
|
+
Component::PackageReader.new(path).type.should == :directory
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should read the package and return it" do
|
88
|
+
path = Location[File.expand_path("../spec_package", __FILE__)] + "TestPackage"
|
89
|
+
Component::PackageReader.read(path).should.kind_of Component::Package
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|