-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathshell.yaml
142 lines (141 loc) · 3.64 KB
/
shell.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
doc: |
Test interaction with a shell using the new regular expression
matching (instead of pattern matching).
Note the use of 'serialization: string' to avoid the default JSON
(de)serialization of messages.
spec:
phases:
phase1:
steps:
- pub:
chan: mother
payload:
make:
name: shell
type: cmd
config:
command: bash
- recv:
chan: mother
pattern:
success: true
- pub:
doc: |
Set a shell variable.
serialization: string
payload: |
QUESO=queso
- pub:
doc: |
Use that shell variable.
serialization: string
payload: |
echo "Hello, $QUESO."
- recv:
doc: |
Verify that the shell variable expansion worked. For
fun, use a guard to check the binding from the match.
serialization: string
regexp: |
Hello, (?P<x>(.*))\.
guard: |
return bs['?*x'] == "queso";
- pub:
doc: |
Update our shell variable.
serialization: string
payload: |
QUESO="good $QUESO"
- pub:
doc: |
Use that shell variable again.
serialization: string
payload: |
echo "I like $QUESO."
- recv:
doc: |
Verify that the shell variable expansion worked.
serialization: string
regexp: |
I like good queso\.
- pub:
doc: |
Exit the shell with an exit code 1
serialization:
payload: |
ls ?
exit $?
- recv:
doc: |
Handle the shell exit code 1
topic: exit
regexp: "2"
- goto: phase2
phase2:
steps:
- pub:
chan: mother
payload:
make:
name: shell2
type: cmd
config:
command: bash
- recv:
chan: mother
pattern:
success: true
- pub:
chan: shell2
doc: |
Exit the shell with an exit code 0
serialization:
payload: |
echo Hello
exit 0
- recv:
chan: shell2
doc: |
Handle the shell exit code 0
topic: exit
regexp: "0"
- goto: phase3
phase3:
steps:
- pub:
chan: mother
payload:
make:
name: shell3
type: cmd
config:
command: bash
- recv:
chan: mother
pattern:
success: true
- pub:
chan: shell3
doc: |
Exit the shell with an exit code 2
serialization:
payload: |
echo Hmmm
exit 2
- recv:
chan: shell3
doc: |
Expect the shell exit code 0 not 2 but only one attempt
topic: exit
attempts: 1
regexp: "0"
fails: true
- recv:
chan: shell3
doc: |
Expect the shell exit code 0 which was already consumed above, so it should timeout
topic: exit
attempts: 1
regexp: "0"
timeout: 1s
fails: true