Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The debug information is not shown in PHP version 7.4 #1

Closed
Chrono79 opened this issue May 25, 2020 · 7 comments · Fixed by #2
Closed

The debug information is not shown in PHP version 7.4 #1

Chrono79 opened this issue May 25, 2020 · 7 comments · Fixed by #2
Labels
bug Something isn't working

Comments

@Chrono79
Copy link

Sorry if it doesn't go here. There are some katas that have enabled 7.4 where you can't see the debug information, like this one it only shows a collapsed Details link and when you click there it shows something like this: /workspace/default/tests/ExampleTest.php:6

Please, check.

@kazk kazk transferred this issue from codewars/codewars.com May 25, 2020
@kazk
Copy link
Member

kazk commented May 25, 2020

Details contain the filtered stacktrace.

$this->write(sprintf("\n<LOG::-Details>%s\n", self::escapeLF(self::getDetails($e))));

private static function getDetails(\Throwable $t): string
{
$stackTrace = Filter::getFilteredStacktrace($t);
$previous = $t instanceof ExceptionWrapper ? $t->getPreviousWrapped() : $t->getPrevious();
while ($previous) {
$stackTrace .= "\nCaused by\n" .
TestFailure::exceptionToString($previous) . "\n" .
Filter::getFilteredStacktrace($previous);
$previous = $previous instanceof ExceptionWrapper ?
$previous->getPreviousWrapped() : $previous->getPrevious();
}
return ' ' . \str_replace("\n", "\n ", $stackTrace);
}

Details link and when you click there it shows something like this: /workspace/default/tests/ExampleTest.php:6

/workspace/default/tests/ExampleTest.php:6 is where the error was thrown (assertion failure). I can remove Details on assertion failures to avoid confusion and rename Details to Stacktrace on other errors.

@kazk kazk added the enhancement New feature or request label May 25, 2020
@Chrono79
Copy link
Author

Ok, but the problem is you can't see the echo or print_r output in the console, how can you debug your code like that?

@kazk
Copy link
Member

kazk commented May 31, 2020

@kazk Sure, take for instance this kata <- link to the trainer

If you write something like this:

function subtractSum($n) {
  echo($n);
  print_r($n);
  var_dump($n);
  return "something";
}

Neither of those will show in the Output panel if you choose 7.4, if you use 7.0 (unavailable in that kata, you can try in another like Multiply <- also link to the trainer) it appears in a Log drop-down, given you write a proper sample test, the mock-up tests don't call the function.

From codewars/codewars-runner-cli#771 (comment)

@kazk
Copy link
Member

kazk commented May 31, 2020

I had completely misunderstood you. I thought this was just about Details and didn't realize nothing is outputted. That's a bug and I'll look into it.

@kazk kazk added bug Something isn't working and removed enhancement New feature or request labels May 31, 2020
kazk added a commit that referenced this issue May 31, 2020
Also rename `Details` to `Stacktrace` and remove it for assertion
failures to avoid confusion.

Fixes #1
@kazk kazk closed this as completed in #2 May 31, 2020
@kazk
Copy link
Member

kazk commented May 31, 2020

I'll close this when it's deployed.

@kazk kazk reopened this May 31, 2020
@kazk
Copy link
Member

kazk commented Jun 1, 2020

Deployed

@kazk kazk closed this as completed Jun 1, 2020
@Chrono79
Copy link
Author

Chrono79 commented Jun 1, 2020

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants