|
| 1 | + |
| 2 | +How SQLFTW is currently tested |
| 3 | +============================== |
| 4 | + |
| 5 | +SQLFTW unit tests |
| 6 | +----------------- |
| 7 | + |
| 8 | +there are unit tests of course. these are written against documentation and do not cover 100% of the features yet. |
| 9 | + |
| 10 | +majority of unit tests check parser in this way: |
| 11 | +- parser tests a given SQL code |
| 12 | +- resulting `Command` is serialized back to string |
| 13 | +- original code and result string is compared and should be equal |
| 14 | + |
| 15 | +there are of course some differences. mainly these three: |
| 16 | +- parser does not track white space, so things like spaces and indentation are normalized |
| 17 | +- (My)SQL uses some aliases like `\N` == `null` or `CHARSET` == `CHARACTER SET`. these are also normalized |
| 18 | +- in some cases there are optional syntax features that are normalized (always removed or always added). e.g. optional `=` in table options etc. |
| 19 | + |
| 20 | +unit tests are not the main source of truth! |
| 21 | + |
| 22 | +see `/tests/Parser` |
| 23 | + |
| 24 | +run `composer t` for unit tests |
| 25 | + |
| 26 | + |
| 27 | +Database unit tests |
| 28 | +------------------- |
| 29 | + |
| 30 | +these are the main source of truth |
| 31 | + |
| 32 | +SQLFTW is currently using the test suites from mysql-server project |
| 33 | + |
| 34 | +these tests are written in Perl, using SQL syntax directly combined with Perl syntax. i am doing my best to strip |
| 35 | +as much non-SQL syntax as possible while keeping as much SQL syntax as possible. resulting code is then being fed to |
| 36 | +`Parser`. the measure for success for now is, whether parser fails and wheter the resulting `Command`s can be serialized. |
| 37 | +i am not currently checking if it serializes properly. working on that... |
| 38 | + |
| 39 | +this test is being runned on all ~8000 test files from mysql-server source and in all versions since 8.0.0 to current version. |
| 40 | +more versions will be added later (5.7...) |
| 41 | + |
| 42 | +see `/tests/Mysql` |
| 43 | + |
| 44 | +run `php tests/Mysql/test.php` for Mysql tests |
| 45 | + |
| 46 | +requirements: |
| 47 | +- you will need `https://github.com/mysql/mysql-server` cloned to adjacent directory |
| 48 | +- you will need `https://github.com/paranoiq/dogma-debug` wired in for now |
0 commit comments