Skip to content

Commit 212f048

Browse files
committed
Add the test suite and a CI job
Cover the token stream, the scanner (the exhaustive unit suite ported from the SQLite driver), the parser runtime, token value and name resolution, generated grammar-data invariants, and a corpus regression test pinning the exact acceptance tally. Run the suite on the oldest and newest supported PHP versions in CI.
1 parent 3a1b9e9 commit 212f048

11 files changed

Lines changed: 2083 additions & 0 deletions
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: MySQL Parser Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- trunk
7+
paths:
8+
- '.github/workflows/mysql-parser-tests.yml'
9+
- 'packages/mysql-parser/**'
10+
pull_request:
11+
paths:
12+
- '.github/workflows/mysql-parser-tests.yml'
13+
- 'packages/mysql-parser/**'
14+
workflow_dispatch:
15+
16+
concurrency:
17+
group: ${{ github.workflow }}-${{ github.ref }}
18+
cancel-in-progress: true
19+
20+
# Disable permissions for all available scopes by default.
21+
# Any needed permissions should be configured at the job level.
22+
permissions: {}
23+
24+
jobs:
25+
test:
26+
# The runtime supports PHP 7.2+; test the oldest and the latest.
27+
name: PHP ${{ matrix.php }}
28+
runs-on: ubuntu-latest
29+
timeout-minutes: 10
30+
permissions:
31+
contents: read # Required to clone the repo.
32+
strategy:
33+
fail-fast: false
34+
matrix:
35+
php: [ '7.2', '8.5' ]
36+
37+
steps:
38+
- name: Checkout repository
39+
uses: actions/checkout@v4
40+
41+
- name: Set up PHP
42+
uses: shivammathur/setup-php@v2
43+
with:
44+
php-version: ${{ matrix.php }}
45+
coverage: none
46+
47+
- name: Install dependencies
48+
working-directory: packages/mysql-parser
49+
run: composer install --no-interaction --no-progress
50+
51+
- name: Run tests
52+
working-directory: packages/mysql-parser
53+
run: composer run test

‎packages/mysql-parser/composer.json‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@
1111
"src/"
1212
]
1313
},
14+
"require-dev": {
15+
"phpunit/phpunit": "^8.5"
16+
},
1417
"scripts": {
18+
"test": "phpunit",
1519
"build-grammar": [
1620
"./bin/build-grammar"
1721
],
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<phpunit
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/8.5/phpunit.xsd"
4+
bootstrap="tests/bootstrap.php"
5+
backupGlobals="false"
6+
colors="true"
7+
beStrictAboutTestsThatDoNotTestAnything="true"
8+
beStrictAboutOutputDuringTests="true"
9+
convertErrorsToExceptions="true"
10+
convertWarningsToExceptions="true"
11+
convertNoticesToExceptions="true"
12+
convertDeprecationsToExceptions="true"
13+
>
14+
<php>
15+
<ini name="memory_limit" value="512M"/>
16+
</php>
17+
<testsuites>
18+
<!-- Default test suite to run all tests. -->
19+
<testsuite name="default">
20+
<directory suffix="_Tests.php">tests/</directory>
21+
</testsuite>
22+
</testsuites>
23+
</phpunit>

0 commit comments

Comments
 (0)