Drizzle Wiki
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 190: Line 190:
 
--assert_rows num_rows; # Checks that the number of results in the output is a certain number
 
--assert_rows num_rows; # Checks that the number of results in the output is a certain number
 
--result_diff filepath; # Diff a returned result with the contents of a file
 
--result_diff filepath; # Diff a returned result with the contents of a file
 
== Test Case and Results Case Parser ==
 
 
The Drizzle Test Case Syntax has the following BNF grammar:
 
 
command_block_list : command_block_list
 
| command_block
 
command_block : command_block_header LBRACE command_list RBRACE
 
command_block_header : IDENTIFIER LPAREN IDENTIFIER RPAREN
 
| IDENTIFIER LPAREN RPAREN
 
| IDENTIFIER
 
command_list : command_list command SEMI
 
| command SEMI
 
command : IDENTIFIER LPAREN RPAREN
 
| IDENTIFIER LPAREN command_arg_list RPAREN
 
command_arg_list : command_arg_list COMMA command_arg
 
| command_arg
 
command_arg : command
 
| literal
 
literal : LITERAL_STRING
 
| LITERAL_INTEGER
 
| LITERAL_BINARY_INTEGER
 
| LITERAL_HEX_INTEGER
 
| LITERAL_FLOAT
 
 
A parser has now been constructed in Python (using the PLY framework for Yacc/Lex compatible parsing). The parser is available in lp:~jaypipes/drizzle/new-test-runner
 
 
Using the following test case:
 
<pre>
 
# Tests that COUNT(*), AVG(), MIN(), MAX() on a table
 
# with no rows returns correct results
 
SETUP ()
 
{
 
EXECUTE_SQL("DROP TABLE IF EXISTS t1");
 
EXECUTE_SQL("CREATE TABLE t1 (id INT NOT NULL)");
 
}
 
 
TEARDOWN ()
 
{
 
EXECUTE_SQL("TRUNCATE t1");
 
ASSERT_SQL(1,2,3,4,COUNT(5,3,4));
 
}
 
 
TEST (count)
 
{
 
EXECUTE_SQL("SELECT COUNT(*) FROM t1");
 
}
 
 
TEST (max)
 
{
 
EXECUTE_SQL("SELECT MAX(id) FROM t1");
 
}
 
 
TEST (min)
 
{
 
EXECUTE_SQL("SELECT MIN(id) FROM t1");
 
}
 
 
TEST (avg)
 
{
 
EXECUTE_SQL("SELECT AVG(id) FROM t1");
 
}
 
</pre>
 
 
the parser now constructs this abstract syntax tree representation:
 
<pre>
 
[511][jpipes@serialcoder: runnerlib]$ python parser.py
 
Command Block List
 
Command Block
 
Command Block Header
 
Value: ('SETUP', None)
 
Command List
 
Command
 
Value: EXECUTE_SQL
 
Command Arg List
 
Literal
 
Value: DROP TABLE IF EXISTS t1
 
Command
 
Value: EXECUTE_SQL
 
Command Arg List
 
Literal
 
Value: CREATE TABLE t1 (id INT NOT NULL)
 
Command Block
 
Command Block Header
 
Value: ('TEARDOWN', None)
 
Command List
 
Command
 
Value: EXECUTE_SQL
 
Command Arg List
 
Literal
 
Value: TRUNCATE t1
 
Command
 
Value: ASSERT_SQL
 
Command Arg List
 
Literal
 
Value: 1
 
Literal
 
Value: 2
 
Literal
 
Value: 3
 
Literal
 
Value: 4
 
Command
 
Value: COUNT
 
Command Arg List
 
Literal
 
Value: 5
 
Literal
 
Value: 3
 
Literal
 
Value: 4
 
Command Block
 
Command Block Header
 
Value: ('TEST', 'count')
 
Command List
 
Command
 
Value: EXECUTE_SQL
 
Command Arg List
 
Literal
 
Value: SELECT COUNT(*) FROM t1
 
Command Block
 
Command Block Header
 
Value: ('TEST', 'max')
 
Command List
 
Command
 
Value: EXECUTE_SQL
 
Command Arg List
 
Literal
 
Value: SELECT MAX(id) FROM t1
 
Command Block
 
Command Block Header
 
Value: ('TEST', 'min')
 
Command List
 
Command
 
Value: EXECUTE_SQL
 
Command Arg List
 
Literal
 
Value: SELECT MIN(id) FROM t1
 
Command Block
 
Command Block Header
 
Value: ('TEST', 'avg')
 
Command List
 
Command
 
Value: EXECUTE_SQL
 
Command Arg List
 
Literal
 
Value: SELECT AVG(id) FROM t1
 
</pre>
 
   
 
== Required Actions of Test Runner ==
 
== Required Actions of Test Runner ==
Please note that all contributions to the Drizzle Wiki are considered to be released under the CC-BY-SA
Cancel Editing help (opens in new window)

Template used on this page: