hhvm / hacktest

A unit testing framework for Hack
MIT License
29 stars 12 forks source link

Verbose output does not include actual error frame - trace starts one frame out #82

Closed fredemmott closed 5 years ago

fredemmott commented 5 years ago

This matches PHP behavior - Throwable::getTrace() and ::getTraceAsString() do not include the active behavior.

Instead, ::getFile() and ::getLine() must be used - and function name is not exposed.

fredemmott commented 5 years ago

Something along these liens in HackTestCLI seems reasonable:

        if ($err is ExpectationFailedException) {
          $num_failed++;
        }
        if ($this->verbose) {
          $curr = $err;
          while ($curr) {
            $output .= Str\format(
              "%s\n\n@  %s(%d)\n%s",
              $curr->getMessage(),
              $curr->getFile(),
              $curr->getLine(),
              $curr->getTraceAsString(),
            );
            $curr = $curr->getPrevious();
            if ($curr !== null) {
              $output .= "\n\nPrevious exception:\n\n";
            }
          }