@@ -760,3 +760,77 @@ InstallGlobalFunction( "TestDirectory", function(arg)
760760
761761 return testTotal;
762762end );
763+
764+ # ############################################################################
765+ # #
766+ # # TestPackage( <pkgname> )
767+ # #
768+ # # <#GAPDoc Label="TestPackage">
769+ # # <ManSection>
770+ # # <Func Name="TestPackage" Arg='pkgname'/>
771+ # # <Description>
772+ # # It is recommended that a &GAP; package specifies a standard test in its
773+ # # <F>PackageInfo.g</F> file. If <A>pkgname</A> is a string with the name of
774+ # # a &GAP; package, then <C>TestDirectory(pkgname)</C> will check if this
775+ # # package is loadable and has the standard test, and will run this test in
776+ # # the current &GAP; session.<P/>
777+ # #
778+ # # The output of the test depends on the particular package, and it also
779+ # # may depend on the current &GAP; session (loaded packages, state of the
780+ # # random sources, defined global variables etc.). If you would like to
781+ # # run the test for the same package in the same setting that is used
782+ # # for the testing of &GAP; releases, you have to call
783+ # #
784+ # # <Log><![CDATA[
785+ # # make testpackage PKGNAME=pkgname
786+ # # ]]></Log>
787+ # #
788+ # # in the UNIX shell (without quotes around <A>pkgname</A>). This will run
789+ # # the standard test for the package <A>pkgname</A> three times in different
790+ # # settings, and will write test output to three files in the <F>dev/log</F>
791+ # # directory. These output files will be named in the format
792+ # # <F>testpackageX_timestamp.pkgname</F>, where <C>X=A</C> for the test
793+ # # with packages loaded by default, <C>X=1</C> for the test without other
794+ # # packages (i.e. when &GAP; is started with <C>-A</C> command line option),
795+ # # and <C>X=2</C> when the test is run with all packages loaded.
796+ # # </Description>
797+ # # </ManSection>
798+ # # <#/GAPDoc>
799+ # #
800+ InstallGlobalFunction( " TestPackage" , function (pkgname )
801+ local testfile, str;
802+ if not IsBound ( GAPInfo.PackagesInfo.(pkgname) ) then
803+ Print(" #I No package with the name " , pkgname, " is available\n " );
804+ return ;
805+ elif LoadPackage( pkgname ) = fail then
806+ Print( " #I " , pkgname, " package can not be loaded\n " );
807+ return ;
808+ elif not IsBound ( GAPInfo.PackagesInfo.(pkgname)[ 1 ] .TestFile ) then
809+ Print(" #I No standard tests specified in " , pkgname, " package, version " ,
810+ GAPInfo.PackagesInfo.(pkgname)[ 1 ] .Version, " \n " );
811+ return ;
812+ else
813+ testfile := Filename( DirectoriesPackageLibrary( pkgname, " " ),
814+ GAPInfo.PackagesInfo.(pkgname)[ 1 ] .TestFile );
815+ str:= StringFile( testfile );
816+ if not IsString( str ) then
817+ Print( " #I Test file `" , testfile, " ' for package `" , pkgname,
818+ " version " , GAPInfo.PackagesInfo.(pkgname)[ 1 ] .Version, " is not readable\n " );
819+ return ;
820+ fi ;
821+ if EndsWith(testfile," .tst" ) then
822+ if Test( testfile, rec (compareFunction := " uptowhitespace" ) ) then
823+ Print( " #I No errors detected while testing package " , pkgname,
824+ " version " , GAPInfo.PackagesInfo.(pkgname)[ 1 ] .Version,
825+ " \n #I using the test file `" , testfile, " '\n " );
826+ else
827+ Print( " #I Errors detected while testing package " , pkgname,
828+ " version " , GAPInfo.PackagesInfo.(pkgname)[ 1 ] .Version,
829+ " \n #I using the test file `" , testfile, " '\n " );
830+ fi ;
831+ elif not READ( testfile ) then
832+ Print( " #I Test file `" , testfile, " ' for package `" , pkgname,
833+ " version " , GAPInfo.PackagesInfo.(pkgname)[ 1 ] .Version, " is not readable\n " );
834+ fi ;
835+ fi ;
836+ end );
0 commit comments