Skip to content

Commit

Permalink
Use colors in output of Test() and some other tests
Browse files Browse the repository at this point in the history
... to make it easier to see and understand diffs.
  • Loading branch information
fingolfin committed Nov 12, 2020
1 parent 320bf65 commit c0845a8
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 26 deletions.
5 changes: 3 additions & 2 deletions etc/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ do
# restore current directory before each test suite
cd "$BUILDDIR"

echo "Running test suite $TEST_SUITE"
case $TEST_SUITE in
testspecial | test-compile)
cd $SRCDIR/tst/$TEST_SUITE
Expand Down Expand Up @@ -97,9 +98,9 @@ GAPInput
Print("-----------------------------------------------------\n");
Print("Loading $pkg ... \n");
if LoadPackage("$pkg",false) = true then
Print("PASS: $pkg\n\n");
Print(TextAttr.2, "PASS: $pkg\n\n", TextAttr.reset);
else
Print("FAIL: $pkg\n\n");
Print(TextAttr.1, "FAIL: $pkg\n\n", TextAttr.reset);
AppendTo("fail.log", "Loading failed : ", "$pkg", "\n");
fi;
GAPInput
Expand Down
39 changes: 27 additions & 12 deletions lib/test.gi
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,32 @@ end);
## </ManSection>
## <#/GAPDoc>
##
DeclareGlobalName("TextAttr"); # from GAPDoc
BindGlobal("DefaultReportDiff", function(inp, expout, found, fnam, line, time)
Print(TextAttr.1);
Print("########> Diff in ");
if IsStream(fnam) then
Print("test stream, line ",line,":\n");
else
Print(fnam,":",line,"\n");
fi;
Print(TextAttr.1);
Print("# Input is:\n");
Print(TextAttr.reset);
Print(inp);
Print(TextAttr.1);
Print("# Expected output:\n");
Print(TextAttr.reset, TextAttr.b2);
Print(expout);
Print(TextAttr.reset, TextAttr.delline, TextAttr.1);
Print("# But found:\n");
Print(TextAttr.reset, TextAttr.b1);
Print(found);
Print(TextAttr.reset, TextAttr.delline, TextAttr.1);
Print("########\n");
Print(TextAttr.reset);
end);

InstallGlobalFunction("Test", function(arg)
local fnam, nopts, opts, size, full, pf, failures, lines, ign, new,
cT, ok, oldtimes, thr, delta, len, c, i, j, d, localdef, line;
Expand Down Expand Up @@ -519,18 +545,7 @@ InstallGlobalFunction("Test", function(arg)
end,
rewriteToFile := false,
breakOnError := false,
reportDiff := function(inp, expout, found, fnam, line, time)
Print("########> Diff in ");
if IsStream(fnam) then
Print("test stream, line ",line,":\n");
else
Print(fnam,":",line,"\n");
fi;
Print("# Input is:\n", inp);
Print("# Expected output:\n", expout);
Print("# But found:\n", found);
Print("########\n");
end,
reportDiff := DefaultReportDiff,
subsWindowsLineBreaks := true,
returnNumFailures := false,
localdef := false,
Expand Down
15 changes: 3 additions & 12 deletions tst/testmanuals.g
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@
ExamplesReportDiff := function(inp, expout, found, fnam, line, time)
local tstf, i, loc, res;

Print("########> Diff in ");
if IsStream(fnam) then
Print("test stream, line ",line,"\n");
else
if IsString(fnam) then
tstf := SplitString(StringFile(fnam), "\n");
i := line;
# Look for location marker
Expand All @@ -30,17 +27,11 @@ ExamplesReportDiff := function(inp, expout, found, fnam, line, time)
loc := InputTextString(Concatenation(tstf[i]{[6..Length(tstf[i])]}, ";"));
res := READ_COMMAND_REAL(loc, false);
if res[1] = true then
Print(res[2][1],":",res[2][2]);
fnam := Concatenation(fnam,res[2][1],":",res[2][2]);
fi;
Print(" (", fnam,":",line,")\n");
else # did not find a location marker
Print(fnam,":",line,"\n");
fi;
fi;
Print("# Input is:\n", inp);
Print("# Expected output:\n", expout);
Print("# But found:\n", found);
Print("########\n");
DefaultReportDiff(inp, expout, found, fnam, line, time)
end;

TestManualChapter := function(filename)
Expand Down

0 comments on commit c0845a8

Please sign in to comment.