@@ -760,3 +760,39 @@ InstallGlobalFunction( "TestDirectory", function(arg)
760760
761761 return testTotal;
762762end );
763+
764+
765+ InstallGlobalFunction( " TestPackage" , function (pkgname )
766+ local testfile, file, str;
767+ if not IsBound ( GAPInfo.PackagesInfo.(pkgname) ) then
768+ Print(" #I No package with the name " , pkgname, " is available\n " );
769+ return ;
770+ elif LoadPackage( pkgname ) = fail then
771+ Print( " #I " , pkgname, " package can not be loaded\n " );
772+ return ;
773+ elif not IsBound ( GAPInfo.PackagesInfo.(pkgname)[ 1 ] .TestFile ) then
774+ Print(" #I No standard tests specified in the installed version of the " , pkgname, " package\n " );
775+ return ;
776+ else
777+ testfile := GAPInfo.PackagesInfo.(pkgname)[ 1 ] .TestFile;
778+ file:= Filename( DirectoriesPackageLibrary( pkgname, " " ), testfile );
779+ str:= StringFile( file );
780+ if not IsString( str ) then
781+ Print( " #I Test file `" , testfile, " ' for package `" , pkgname, " is not readable\n " );
782+ return ;
783+ fi ;
784+ if PositionSublist( str, " gap> START_TEST(" ) = fail then
785+ if not READ( file ) then
786+ Print( " #I Test file `" , testfile, " ' for package `" , pkgname, " is not readable\n " );
787+ fi ;
788+ else
789+ if not Test( file, rec (compareFunction := " uptowhitespace" ) ) then
790+ Print( " #I Errors detected while testing package " , pkgname, " \n " ,
791+ " #I using the test file `" , testfile, " '\n " );
792+ else
793+ Print( " #I No errors detected while testing package " , pkgname, " \n " ,
794+ " #I using the test file `" , testfile, " '\n " );
795+ fi ;
796+ fi ;
797+ fi ;
798+ end );
0 commit comments