Skip to content

Commit

Permalink
Make AvailabilityTest for packages optional
Browse files Browse the repository at this point in the history
If missing we assume it is ReturnTrue which is what >= 100 of our packages use.
  • Loading branch information
fingolfin committed Nov 7, 2024
1 parent 70eba1d commit 13c516a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions doc/ref/gappkg.xml
Original file line number Diff line number Diff line change
Expand Up @@ -273,13 +273,6 @@ The following components of this record are <E>mandatory</E>.
</Item>
</List>
</Item>
<Mark><C>AvailabilityTest</C></Mark>
<Item>
a function with no arguments that returns <K>true</K> if the package is
available, and <K>false</K> otherwise
(can be <Ref Func="ReturnTrue"/> if the package consists only of &GAP;
code).
</Item>
</List>

The following components of the record are <E>optional</E>.
Expand Down Expand Up @@ -384,6 +377,13 @@ The following components of the record are <E>optional</E>.
</Item>
</List>
</Item>
<Mark><C>AvailabilityTest</C></Mark>
<Item>
a function with no arguments that returns <K>true</K> if the package is
available, and <K>false</K> otherwise
(can be <Ref Func="ReturnTrue"/> if the package consists only of &GAP;
code; this is also the default value),
</Item>
<Mark><C>BannerString</C> or <C>BannerFunction</C></Mark>
<Item>
a string or a function, respectively,
Expand Down
4 changes: 2 additions & 2 deletions lib/package.gi
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,7 @@ InstallGlobalFunction( PackageAvailabilityInfo,

# Test whether the availability test function fits.
GAPInfo.PackageCurrent:= inforec;
test:= inforec.AvailabilityTest();
test:= (not IsBound(inforec.AvailabilityTest)) or (inforec.AvailabilityTest() = true);
Unbind( GAPInfo.PackageCurrent );
if test = true then
LogPackageLoadingMessage( PACKAGE_DEBUG,
Expand Down Expand Up @@ -2524,7 +2524,7 @@ InstallGlobalFunction( ValidatePackageInfo, function( info )
ForAll( l, IsString ) ) and
IsBound( r.filename ) and IsString( r.filename ) ),
"a list of records with components `needed' and `filename'" );
TestMandat( record, "AvailabilityTest", IsFunction, "a function" );
TestOption( record, "AvailabilityTest", IsFunction, "a function" );
TestOption( record, "BannerFunction", IsFunction, "a function" );
TestOption( record, "BannerString", IsString, "a string" );
TestOption( record, "TestFile", IsFilename,
Expand Down

0 comments on commit 13c516a

Please sign in to comment.