@@ -760,3 +760,42 @@ InstallGlobalFunction( "TestDirectory", function(arg)
760760
761761 return testTotal;
762762end );
763+
764+
765+ InstallGlobalFunction( " TestPackage" , function (pkgname )
766+ local testfile, 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 " , pkgname, " package, version " ,
775+ GAPInfo.PackagesInfo.(pkgname)[ 1 ] .Version, " \n " );
776+ return ;
777+ else
778+ testfile := Filename( DirectoriesPackageLibrary( pkgname, " " ),
779+ GAPInfo.PackagesInfo.(pkgname)[ 1 ] .TestFile );
780+ str:= StringFile( testfile );
781+ if not IsString( str ) then
782+ Print( " #I Test file `" , testfile, " ' for package `" , pkgname,
783+ " version " , GAPInfo.PackagesInfo.(pkgname)[ 1 ] .Version, " is not readable\n " );
784+ return ;
785+ fi ;
786+ if EndsWith(testfile," .tst" ) then
787+ if Test( testfile, rec (compareFunction := " uptowhitespace" ) ) then
788+ Print( " #I No errors detected while testing package " , pkgname,
789+ " version " , GAPInfo.PackagesInfo.(pkgname)[ 1 ] .Version,
790+ " \n #I using the test file `" , testfile, " '\n " );
791+ else
792+ Print( " #I Errors detected while testing package " , pkgname,
793+ " version " , GAPInfo.PackagesInfo.(pkgname)[ 1 ] .Version,
794+ " \n #I using the test file `" , testfile, " '\n " );
795+ fi ;
796+ elif not READ( testfile ) then
797+ Print( " #I Test file `" , testfile, " ' for package `" , pkgname,
798+ " version " , GAPInfo.PackagesInfo.(pkgname)[ 1 ] .Version, " is not readable\n " );
799+ fi ;
800+ fi ;
801+ end );
0 commit comments