diff --git a/etc/ci.sh b/etc/ci.sh index 39f8b78b54..f16a361cae 100644 --- a/etc/ci.sh +++ b/etc/ci.sh @@ -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 @@ -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 diff --git a/lib/test.gi b/lib/test.gi index e18c0d9491..c02a9de296 100644 --- a/lib/test.gi +++ b/lib/test.gi @@ -499,6 +499,44 @@ end); ## ## <#/GAPDoc> ## +DeclareGlobalName("TextAttr"); # from GAPDoc +DeclareGlobalName("DefaultReportDiffColors"); # initialized in Test() or by the user +BindGlobal("DefaultReportDiff", function(inp, expout, found, fnam, line, time) + if UserPreference("UseColorsInTerminal") = true then + Print(DefaultReportDiffColors.message); + Print("########> Diff in "); + if IsStream(fnam) then + Print("test stream, line ",line,":"); + else + Print(fnam,":",line); + fi; + Print(TextAttr.reset, "\n", DefaultReportDiffColors.message); + Print("# Input is:", TextAttr.reset, "\n"); + Print(DefaultReportDiffColors.input); + Print(inp); + Print(TextAttr.reset, TextAttr.delline, DefaultReportDiffColors.message); + Print("# Expected output:", TextAttr.reset, "\n"); + Print(DefaultReportDiffColors.expected); + Print(expout); + Print(TextAttr.reset, TextAttr.delline, DefaultReportDiffColors.message); + Print("# But found:", TextAttr.reset, "\n"); + Print(DefaultReportDiffColors.actual); + Print(found); + Print(TextAttr.reset, TextAttr.delline, DefaultReportDiffColors.message); + Print("########", TextAttr.reset, "\n"); + else + 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"); fi; +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; @@ -510,6 +548,14 @@ InstallGlobalFunction("Test", function(arg) else nopts := rec(); fi; + if not IsBound(DefaultReportDiffColors) then + BindGlobal("DefaultReportDiffColors", rec( + message := TextAttr.4, # blue text + input := "", + expected := Concatenation(TextAttr.0, TextAttr.b2), # black text on green background + actual := Concatenation(TextAttr.7, TextAttr.b1), # white text on red background + )); + fi; opts := rec( ignoreComments := true, isStream := IsStream(fnam), @@ -538,18 +584,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, diff --git a/tst/testmanuals.g b/tst/testmanuals.g index 98ee399895..ea6e4c0fe5 100644 --- a/tst/testmanuals.g +++ b/tst/testmanuals.g @@ -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 @@ -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)