Skip to content

Commit

Permalink
Little bit of doc
Browse files Browse the repository at this point in the history
  • Loading branch information
paranoiq committed Jun 28, 2022
1 parent 82950e4 commit e1655b3
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 4 deletions.
14 changes: 10 additions & 4 deletions doc/doc.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@

Random doc:
Documentation index:
====================

as all doc, this doc is also not current, but it can give some insight into how things generally work

- [Testing](testing.md)
- [Parser exceptions](parser-exceptions.md)
- [SQL model hierarchy](sql-model.md)
- [SQL commands](sql-commands.md)
- [SQL expression nodes](sql-expression-nodes.md)
- [Lexer token types](token-types.md)
- [SQL: model hierarchy](sql-model.md)
- [SQL: commands](sql-commands.md)
- [SQL: other statements](sql-compound-statements.md)
- [SQL: expression nodes](sql-expression-nodes.md)
- [Some notes to PHP type-hint usage in the project](types.md)
48 changes: 48 additions & 0 deletions doc/testing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@

How SQLFTW is currently tested
==============================

SQLFTW unit tests
-----------------

there are unit tests of course. these are written against documentation and do not cover 100% of the features yet.

majority of unit tests check parser in this way:
- parser tests a given SQL code
- resulting `Command` is serialized back to string
- original code and result string is compared and should be equal

there are of course some differences. mainly these three:
- parser does not track white space, so things like spaces and indentation are normalized
- (My)SQL uses some aliases like `\N` == `null` or `CHARSET` == `CHARACTER SET`. these are also normalized
- in some cases there are optional syntax features that are normalized (always removed or always added). e.g. optional `=` in table options etc.

unit tests are not the main source of truth!

see `/tests/Parser`

run `composer t` for unit tests


Database unit tests
-------------------

these are the main source of truth

SQLFTW is currently using the test suites from mysql-server project

these tests are written in Perl, using SQL syntax directly combined with Perl syntax. i am doing my best to strip
as much non-SQL syntax as possible while keeping as much SQL syntax as possible. resulting code is then being fed to
`Parser`. the measure for success for now is, whether parser fails and wheter the resulting `Command`s can be serialized.
i am not currently checking if it serializes properly. working on that...

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.
more versions will be added later (5.7...)

see `/tests/Mysql`

run `php tests/Mysql/test.php` for Mysql tests

requirements:
- you will need `https://github.com/mysql/mysql-server` cloned to adjacent directory
- you will need `https://github.com/paranoiq/dogma-debug` wired in for now

0 comments on commit e1655b3

Please sign in to comment.