Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Actually three features are introduced with this commit. ## SQL driver Now test-run recognizes *.test.sql files. The content of those files are SQL statements written line-by-line. A long statement may be splitted, see the next section. The implementation leans on '\set language [lua|sql]' command of tarantool console: appropriate language is set depending of a file name: *.test.lua or *.test.sql before executing commands for a test file. A value of 'engine' option when it is provided by a configuration has a special meaning for *.test.sql tests (a configuration is a file set by 'config' option in suite.ini) . If it is 'memtx' or 'vinyl', then corresponding default engine will be set for SQL subsystem before executing commands for a test file. The implementation uses "pragma sql_default_engine='memtx|vinyl'" command. It is possible to mix Lua and SQL code in *.test.lua and *.test.sql tests. Consider an example: | -- Verify output of large integers. | CREATE TABLE test (id INTEGER PRIMARY KEY) | INSERT INTO test VALUES (9223372036854775807) | SELECT * FROM test | \set language lua | box.space.TEST:select() | \set language sql | DROP TABLE test ## Line carrying with backslash Consider the following code: | test_run:cmd("setopt delimiter ';'") | function echo(...) | return ... | end | test_run:cmd("setopt delimiter ''"); Now it may be rewritten in the following way: | function echo(...) \ | return ... \ | end This ability also works in SQL test files: a long statement may be written in this way: | CREATE TABLE t1 (s1 VARCHAR(10) PRIMARY KEY) | CREATE TABLE t2 (s1 VARCHAR(10) PRIMARY KEY, s2 VARCHAR(10) \ | REFERENCES t1 ON DELETE CASCADE) ## New result file format A new result file format is introduced. The differences are following. 1. A result of a Lua command or SQL statement is indented to easier distinguish from a command / statement itself. Before: | CREATE TABLE t1 (s1 VARCHAR(10) PRIMARY KEY) | --- | - row_count: 1 | ... After: | CREATE TABLE t1 (s1 VARCHAR(10) PRIMARY KEY) | | --- | | - row_count: 1 | | ... 2. Empty lines from a test file are preserved in a result file. 3. A small bug when a comment in a setopt-delimiter block is written before a previous command was fixed. 4. The first line of a result file in the new format is a version line. | -- test-run result file version 2 A result file for a new test will be written in the new format, but when a result file already exists (and has the old format), test-run performs formatting of a test output in the old way. So the new test-run version is backward compatible with previous ones and no changes are needed for existing test and result files. If you want to update a result file to the new format, remove it and run a test. If you want to produce a result file in the old format for a new test, create an empty result file, run a test and move *.reject to *.result. Fixes tarantool/tarantool#4123
- Loading branch information
1 parent
4ecf8ce
commit a04b5b0
Showing
5 changed files
with
280 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.