Commit b7b86ce4 authored by Simon Welsh's avatar Simon Welsh

Merge branch 'phpunit-5.7' into phpunit-6.2

parents b86559a6 e885e708
......@@ -4,9 +4,11 @@ stages:
- deploy
before_script:
- "echo 'hhvm.php7.all=1' >> /etc/hhvm/php.ini"
- "echo 'assume_php=false' > .hhconfig"
- echo 'enable_experimental_tc_features = safe_pass_by_ref' >> .hhconfig
- echo 'hhvm.php7.all=1' >> /etc/hhvm/php.ini
- echo 'assume_php=false' > .hhconfig
- echo 'safe_array=true' >> .hhconfig
- echo 'safe_vector_array=true' >> .hhconfig
- echo 'enable_experimental_tc_features = safe_pass_by_ref, no_fallback_in_namespaces' >> .hhconfig
- ./tests/composer.sh
- composer install
......@@ -26,9 +28,17 @@ hack:
tags:
- docker
hack-nightly:
script:
- hh_server --check .
stage: typecheck
image: hhvm/hhvm:nightly
tags:
- docker
phpunit-min:
script:
- hhvm vendor/bin/phpunit --bootstrap tests/HHITest.php tests/
- hhvm vendor/bin/phpunit tests/
stage: test
image: hhvm/hhvm:3.23.0
tags:
......@@ -36,12 +46,20 @@ phpunit-min:
phpunit:
script:
- hhvm vendor/bin/phpunit --bootstrap tests/HHITest.php tests/
- hhvm vendor/bin/phpunit tests/
stage: test
image: hhvm/hhvm:latest
tags:
- docker
phpunit-nightly:
script:
- hhvm vendor/bin/phpunit tests/
stage: test
image: hhvm/hhvm:nightly
tags:
- docker
packagist:
stage: deploy
only:
......
......@@ -35,6 +35,11 @@
"require-dev": {
"phpunit/phpunit": "*"
},
"autoload-dev": {
"classmap": [
"tests/"
]
},
"minimum-stability": "dev",
"prefer-stable": true
}
......@@ -5,19 +5,19 @@ namespace PHPUnitHHI;
abstract class HHITest extends \PHPUnit\Framework\TestCase {
protected function parseFile(string $testName): \ConstMap<string, string> {
$file = __DIR__.'/runs/'.$testName.'.hhit';
$parts = explode('---', file_get_contents($file));
$parts = \explode('---', \file_get_contents($file));
$head = array_shift(&$parts);
$head = \array_shift(&$parts);
$this->assertEmpty(
$head,
'File for test '.$testName.' has invalid start',
);
invariant(count($parts) % 2 == 0, 'Invalid file for test: %s', $file);
invariant(\count($parts) % 2 == 0, 'Invalid file for test: %s', $file);
$mapping = Map {};
for ($i = 0; $i < count($parts); $i += 2) {
$key = strtoupper(trim($parts[$i]));
$mapping[$key] = trim($parts[$i + 1]);
for ($i = 0; $i < \count($parts); $i += 2) {
$key = \strtoupper(\trim($parts[$i]));
$mapping[$key] = \trim($parts[$i + 1]);
}
return $mapping->toImmMap();
......@@ -30,14 +30,14 @@ abstract class HHITest extends \PHPUnit\Framework\TestCase {
'Test file for '.$testName.' is missing a FILE section',
);
$dumpPath = __DIR__.'/output/test-'.md5($parts['FILE']).'.php';
$dumpPath = __DIR__.'/output/test-'.\md5($parts['FILE']).'.php';
try {
file_put_contents($dumpPath, $parts['FILE']);
\file_put_contents($dumpPath, $parts['FILE']);
// We use hh_server --check instead of \HH\Client\typecheck so that we
// ignore timeouts and don't have to sleep between runs to ensure the
// mtime for the cache check hass passed.
$path = \escapeshellarg(dirname(__DIR__));
$path = \escapeshellarg(\dirname(__DIR__));
$cmd = \sprintf('hh_server --json --check %s 2>&1', $path);
$ret = null;
......@@ -46,9 +46,9 @@ abstract class HHITest extends \PHPUnit\Framework\TestCase {
$json = @\json_decode($output, true);
if (json_last_error() != JSON_ERROR_NONE) {
if (\json_last_error() != \JSON_ERROR_NONE) {
$this->fail(
sprintf('Invalid JSON for test %s: %s', $testName, $output),
\sprintf('Invalid JSON for test %s: %s', $testName, $output),
);
}
$this->assertArrayHasKey('passed', $json);
......@@ -82,16 +82,16 @@ abstract class HHITest extends \PHPUnit\Framework\TestCase {
return $err1['code'] - $err2['code'];
}
return strcmp($err1['error'], $err2['error']);
return \strcmp($err1['error'], $err2['error']);
};
usort(&$actualErrors, $sorter);
usort(&$expectedErrors, $sorter);
\usort(&$actualErrors, $sorter);
\usort(&$expectedErrors, $sorter);
$this->assertEquals($expectedErrors, $actualErrors);
}
} finally {
unlink($dumpPath);
\unlink($dumpPath);
}
}
......@@ -117,12 +117,12 @@ abstract class HHITest extends \PHPUnit\Framework\TestCase {
$message .= $m['descr'].'. ';
}
$error = shape(
'error' => trim($message),
'error' => \trim($message),
'line' => $error['message'][0]['line'],
'code' => $error['message'][0]['code'],
);
$comp = json_encode($error);
$comp = \json_encode($error);
if (!$compressed->contains($comp)) {
$compressed[] = $comp;
$errs[] = $error;
......@@ -138,17 +138,17 @@ abstract class HHITest extends \PHPUnit\Framework\TestCase {
'line' => int,
'code' => int,
)> {
$errors = explode("\n", $errors);
$errors = \explode("\n", $errors);
$errs = Vector {};
foreach ($errors as $error) {
$parts = explode(':', $error, 3);
if (count($parts) != 3) {
$parts = \explode(':', $error, 3);
if (\count($parts) != 3) {
$this->fail('Invalid ERRORS');
}
$errs[] = shape(
'error' => trim($parts[2]),
'line' => intval($parts[0]),
'code' => intval($parts[1]),
'error' => \trim($parts[2]),
'line' => \intval($parts[0]),
'code' => \intval($parts[1]),
);
}
return $errs->toImmVector();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment