Merge lp:~sharan-monikantan/drizzle/drizzletest-2 into lp:drizzle

Proposed by Sharan Kumar
Status: Merged
Approved by: Patrick Crews
Approved revision: 2595
Merged at revision: 2596
Proposed branch: lp:~sharan-monikantan/drizzle/drizzletest-2
Merge into: lp:drizzle
Diff against target: 292 lines (+233/-11)
1 file modified
docs/testing/drizzletest_commands.rst (+233/-11)
To merge this branch: bzr merge lp:~sharan-monikantan/drizzle/drizzletest-2
Reviewer Review Type Date Requested Status
Patrick Crews Approve
Vijay Samuel Pending
Brian Aker Pending
Review via email: mp+126514@code.launchpad.net

Description of the change

The following drizzletest commands are documented:
1.dec
2.delimiter
3.die
4.echo
5.exit
6.inc

To post a comment you must log in.
Revision history for this message
Patrick Crews (patrick-crews) wrote :

Looks good. Thanks for the great work on these docs!

review: Approve
Revision history for this message
Brian Aker (brianaker) wrote :

Merging...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'docs/testing/drizzletest_commands.rst'
2--- docs/testing/drizzletest_commands.rst 2012-09-15 16:29:34 +0000
3+++ docs/testing/drizzletest_commands.rst 2012-09-26 17:34:22 +0000
4@@ -255,9 +255,51 @@
5
6 :program:`dec $variable_name`
7
8-:Example:
9-
10-.. code-block:: python
11+:program:`dec` takes in exactly one argument. The argument should be a ``variable``. The ``dec`` decrements the value of the variable by 1. This command takes two forms. :program:`dec $variable_name;` and :program:`- -dec $variable_name`. This command is the reverse of :ref:`inc`
12+
13+.. note:: If a constant is given as argument, the following error is thrown. ERROR:The argument to dec must be a variable (start with $)
14+
15+.. note:: If two arguments are given, the following error is thrown ERROR:End of line junk detected
16+
17+:Example:
18+
19+::
20+
21+ /tests/t/testname.test:
22+ let $foo = 5;
23+ echo $foo;
24+ dec $foo;
25+ echo $foo;
26+
27+:Output:
28+
29+::
30+
31+ /tests/r/testname.result:
32+ 5
33+ 4
34+
35+.. note:: If a string is stored in the variable, then it is not considered as an error. Decrementing such a variable will store -1 in the variable.
36+
37+:Example:
38+
39+::
40+
41+ /tests/t/testname.test:
42+ let $foo = 5;
43+ echo $foo;
44+ --dec $foo
45+ echo $foo;
46+
47+:Output:
48+
49+::
50+
51+ /tests/r/testname.result:
52+ 5
53+ 4
54+
55+.. note:: In the second form, the ``;`` is not required as a delimiter.
56
57 .. _delimiter:
58
59@@ -268,9 +310,73 @@
60
61 :program:`delimiter string`
62
63-:Example:
64-
65-.. code-block:: python
66+:program:`delimiter` is used to change the default delimiter ``;`` to the one specified by the argument ``string``. The default delimiter is ``;`` (semi-colon). This command takes two forms. :program:`delimiter string` and :program:`- -delimiter string`.
67+
68+.. note:: The string argument can have space in between. In such cases, the entire string (with the space) should be used as delimiter
69+
70+:Example:
71+
72+::
73+
74+ /tests/t/testname.test:
75+ SELECT 1;
76+ delimiter stop;
77+ SELECT 1 stop
78+
79+:Output:
80+
81+::
82+
83+ /tests/r/testname.result:
84+ SELECT 1;
85+ 1
86+ 1
87+ SELECT 1 stop
88+ 1
89+ 1
90+
91+.. note:: The strings are case sensitive. For example, if the delimiter is set to ``stop``, then ``Stop`` or ``STOP`` cannot be considered as delimiter.
92+
93+:Example:
94+
95+::
96+
97+ tests/t/testname.test:
98+ SELECT 1;
99+ --delimiter END OF LINE
100+ SELECT 1 END OF LINE
101+
102+:Output:
103+
104+::
105+
106+ tests/r/testname.result:
107+ SELECT 1;
108+ 1
109+ 1
110+ SELECT 1 END OF LINE
111+ 1
112+ 1
113+
114+.. note:: In the above example, note the usage of ``--delimiter`` form. Also note the string with spaces in them.
115+
116+When a string is set as delimiter, make sure that, the string is not used anywhere else. It should be unique. A common mistake that can be left unnoticed is given in the following example.
117+
118+:Example:
119+
120+::
121+
122+ tests/t/testname.test:
123+ CREATE TABLE test (id INT, start FLOAT, end FLOAT);
124+ INSERT INTO test VALUES (1,10,12);
125+ delimiter end;
126+ SELECT start,end FROM test;
127+
128+.. note:: We get the following error. At line 4: query 'select start,' failed: 1064: You have an error in your SQL syntax;
129+
130+This test seems to be correct. However not that, the ``end`` in line 4 is treated as delimiter, and not as a field.
131+
132+.. note:: To set the delimiter again to another one, ``delimiter new_delimiter`` should be followed by the old_delimiter
133
134 .. _die:
135
136@@ -281,9 +387,32 @@
137
138 :program:`die [message]`
139
140+:program:`die` is used to terminate the test. This command takes in a ``message`` ( string ) as argument. When this line is executed, the test fails, and the message is printed as the reason for aborting the test. This is similar to :ref:`exit`.
141+
142 :Example:
143
144-.. code-block:: python
145+::
146+
147+ tests/t/testname.test:
148+ let $i=3;
149+ while($i)
150+ {
151+ die INFINITE LOOP ENCONTERED;
152+ }
153+
154+:Output:
155+
156+::
157+
158+ ================================================================================
159+ DEFAULT STORAGE ENGINE: innodb
160+ TEST RESULT TIME (ms)
161+ --------------------------------------------------------------------------------
162+
163+ main.testname [ fail ]
164+ testname: At line 4: INFINITE LOOP ENCOUNTERED
165+
166+.. note:: This is often used within a conditional statement such as ``if``. That is, if a particular condition is reached, and the test will here after produce a fail result, then there is no need to carry out the remaining tests. Hence a die statement with the appropriate message can be used.
167
168 .. _diff_files:
169
170@@ -472,9 +601,38 @@
171
172 :program:`echo text`
173
174+:program:`echo` is used to display ``text`` in the test.result file. This is often used for giving a verbose explanation about the test in the test.result file.
175+
176+.. note:: If no text is provided, then a blank line is printed in the test.result file.
177+
178+A good test file should echo all the important comments, so that, they are displayed into the test.result file for more clarity to the readers
179+
180 :Example:
181
182-.. code-block:: python
183+::
184+
185+ tests/t/testname.test:
186+ echo testing select statement...
187+ --echo #test1
188+ SELECT 1;
189+ --echo #test2
190+ SELECT 2;
191+
192+:Output:
193+
194+::
195+
196+ test started...
197+ #test1
198+ SELECT 1;
199+ 1
200+ 1
201+ #test2
202+ SELECT 2;
203+ 2
204+ 2
205+
206+In the above example, we can see that, comments ``test1`` and ``test2`` are echoed into the testname.result file. This gives a better understanding and clarity for the readers while tracing through the testname.result file.
207
208 .. _end:
209
210@@ -542,6 +700,28 @@
211
212 :program:`exit`
213
214+:program:`exit` command is used to terminate the test. It is similar to :ref:`die`. However, here the test is not considered to have failed.
215+
216+:Example:
217+
218+::
219+
220+ tests/t/testname.test:
221+ SELECT 1;
222+ exit
223+ SELECT 2;
224+
225+:Output:
226+
227+::
228+
229+ tests/r/testname.result:
230+ SELECT 1;
231+ 1
232+ 1
233+
234+.. note:: In the above example, the test for ``select 2`` is not executed. Often this statement is used with a conditional statement such as ``if``. That is, if a particular condition is satisfied, and the test has not yet failed so far, and needs no more testing, this exit statement can be used.
235+
236 .. _file_exists:
237
238 file_exists
239@@ -590,9 +770,51 @@
240
241 :program:`inc $var_name`
242
243-:Example:
244-
245-.. code-block:: python
246+:program:`inc` takes in exactly one argument. The argument should be a ``variable``. The ``inc`` increments the value of the variable by 1. This command takes two forms. :program:`inc $variable_name;` and :program:`- -inc $variable_name`. This command is the reverse of :ref:`dec`
247+
248+.. note:: If a constant is given as argument, the following error is thrown. ERROR:The argument to inc must be a variable (start with $)
249+
250+.. note:: If two arguments are given, the following error is thrown ERROR:End of line junk detected
251+
252+:Example:
253+
254+::
255+
256+ /tests/t/testname.test:
257+ let $foo = 5;
258+ echo $foo;
259+ inc $foo;
260+ echo $foo;
261+
262+:Output:
263+
264+::
265+
266+ /tests/r/testname.result:
267+ 5
268+ 6
269+
270+.. note:: If a string is stored in the variable, then it is not considered as an error. Incrementing such a variable will store 1 in the variable.
271+
272+:Example:
273+
274+::
275+
276+ /tests/t/testname.test:
277+ let $foo = 5;
278+ echo $foo;
279+ --inc $foo
280+ echo $foo;
281+
282+:Output:
283+
284+::
285+
286+ /tests/r/testname.result:
287+ 5
288+ 6
289+
290+.. note:: In the second form, the ``;`` is not required as a delimiter.
291
292 .. _let:
293

Subscribers

People subscribed via source and target branches

to all changes: