Blame


1 76991ad5 2021-12-02 op .\" Copyright (c) 2021 Omar Polo <op@omarpolo.com>
2 76991ad5 2021-12-02 op .\"
3 76991ad5 2021-12-02 op .\" Permission to use, copy, modify, and distribute this software for any
4 76991ad5 2021-12-02 op .\" purpose with or without fee is hereby granted, provided that the above
5 76991ad5 2021-12-02 op .\" copyright notice and this permission notice appear in all copies.
6 76991ad5 2021-12-02 op .\"
7 76991ad5 2021-12-02 op .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8 76991ad5 2021-12-02 op .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9 76991ad5 2021-12-02 op .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10 76991ad5 2021-12-02 op .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11 76991ad5 2021-12-02 op .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12 76991ad5 2021-12-02 op .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
13 76991ad5 2021-12-02 op .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14 76991ad5 2021-12-02 op .\"
15 76991ad5 2021-12-02 op .Dd $Mdocdate: December 02 2021$
16 76991ad5 2021-12-02 op .Dt NINEPSCRIPT 5
17 76991ad5 2021-12-02 op .Os
18 76991ad5 2021-12-02 op .Sh NAME
19 76991ad5 2021-12-02 op .Nm ninepscript
20 76991ad5 2021-12-02 op .Nd kamid regress test scripting language
21 76991ad5 2021-12-02 op .Sh DESCRIPTION
22 76991ad5 2021-12-02 op .Nm
23 76991ad5 2021-12-02 op is a custom DSL
24 76991ad5 2021-12-02 op .Pq domain specific language
25 76991ad5 2021-12-02 op used to write the regression suite of
26 76991ad5 2021-12-02 op .Xr kamid 8 .
27 76991ad5 2021-12-02 op it has a fairly simple and regular syntax that features constant
28 76991ad5 2021-12-02 op declarations, routines, test cases.
29 76991ad5 2021-12-02 op It does not support conditional or loops.
30 76991ad5 2021-12-02 op .Pp
31 76991ad5 2021-12-02 op Additional files can be included with the
32 76991ad5 2021-12-02 op .Ic include
33 76991ad5 2021-12-02 op keyword, for example
34 76991ad5 2021-12-02 op .Bd -literal -offset Ds
35 76991ad5 2021-12-02 op include "lib.9ps"
36 76991ad5 2021-12-02 op .Ed
37 76991ad5 2021-12-02 op .Pp
38 76991ad5 2021-12-02 op Comments can be placed anywhere, start with the # character and extend
39 76991ad5 2021-12-02 op until the end of the line.
40 76991ad5 2021-12-02 op .Pp
41 76991ad5 2021-12-02 op An expression is a fundamental building block.
42 76991ad5 2021-12-02 op It is something that yields a value.
43 76991ad5 2021-12-02 op An expression may be either a:
44 76991ad5 2021-12-02 op .Bl -tag -width variable_reference
45 76991ad5 2021-12-02 op .It literal
46 76991ad5 2021-12-02 op a bare number or string.
47 76991ad5 2021-12-02 op A string is a sequence of characters enclosed in single or double quotes
48 76991ad5 2021-12-02 op .Sq like this
49 76991ad5 2021-12-02 op or
50 76991ad5 2021-12-02 op .Dq like this .
51 76991ad5 2021-12-02 op .It routine call
52 76991ad5 2021-12-02 op Evaluate the routine code and return the value computed by it.
53 76991ad5 2021-12-02 op The syntax is
54 76991ad5 2021-12-02 op .Bd -literal -offset Ds
55 76991ad5 2021-12-02 op .Ar routine Ns Po Ar arguments... Pc
56 76991ad5 2021-12-02 op .Ed
57 76991ad5 2021-12-02 op .Pp
58 76991ad5 2021-12-02 op The
59 76991ad5 2021-12-02 op .Ql ...
60 76991ad5 2021-12-02 op special syntax expands to the list of variable arguments of the
61 76991ad5 2021-12-02 op current routine.
62 76991ad5 2021-12-02 op Be aware that the implementation of the variable arguments is quirky
63 76991ad5 2021-12-02 op and has a lot of corner cases, use with care!
64 76991ad5 2021-12-02 op .It variable reference
65 76991ad5 2021-12-02 op a variable
66 76991ad5 2021-12-02 op .Pq or constant
67 76991ad5 2021-12-02 op reference is the name of a previously defined variable or constant.
68 76991ad5 2021-12-02 op It evaluates to the value of the variable or constant in the current
69 76991ad5 2021-12-02 op scope.
70 76991ad5 2021-12-02 op .It comparison
71 76991ad5 2021-12-02 op The syntax is
72 423f02f5 2021-12-28 cage .Bd -literal -offset Ds
73 423f02f5 2021-12-28 cage .Ar expression Cm == Ar expression
74 423f02f5 2021-12-28 cage .Ar expression Cm <= Ar expression
75 423f02f5 2021-12-28 cage .Ed
76 423f02f5 2021-12-28 cage .Pp
77 76991ad5 2021-12-02 op and yields a true value if the two expressions are considered to be
78 423f02f5 2021-12-28 cage respectively
79 76991ad5 2021-12-02 op .Sq equal
80 423f02f5 2021-12-28 cage or
81 423f02f5 2021-12-28 cage .Sq lesser equal ,
82 423f02f5 2021-12-28 cage a false value otherwise.
83 76991ad5 2021-12-02 op Two values are equal if they are both number and represent the same
84 76991ad5 2021-12-02 op value
85 76991ad5 2021-12-02 op .Pq regardless of the size
86 76991ad5 2021-12-02 op or if they're both the same string.
87 76991ad5 2021-12-02 op .It cast
88 76991ad5 2021-12-02 op convert one value to another type.
89 76991ad5 2021-12-02 op The syntax is
90 76991ad5 2021-12-02 op .Ql Ar expression : Ns Ar type
91 76991ad5 2021-12-02 op where type is one of
92 76991ad5 2021-12-02 op .Sq u8 ,
93 76991ad5 2021-12-02 op .Sq u16 ,
94 76991ad5 2021-12-02 op .Sq u32
95 76991ad5 2021-12-02 op or
96 76991ad5 2021-12-02 op .Sq str .
97 76991ad5 2021-12-02 op .It field access
98 76991ad5 2021-12-02 op Access a field of a complex object.
99 76991ad5 2021-12-02 op The syntax is
100 76991ad5 2021-12-02 op .Ql Ar object . Ns Ar field .
101 76991ad5 2021-12-02 op See the
102 76991ad5 2021-12-02 op .Sx OBJECTS AND FIELDS
103 76991ad5 2021-12-02 op section for the description of objects types and fields allowed.
104 76991ad5 2021-12-02 op .El
105 76991ad5 2021-12-02 op .Pp
106 76991ad5 2021-12-02 op An expression is considered to be
107 76991ad5 2021-12-02 op .Dq false
108 76991ad5 2021-12-02 op if evaluates to a number and its value is zero.
109 76991ad5 2021-12-02 op Otherwise, it's considered to be
110 76991ad5 2021-12-02 op .Dq true .
111 76991ad5 2021-12-02 op .Pp
112 76991ad5 2021-12-02 op The top-level declarations are:
113 76991ad5 2021-12-02 op .Bl -tag -width Ds
114 76991ad5 2021-12-02 op .It Ic const Ar identifier No = Ar value
115 76991ad5 2021-12-02 op Declare
116 76991ad5 2021-12-02 op .Ar identifier
117 76991ad5 2021-12-02 op to be a constant that evaluates to
118 76991ad5 2021-12-02 op .Ar value .
119 76991ad5 2021-12-02 op .Ar value
120 76991ad5 2021-12-02 op must be a literal or a cast from a literal.
121 76991ad5 2021-12-02 op Multiple constant can be declared at the same time using the following
122 76991ad5 2021-12-02 op syntax:
123 76991ad5 2021-12-02 op .Bd -literal -offset Ds
124 76991ad5 2021-12-02 op .Ic const (
125 76991ad5 2021-12-02 op foo = 5
126 76991ad5 2021-12-02 op bar = 7
127 76991ad5 2021-12-02 op )
128 76991ad5 2021-12-02 op .Ed
129 76991ad5 2021-12-02 op .Pp
130 76991ad5 2021-12-02 op Note that newlines are mandatory after an
131 76991ad5 2021-12-02 op .Ar identifier No = Ar value
132 76991ad5 2021-12-02 op line in this case.
133 76991ad5 2021-12-02 op .It Ic proc Ar name Ns Po Ar arguments ... Pc Brq code ...
134 76991ad5 2021-12-02 op Define a routine called
135 76991ad5 2021-12-02 op .Ar name
136 76991ad5 2021-12-02 op that accepts the comma-separated list of
137 76991ad5 2021-12-02 op .Ar arguments .
138 76991ad5 2021-12-02 op When a routine is called, its
139 76991ad5 2021-12-02 op .Ar code
140 76991ad5 2021-12-02 op gets evaluated in a lexical scope where
141 76991ad5 2021-12-02 op .Ar arguments
142 76991ad5 2021-12-02 op are defined to the value passed by the caller.
143 76991ad5 2021-12-02 op A routine may be called only within another routine body or inside a
144 76991ad5 2021-12-02 op .Ic testing
145 76991ad5 2021-12-02 op body.
146 76991ad5 2021-12-02 op .It Ic testing Ar reason Ic dir Ar path Brq code ...
147 76991ad5 2021-12-02 op Define a test case.
148 76991ad5 2021-12-02 op .Ar reason
149 76991ad5 2021-12-02 op is what the test block is about and
150 76991ad5 2021-12-02 op .Ar path
151 76991ad5 2021-12-02 op is the path to the root directory where the test will be executed.
152 76991ad5 2021-12-02 op .Ar reason
153 76991ad5 2021-12-02 op and
154 76991ad5 2021-12-02 op .Ar path
155 76991ad5 2021-12-02 op must be string literals.
156 76991ad5 2021-12-02 op .El
157 76991ad5 2021-12-02 op .Pp
158 76991ad5 2021-12-02 op Inside a
159 76991ad5 2021-12-02 op .Ic proc
160 76991ad5 2021-12-02 op or
161 76991ad5 2021-12-02 op .Ic testing
162 76991ad5 2021-12-02 op code block the following instructions are allowed:
163 76991ad5 2021-12-02 op .Bl -tag -width Ds
164 76991ad5 2021-12-02 op .It Ar variable Cm = Ar expression
165 76991ad5 2021-12-02 op Set a local lexical
166 76991ad5 2021-12-02 op .Ar variable
167 76991ad5 2021-12-02 op to the value yielded by
168 76991ad5 2021-12-02 op .Ar expression .
169 76991ad5 2021-12-02 op The
170 76991ad5 2021-12-02 op .Ar variable
171 76991ad5 2021-12-02 op lifetime last from this declaration until the end of the current
172 76991ad5 2021-12-02 op block.
173 76991ad5 2021-12-02 op .It Ar procedure Ns Pq Ar arguments ...
174 76991ad5 2021-12-02 op Execute
175 76991ad5 2021-12-02 op .Ar procedure
176 76991ad5 2021-12-02 op with the given
177 76991ad5 2021-12-02 op .Ar arguments .
178 423f02f5 2021-12-28 cage .It Ic assert Ar comparison
179 76991ad5 2021-12-02 op Evaluate
180 423f02f5 2021-12-28 cage .Ar comparison
181 76991ad5 2021-12-02 op and if it not yields a true-ish value terminate the current running
182 76991ad5 2021-12-02 op test and mark it as failed.
183 76991ad5 2021-12-02 op Multiple assertion can be done in one single
184 76991ad5 2021-12-02 op .Ic assert
185 76991ad5 2021-12-02 op block using the following syntax:
186 76991ad5 2021-12-02 op .Bd -literal -offset Ds
187 76991ad5 2021-12-02 op .Ic assert (
188 423f02f5 2021-12-28 cage comparison_1
189 423f02f5 2021-12-28 cage comparison_2
190 76991ad5 2021-12-02 op ...
191 423f02f5 2021-12-28 cage comparison_n
192 76991ad5 2021-12-02 op )
193 76991ad5 2021-12-02 op .Ed
194 76991ad5 2021-12-02 op .Pp
195 76991ad5 2021-12-02 op Note that newlines are mandatory after every
196 423f02f5 2021-12-28 cage .Ar comparison
197 76991ad5 2021-12-02 op in this case.
198 76991ad5 2021-12-02 op .It Ic should-fail Ar expression Op : Ar reason
199 76991ad5 2021-12-02 op Evaluate
200 76991ad5 2021-12-02 op .Ar expression
201 76991ad5 2021-12-02 op and continue only if the evaluation produced an error.
202 76991ad5 2021-12-02 op If the execution of
203 76991ad5 2021-12-02 op .Ar expression
204 76991ad5 2021-12-02 op is successful, terminate the current test.
205 76991ad5 2021-12-02 op .Ar reason
206 76991ad5 2021-12-02 op is optional and, if present, must be a literal string.
207 76991ad5 2021-12-02 op It is similar to the
208 76991ad5 2021-12-02 op .Sq try-catch
209 76991ad5 2021-12-02 op statement of other programming languages.
210 76991ad5 2021-12-02 op .El
211 76991ad5 2021-12-02 op .Sh BUILT IN FUNCTIONS
212 76991ad5 2021-12-02 op These functions are built into the language and provided by the
213 76991ad5 2021-12-02 op interpreter:
214 76991ad5 2021-12-02 op .Bl -tag -width Ds
215 76991ad5 2021-12-02 op .It Ic debug Ns Po Ar arg, ... Pc
216 76991ad5 2021-12-02 op Print the argument list separated by a space and followed by a newline
217 76991ad5 2021-12-02 op if the interpreter runs with the verbose flag set.
218 76991ad5 2021-12-02 op .It Ic iota Ns Pq
219 76991ad5 2021-12-02 op Return distinct u16 integer every time it's called.
220 76991ad5 2021-12-02 op Starts at zero and goes up to 254 to then wrap around to zero again.
221 76991ad5 2021-12-02 op 255 is skipped because
222 76991ad5 2021-12-02 op .Ic iota
223 76991ad5 2021-12-02 op is intended to be used to provide the tag for
224 76991ad5 2021-12-02 op .Ic send
225 76991ad5 2021-12-02 op and 255 is the special
226 76991ad5 2021-12-02 op .Sq NOTAG
227 76991ad5 2021-12-02 op value in 9P200.
228 76991ad5 2021-12-02 op .It Ic print Ns Po Ar arg, ... Pc
229 76991ad5 2021-12-02 op Print the argument list separated by a space and followed by a
230 76991ad5 2021-12-02 op newline.
231 76991ad5 2021-12-02 op .It Ic recv Ns Pq
232 76991ad5 2021-12-02 op Receive a message from the server and return it as an object.
233 76991ad5 2021-12-02 op A
234 76991ad5 2021-12-02 op .Dv Terror
235 76991ad5 2021-12-02 op doesn't stop the execution of the test, rather, an error object is
236 76991ad5 2021-12-02 op returned.
237 76991ad5 2021-12-02 op See
238 76991ad5 2021-12-02 op .Sx OBJECTS AND FIELDS
239 76991ad5 2021-12-02 op for the complete list of objects.
240 76991ad5 2021-12-02 op .It Ic send Ns Po Ar type, tag, ... Pc
241 76991ad5 2021-12-02 op Send a 9P message with the given
242 76991ad5 2021-12-02 op .Ar type
243 76991ad5 2021-12-02 op and
244 76991ad5 2021-12-02 op .Ar tag .
245 76991ad5 2021-12-02 op Other arguments, if given, are packed into the message and sent as
246 76991ad5 2021-12-02 op well, respecting the given order.
247 76991ad5 2021-12-02 op The overall length of the message is computed automatically.
248 76991ad5 2021-12-02 op .It Ic skip Ns Pq
249 76991ad5 2021-12-02 op Terminate the execution of the current test suite immediately.
250 76991ad5 2021-12-02 op The test won't be counted as passed nor failed, but as skipped.
251 76991ad5 2021-12-02 op .El
252 76991ad5 2021-12-02 op .Sh OBJECTS AND FIELDS
253 76991ad5 2021-12-02 op List of objects and fields...
254 76991ad5 2021-12-02 op .Sh SEE ALSO
255 76991ad5 2021-12-02 op .Xr 9p 7 ,
256 76991ad5 2021-12-02 op .Xr kamid 8 ,
257 76991ad5 2021-12-02 op .Xr ninepscript 8
258 76991ad5 2021-12-02 op .Sh AUTHORS
259 76991ad5 2021-12-02 op .An -nosplit
260 76991ad5 2021-12-02 op .Nm
261 76991ad5 2021-12-02 op was designed and implemented by
262 76991ad5 2021-12-02 op .An Omar Polo Aq Mt op@omarpolo.com
263 76991ad5 2021-12-02 op for the
264 76991ad5 2021-12-02 op .Xr kamid 8
265 76991ad5 2021-12-02 op daemon regression suite.