HackTypecheckerTest.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace FastRoute;
  3. use PHPUnit\Framework\TestCase;
  4. class HackTypecheckerTest extends TestCase
  5. {
  6. const SERVER_ALREADY_RUNNING_CODE = 77;
  7. public function testTypechecks($recurse = true)
  8. {
  9. if (!defined('HHVM_VERSION')) {
  10. $this->markTestSkipped('HHVM only');
  11. }
  12. if (!version_compare(HHVM_VERSION, '3.9.0', '>=')) {
  13. $this->markTestSkipped('classname<T> requires HHVM 3.9+');
  14. }
  15. // The typechecker recurses the whole tree, so it makes sure
  16. // that everything in fixtures/ is valid when this runs.
  17. $output = [];
  18. $exit_code = null;
  19. exec(
  20. 'hh_server --check ' . escapeshellarg(__DIR__ . '/../../') . ' 2>&1',
  21. $output,
  22. $exit_code
  23. );
  24. if ($exit_code === self::SERVER_ALREADY_RUNNING_CODE) {
  25. $this->assertTrue(
  26. $recurse,
  27. 'Typechecker still running after running hh_client stop'
  28. );
  29. // Server already running - 3.10 => 3.11 regression:
  30. // https://github.com/facebook/hhvm/issues/6646
  31. exec('hh_client stop 2>/dev/null');
  32. $this->testTypechecks(/* recurse = */ false);
  33. return;
  34. }
  35. $this->assertSame(0, $exit_code, implode("\n", $output));
  36. }
  37. }