Skip to content

Commit e1655b3

Browse files
committed
Little bit of doc
1 parent 82950e4 commit e1655b3

2 files changed

Lines changed: 58 additions & 4 deletions

File tree

doc/doc.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11

2-
Random doc:
2+
Documentation index:
3+
====================
34

5+
as all doc, this doc is also not current, but it can give some insight into how things generally work
6+
7+
- [Testing](testing.md)
48
- [Parser exceptions](parser-exceptions.md)
5-
- [SQL model hierarchy](sql-model.md)
6-
- [SQL commands](sql-commands.md)
7-
- [SQL expression nodes](sql-expression-nodes.md)
89
- [Lexer token types](token-types.md)
10+
- [SQL: model hierarchy](sql-model.md)
11+
- [SQL: commands](sql-commands.md)
12+
- [SQL: other statements](sql-compound-statements.md)
13+
- [SQL: expression nodes](sql-expression-nodes.md)
14+
- [Some notes to PHP type-hint usage in the project](types.md)

doc/testing.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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

Comments
 (0)