Skip to content

Commit

Permalink
Adjust TestPackage to return info about test result
Browse files Browse the repository at this point in the history
... at least where possible; the value `true` indicates success, `false` means
that tests were run but failed, and `fail` that there was an error, e.g. no
tests were found or it was not possible tor run them.
  • Loading branch information
fingolfin committed Oct 21, 2019
1 parent fe70aa2 commit 2555b88
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions lib/test.gi
Original file line number Diff line number Diff line change
Expand Up @@ -980,36 +980,46 @@ InstallGlobalFunction( "TestPackage", function(pkgname)
local testfile, str;
if not IsBound( GAPInfo.PackagesInfo.(pkgname) ) then
Print("#I No package with the name ", pkgname, " is available\n");
return;
return fail;
elif LoadPackage( pkgname ) = fail then
Print( "#I ", pkgname, " package can not be loaded\n" );
return;
return fail;
elif not IsBound( GAPInfo.PackagesInfo.(pkgname)[1].TestFile ) then
Print("#I No standard tests specified in ", pkgname, " package, version ",
GAPInfo.PackagesInfo.(pkgname)[1].Version, "\n");
return;
return fail;
else
testfile := Filename( DirectoriesPackageLibrary( pkgname, "" ),
GAPInfo.PackagesInfo.(pkgname)[1].TestFile );
str:= StringFile( testfile );
if not IsString( str ) then
Print( "#I Test file `", testfile, "' for package `", pkgname,
" version ", GAPInfo.PackagesInfo.(pkgname)[1].Version, " is not readable\n" );
return;
return fail;
fi;
if EndsWith(testfile,".tst") then
if Test( testfile, rec(compareFunction := "uptowhitespace") ) then
Print( "#I No errors detected while testing package ", pkgname,
" version ", GAPInfo.PackagesInfo.(pkgname)[1].Version,
"\n#I using the test file `", testfile, "'\n");
return true;
else
Print( "#I Errors detected while testing package ", pkgname,
" version ", GAPInfo.PackagesInfo.(pkgname)[1].Version,
"\n#I using the test file `", testfile, "'\n");
return false;
fi;
elif not READ( testfile ) then
Print( "#I Test file `", testfile, "' for package `", pkgname,
" version ", GAPInfo.PackagesInfo.(pkgname)[1].Version, " is not readable\n" );
return fail;
else
# At this point, the READ succeeded, but we have no idea what the
# outcome of that test was. Hopefully, that file printed a message of
# its own and then terminated GAP with a suitable error code (e.g. by
# using TestDirectory with exitGAP:=true); in that case we never get
# here an all is fine.
return "UNKNOWN";
fi;
fi;
end);

0 comments on commit 2555b88

Please sign in to comment.