Qual: Improve lang test + message in case of test exception

# Qual: Improve lang test + message in case of test exception

This fixes the language test enabling the error message itself.
I also improved the Exception handling so that a backtrace is shown to help
find where it happened (here the error message was empty which was strange
and made it harder to find - the (empty(val)?a:b) was lacking parentheses
for proper concatenation
This commit is contained in:
MDW
2025-01-30 17:53:56 +01:00
parent 09d745057c
commit 70f9dde739
2 changed files with 17 additions and 7 deletions

View File

@@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2018 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2023 Alexandre Janniaux <alexandre.janniaux@gmail.com>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
*
* This program is free software; you can redistribute it and/or modify
@@ -168,6 +168,16 @@ abstract class CommonClassTest extends TestCase
print "##[group]$className::$failedTestMethod failed - $argsText.".PHP_EOL;
print "## ".get_class($t).": {$t->getMessage()}".PHP_EOL;
// Show some information about where it happened
foreach ($t->getTrace() as $idx => $trace) {
if (isset($trace['file'], $trace['line']) // Only if we have a file name
&& !preg_match('/(?:\bphar\b|Framework)/', $trace['file']) // Only if it's not in phpunit
) {
print "## backtrace($idx): From {$trace['file']}:{$trace['line']}.".PHP_EOL;
}
}
if ($nbLinesToShow) {
$newLines = count($last_lines);
if ($newLines > 0) {