Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,33 @@ testpackages:
( chmod 777 testpackages.in; ./testpackages.in; rm testpackages.in )
( rm wsp.g )

testpackage:
mkdir -p dev/log
( echo 'SetAssertionLevel( 2 ); ReadGapRoot( "tst/testutil.g" ); \
SaveWorkspace( "wsp.g" );' | $(TESTGAP) )
( echo 'CreatePackageTestsInput( "testpackage.in", \
"dev/log/testpackage1", \
"$(TESTGAP) -L wsp.g", "false", "$(PKGNAME)" );'\
| $(TESTGAP) -L wsp.g > /dev/null )
( chmod 777 testpackage.in; ./testpackage.in; rm testpackage.in )
( rm wsp.g )
( echo 'SetAssertionLevel( 2 ); ReadGapRoot( "tst/testutil.g" ); \
SaveWorkspace( "wsp.g" );' | $(TESTGAPauto) )
( echo 'CreatePackageTestsInput( "testpackage.in", \
"dev/log/testpackageA", \
"$(TESTGAPauto) -L wsp.g", "auto", "$(PKGNAME)" );'\
| $(TESTGAPauto) -L wsp.g > /dev/null )
( chmod 777 testpackage.in; ./testpackage.in; rm testpackage.in )
( rm wsp.g )
( echo 'SetAssertionLevel( 2 ); ReadGapRoot( "tst/testutil.g" ); \
SaveWorkspace( "wsp.g" );' | $(TESTGAP) )
( echo 'CreatePackageTestsInput( "testpackage.in", \
"dev/log/testpackage2", \
"$(TESTGAP) -L wsp.g", "true", "$(PKGNAME)" );'\
| $(TESTGAP) -L wsp.g > /dev/null )
( chmod 777 testpackage.in; ./testpackage.in; rm testpackage.in )
( rm wsp.g )

testpackagesload:
mkdir -p dev/log
( echo 'ReadGapRoot( "tst/testutil.g" ); \
Expand Down
3 changes: 3 additions & 0 deletions doc/ref/debug.xml
Original file line number Diff line number Diff line change
Expand Up @@ -769,6 +769,9 @@ gaussian.tst 0 10

<#Include Label="Test">
<#Include Label="TestDirectory">

See also <Ref Func="TestPackage"/> for the information on running standard
tests for &GAP; packages.
</Section>


Expand Down
1 change: 1 addition & 0 deletions doc/ref/gappkg.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ package and not by users of a package.

<#Include Label="ReadPackage">
<#Include Label="TestPackageAvailability">
<#Include Label="TestPackage">
<#Include Label="InstalledPackageVersion">
<#Include Label="DirectoriesPackageLibrary">
<#Include Label="DirectoriesPackagePrograms">
Expand Down
1 change: 1 addition & 0 deletions lib/test.gd
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ DeclareGlobalFunction("ParseTestFile");
DeclareGlobalFunction("RunTests");
DeclareGlobalFunction("Test");
DeclareGlobalFunction("TestDirectory");
DeclareGlobalFunction("TestPackage");

74 changes: 74 additions & 0 deletions lib/test.gi
Original file line number Diff line number Diff line change
Expand Up @@ -760,3 +760,77 @@ InstallGlobalFunction( "TestDirectory", function(arg)

return testTotal;
end);

#############################################################################
##
## TestPackage( <pkgname> )
##
## <#GAPDoc Label="TestPackage">
## <ManSection>
## <Func Name="TestPackage" Arg='pkgname'/>
## <Description>
## It is recommended that a &GAP; package specifies a standard test in its
## <F>PackageInfo.g</F> file. If <A>pkgname</A> is a string with the name of
## a &GAP; package, then <C>TestDirectory(pkgname)</C> will check if this
## package is loadable and has the standard test, and will run this test in
## the current &GAP; session.<P/>
##
## The output of the test depends on the particular package, and it also
## may depend on the current &GAP; session (loaded packages, state of the
## random sources, defined global variables etc.). If you would like to
## run the test for the same package in the same setting that is used
## for the testing of &GAP; releases, you have to call
##
## <Log><![CDATA[
## make testpackage PKGNAME=pkgname
## ]]></Log>
##
## in the UNIX shell (without quotes around <A>pkgname</A>). This will run
## the standard test for the package <A>pkgname</A> three times in different
## settings, and will write test output to three files in the <F>dev/log</F>
## directory. These output files will be named in the format
## <F>testpackageX_timestamp.pkgname</F>, where <C>X=A</C> for the test
## with packages loaded by default, <C>X=1</C> for the test without other
## packages (i.e. when &GAP; is started with <C>-A</C> command line option),
## and <C>X=2</C> when the test is run with all packages loaded.
## </Description>
## </ManSection>
## <#/GAPDoc>
##
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;
elif LoadPackage( pkgname ) = fail then
Print( "#I ", pkgname, " package can not be loaded\n" );
return;
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;
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;
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");
else
Print( "#I Errors detected while testing package ", pkgname,
" version ", GAPInfo.PackagesInfo.(pkgname)[1].Version,
"\n#I using the test file `", testfile, "'\n");
fi;
elif not READ( testfile ) then
Print( "#I Test file `", testfile, "' for package `", pkgname,
" version ", GAPInfo.PackagesInfo.(pkgname)[1].Version, " is not readable\n" );
fi;
fi;
end);
18 changes: 15 additions & 3 deletions tst/testutil.g
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,28 @@ end;
## is actually managed in the Makefile, and is passed to this function
## just to be printed in the information messages.
##
BindGlobal( "CreatePackageTestsInput", function( scriptfile, outfile, gap, other )
local result, name, entry, pair, testfile;
BindGlobal( "CreatePackageTestsInput", function( scriptfile, outfile, gap, other, pkgname... )
local result, name, entry, pair, testfile, packages;

SizeScreen( [ 1000 ] );
InitializePackagesInfoRecords( false );
result:= "";

Append( result, "TIMESTAMP=`date -u +_%Y-%m-%d-%H-%M`\n" );

for name in SortedList(ShallowCopy(RecNames(GAPInfo.PackagesInfo))) do
if Length(pkgname)=0 then
packages := SortedList(ShallowCopy(RecNames(GAPInfo.PackagesInfo)));
else
packages := pkgname;
if Length(packages) <> 1 or Length(packages[1]) = 0 then
Error("Usage: make testpackage PKGNAME=pkgname");
fi;
if not pkgname[1] in RecNames(GAPInfo.PackagesInfo) then
Error("There is no package with the name ", pkgname[1], " installed\n");
fi;
fi;

for name in packages do
for entry in GAPInfo.PackagesInfo.( name ) do
if IsBound( entry.InstallationPath ) and IsBound( entry.TestFile ) then
testfile := Filename( DirectoriesPackageLibrary( name, "" ), entry.TestFile );
Expand Down