protected static function processMissingHHVMOutput()

in src/markdown-extensions/extracted-code-blocks/ExtractFilter.php [89:139]


  protected static function processMissingHHVMOutput(
    string $hack_file_path,
    bool $needs_example,
  ): void {
    $config = $hack_file_path.'.'.Files::INI;
    if (!\file_exists($config)) {
      $config = LocalConfig::ROOT.'/api-sources/hhvm/hphp/test/config.ini';
    }

    $command = vec[
      \PHP_BINARY,
      // use the same config as the test runner in ExamplesTest
      '-c',
      $config,
      '-vEval.EnableArgsInBacktraces=false',
      '-dhhvm.hack.lang.disable_xhp_element_mangling=true',
      '-dauto_prepend_file='.
      LocalConfig::ROOT.
      '/src/utils/_private/init_docs_autoloader.php',
      $hack_file_path,
    ]
      |> Vec\map($$, $arg ==> \escapeshellarg($arg))
      |> Str\join($$, ' ');

    $env = vec[
      'GLOG_minloglevel=3', // get rid of mcrouter examples log spew
    ]
      |> Str\join($$, ' ');

    $exit_code = null;
    $output = null;
    \exec($env.' '.$command.' 2>&1', inout $output, inout $exit_code);

    if ($exit_code !== 0) {
      // Regenerate the autoload map and retry. This is a common failure when
      // adding multiple related examples at the same time.
      UpdateAutoloaderBuildStep::generateAutoloadMap();
      \exec($env.' '.$command.' 2>&1', inout $output, inout $exit_code);
    }

    self::writeOutput(
      Str\join($output, "\n"),
      \dirname($hack_file_path),
      $hack_file_path,
      Files::HHVM_EXPECT,
      Files::EXAMPLE_HHVM_OUT,
      Files::HHVM_EXPECTF,
      Files::HHVM_EXPECTREGEX,
      $needs_example,
    );
  }