Fine grained version choice for test_old

This commit is contained in:
Nikita Popov 2020-08-09 15:51:40 +02:00
parent 544aee1671
commit 722119502f
3 changed files with 33 additions and 42 deletions

View File

@ -26,16 +26,18 @@ matrix:
php: nightly
install:
- composer update --ignore-platform-req=php --no-progress --prefer-dist
- name: PHP 7 Integration Tests
php: 7.4
- name: PHP 7.3 Code on PHP 8.0 Integration Tests
php: nightly
install:
- composer update --ignore-platform-req=php --no-progress --prefer-dist
script:
- test_old/run-php-src.sh 7
- name: PHP 8 Integration Tests
php: 7.4
- test_old/run-php-src.sh 7.3.21
- name: PHP 8.0 Code on PHP 7.0 Integration Tests
php: 7.0
script:
- test_old/run-php-src.sh 8
- test_old/run-php-src.sh 8.0.0beta1
allow_failures:
- name: PHP 8 Integration Tests
- name: PHP 8.0 Code on PHP 7.0 Integration Tests
fast_finish: true
script: vendor/bin/phpunit

View File

@ -1,9 +1,5 @@
if [[ $1 == '7' ]]; then
VERSION='fa9bd812fcab6dfd6d9b506cb3cb04dfa75d239d'
else
VERSION='05478e985eb50c473054b4f1bf174f48ead78784'
fi
wget -q https://github.com/php/php-src/archive/$VERSION.tar.gz
VERSION=$1
wget -q https://github.com/php/php-src/archive/php-$VERSION.tar.gz
mkdir -p ./data/php-src
tar -xzf ./$VERSION.tar.gz -C ./data/php-src --strip-components=1
php -n test_old/run.php --verbose --no-progress PHP$1 ./data/php-src
tar -xzf ./php-$VERSION.tar.gz -C ./data/php-src --strip-components=1
php -n test_old/run.php --verbose --no-progress --php-version=$VERSION PHP ./data/php-src

View File

@ -14,11 +14,13 @@ This script has to be called with the following signature:
php run.php [--no-progress] testType pathToTestFiles
The test type must be one of: PHP5, PHP7, PHP8 or Symfony.
The test type must be one of: PHP, Symfony
The following options are available:
--no-progress Disables showing which file is currently tested.
--no-progress Disables showing which file is currently tested.
--verbose Print more information for failures.
--php-version=VERSION PHP version to use for lexing/parsing.
OUTPUT
);
@ -32,7 +34,8 @@ array_shift($argv);
foreach ($argv as $arg) {
if ('-' === $arg[0]) {
$options[] = $arg;
$parts = explode('=', $arg);
$options[$parts[0]] = $parts[1] ?? true;
} else {
$arguments[] = $arg;
}
@ -42,18 +45,9 @@ if (count($arguments) !== 2) {
showHelp('Too few arguments passed!');
}
$showProgress = true;
$verbose = false;
foreach ($options as $option) {
if ($option === '--no-progress') {
$showProgress = false;
} elseif ($option === '--verbose') {
$verbose = true;
} else {
showHelp('Invalid option passed!');
}
}
$showProgress = !isset($options['--no-progress']);
$verbose = isset($options['--verbose']);
$phpVersion = $options['--php-version'] ?? '8.0';
$testType = $arguments[0];
$dir = $arguments[1];
@ -61,8 +55,6 @@ require_once __DIR__ . '/../vendor/autoload.php';
switch ($testType) {
case 'Symfony':
$parserVersion = 'Php7';
$lexerVersion = PhpParser\Lexer\Emulative::PHP_7_3;
$fileFilter = function($path) {
if (!preg_match('~\.php$~', $path)) {
return false;
@ -85,11 +77,7 @@ switch ($testType) {
return $code;
};
break;
case 'PHP5':
case 'PHP7':
case 'PHP8':
$parserVersion = $testType === 'PHP5' ? 'Php5' : 'Php7';
$lexerVersion = $testType === 'PHP8' ? PhpParser\Lexer\Emulative::PHP_8_0 : PhpParser\Lexer\Emulative::PHP_7_4;
case 'PHP':
$fileFilter = function($path) {
return preg_match('~\.phpt$~', $path);
};
@ -119,6 +107,9 @@ switch ($testType) {
| ext.standard.tests.file.fread_basic
# its too hard to emulate these on old PHP versions
| Zend.tests.flexible-heredoc-complex-test[1-4]
# whitespace in namespaced name
| Zend.tests.bug55086
| Zend.tests.grammar.regression_010
)\.phpt$~x', $file)) {
return null;
}
@ -134,18 +125,20 @@ switch ($testType) {
};
break;
default:
showHelp('Test type must be one of: PHP5, PHP7, PHP8 or Symfony');
showHelp('Test type must be one of: PHP or Symfony');
}
$lexer = new PhpParser\Lexer\Emulative([
'usedAttributes' => [
'comments', 'startLine', 'endLine', 'startTokenPos', 'endTokenPos',
],
'phpVersion' => $lexerVersion,
'phpVersion' => $phpVersion,
]);
$parserName = 'PhpParser\Parser\\' . $parserVersion;
/** @var PhpParser\Parser $parser */
$parser = new $parserName($lexer);
if (version_compare($phpVersion, '7.0', '>=')) {
$parser = new PhpParser\Parser\Php7($lexer);
} else {
$parser = new PhpParser\Parser\Php5($lexer);
}
$prettyPrinter = new PhpParser\PrettyPrinter\Standard;
$nodeDumper = new PhpParser\NodeDumper;