Skip to content

Commit 79f555a

Browse files
committed
Ref #360 - Implement testing MariaDB by context level
Signed-off-by: William Desportes <williamdes@wdes.fr>
1 parent e981193 commit 79f555a

File tree

5 files changed

+1088
-0
lines changed

5 files changed

+1088
-0
lines changed

src/Tools/TestGenerator.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,13 @@ public static function build($type, $input, $output, $debug = null, $ansi = fals
150150
Context::setMode('ANSI_QUOTES');
151151
}
152152

153+
$mariaDbPos = strpos($input, '_mariadb_');
154+
if ($mariaDbPos !== false) {// Keep in sync with TestCase.php
155+
// set context
156+
$mariaDbVersion = (int) substr($input, $mariaDbPos + 9, 6);
157+
Context::load('MariaDb' . $mariaDbVersion);
158+
}
159+
153160
$test = static::generate($query, $type);
154161

155162
// unset mode, reset to default every time, to be sure

tests/Parser/SelectStatementTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ public function selectProvider(): array
9191
['parser/parseSelectIndexHintErr4'],
9292
['parser/parseSelectWithParenthesis'],
9393
['parser/parseSelectOrderByComment'],
94+
['parser/parseSelectOverAlias_mariadb_100600'],
9495
];
9596
}
9697
}

tests/TestCase.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
use function file_get_contents;
2020
use function strpos;
21+
use function substr;
2122

2223
/**
2324
* Implements useful methods for testing.
@@ -113,6 +114,13 @@ public function runParserTest($name)
113114
Context::setMode('ANSI_QUOTES');
114115
}
115116

117+
$mariaDbPos = strpos($name, '_mariadb_');
118+
if ($mariaDbPos !== false) {// Keep in sync with TestGenerator.php
119+
// set context
120+
$mariaDbVersion = (int) substr($name, $mariaDbPos + 9, 6);
121+
Context::load('MariaDb' . $mariaDbVersion);
122+
}
123+
116124
// Lexer.
117125
$lexer = new Lexer($data['query']);
118126
$lexerErrors = $this->getErrorsAsArray($lexer);
File renamed without changes.

0 commit comments

Comments
 (0)