File: HackTypecheckerTest.php

package info (click to toggle)
php-nikic-fast-route 1.3.0-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 440 kB
  • sloc: php: 1,306; xml: 36; makefile: 13; sh: 7
file content (44 lines) | stat: -rw-r--r-- 1,326 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php

namespace FastRoute;

use PHPUnit\Framework\TestCase;

class HackTypecheckerTest extends TestCase
{
    const SERVER_ALREADY_RUNNING_CODE = 77;

    public function testTypechecks($recurse = true)
    {
        if (!defined('HHVM_VERSION')) {
            $this->markTestSkipped('HHVM only');
        }
        if (!version_compare(HHVM_VERSION, '3.9.0', '>=')) {
          $this->markTestSkipped('classname<T> requires HHVM 3.9+');
        }

        // The typechecker recurses the whole tree, so it makes sure
        // that everything in fixtures/ is valid when this runs.

        $output = [];
        $exit_code = null;
        exec(
            'hh_server --check ' . escapeshellarg(__DIR__ . '/../../') . ' 2>&1',
            $output,
            $exit_code
        );
        if ($exit_code === self::SERVER_ALREADY_RUNNING_CODE) {
            $this->assertTrue(
              $recurse,
              'Typechecker still running after running hh_client stop'
            );
            // Server already running - 3.10 => 3.11 regression:
            // https://github.com/facebook/hhvm/issues/6646
            exec('hh_client stop 2>/dev/null');
            $this->testTypechecks(/* recurse = */ false);
            return;

        }
        $this->assertSame(0, $exit_code, implode("\n", $output));
    }
}