Skip to content

Commit

Permalink
[tests] better debug data on failures
Browse files Browse the repository at this point in the history
  • Loading branch information
kLabz committed Jan 3, 2024
1 parent 8ab7572 commit f9a8a0b
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions tests/server/src/cases/CsSafeTypeBuilding.hx
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,20 @@ class CsSafeTypeBuilding extends TestCase {
}

#if debug
var failed:Bool;
function _assertHasPrint(s:String, ?pos:haxe.PosInfos) {
if (!assertHasPrint(s)) haxe.Log.trace("Fail", pos);
if (!assertHasPrint(s)) {
failed = true;
haxe.Log.trace("Fail: doesn't contain \"" + s + "\"", pos);
}
}
#end

function assertResult(target:String) {
#if debug var assertHasPrint = _assertHasPrint; #end
#if debug
failed = false;
var assertHasPrint = _assertHasPrint;
#end
assertSuccess();

// Make sure all types are generated
Expand All @@ -40,6 +47,10 @@ class CsSafeTypeBuilding extends TestCase {
assertHasPrint("[runtime] Hello from Foo__Main__Main");
assertHasPrint("[runtime] Hello from Main");

#if debug
if (failed) messages.filter(m -> StringTools.startsWith(m, "Haxe print: ")).iter(m -> trace(m));
#end

// Disabled this check because types move around a bit so we get false negatives
// Kept for debugging purposes
if (false && target == "js") {
Expand Down

0 comments on commit f9a8a0b

Please sign in to comment.