Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValidatePackageInfo: suppress Print output if requested #5766

Merged
merged 2 commits into from
Jul 29, 2024
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
2 changes: 2 additions & 0 deletions lib/package.gd
Original file line number Diff line number Diff line change
Expand Up @@ -1065,6 +1065,8 @@ DeclareGlobalFunction( "DeclareAutoreadableVariables" );
## The result is <K>true</K> if the record or the contents of the file,
## respectively, has correct format, and <K>false</K> otherwise;
## in the latter case information about the incorrect components is printed.
## These diagnostic messages can be suppressed by setting the global option
## <C>quiet</C> to <K>true</K>.
## <P/>
## Note that the components used for package loading are checked as well as
## the components that are needed for composing the package overview web
Expand Down
40 changes: 26 additions & 14 deletions lib/package.gi
Original file line number Diff line number Diff line change
Expand Up @@ -2234,8 +2234,10 @@ InstallGlobalFunction( ValidatePackageInfo, function( info )

TestOption:= function( record, name, type, typename )
if IsBound( record.( name ) ) and not type( record.( name ) ) then
Print( "#E component `", name, "', if present, must be bound to ",
typename, "\n" );
if ValueOption( "quiet" ) <> true then
Print( "#E component `", name, "', if present, must be bound to ",
typename, "\n" );
fi;
result:= false;
return false;
fi;
Expand All @@ -2244,8 +2246,10 @@ InstallGlobalFunction( ValidatePackageInfo, function( info )

TestMandat:= function( record, name, type, typename )
if not IsBound( record.( name ) ) or not type( record.( name ) ) then
Print( "#E component `", name, "' must be bound to ",
typename, "\n" );
if ValueOption( "quiet" ) <> true then
Print( "#E component `", name, "' must be bound to ",
typename, "\n" );
fi;
result:= false;
return false;
fi;
Expand Down Expand Up @@ -2303,8 +2307,10 @@ InstallGlobalFunction( ValidatePackageInfo, function( info )
IsBound(record.BinaryFiles),
IsBound(record.TextBinaryFilesPatterns) ],
a -> a=true ) > 1 then
Print("#W only one of TextFiles, BinaryFiles or TextBinaryFilesPatterns\n");
Print("#W components must be bound\n");
if ValueOption( "quiet" ) <> true then
Print("#W only one of TextFiles, BinaryFiles or TextBinaryFilesPatterns\n");
Print("#W components must be bound\n");
fi;
fi;
if TestOption( record, "Persons", IsRecordList, "a list of records" )
and IsBound( record.Persons ) then
Expand All @@ -2313,8 +2319,10 @@ InstallGlobalFunction( ValidatePackageInfo, function( info )
TestMandat( subrec, "FirstNames", IsString, "a string" );
if not ( IsBound( subrec.IsAuthor )
or IsBound( subrec.IsMaintainer ) ) then
Print( "#E one of the components `IsAuthor', `IsMaintainer' ",
"must be bound\n" );
if ValueOption( "quiet" ) <> true then
Print( "#E one of the components `IsAuthor', `IsMaintainer' ",
"must be bound\n" );
fi;
result:= false;
fi;
TestOption( subrec, "IsAuthor", IsProperBool, "`true' or `false'" );
Expand All @@ -2325,8 +2333,10 @@ InstallGlobalFunction( ValidatePackageInfo, function( info )
not ( IsBound( subrec.Email ) or
IsBound( subrec.WWWHome ) or
IsBound( subrec.PostalAddress ) ) then
Print( "#E one of the components `Email', `WWWHome', `PostalAddress'\n",
"#E must be bound for each package maintainer \n" );
if ValueOption( "quiet" ) <> true then
Print( "#E one of the components `Email', `WWWHome', `PostalAddress'\n",
"#E must be bound for each package maintainer\n" );
fi;
result:= false;
fi;
fi;
Expand Down Expand Up @@ -2361,7 +2371,7 @@ InstallGlobalFunction( ValidatePackageInfo, function( info )
fi;
for subrec in list do
TestMandat( subrec, "BookName", IsString, "a string" );
if IsBound(subrec.Archive) then
if IsBound(subrec.Archive) and ValueOption( "quiet" ) <> true then
Print("#W PackageDoc.Archive is withdrawn, use PackageDoc.ArchiveURLSubset instead\n");
fi;
TestMandat( subrec, "ArchiveURLSubset", IsFilenameList,
Expand Down Expand Up @@ -2408,9 +2418,11 @@ InstallGlobalFunction( ValidatePackageInfo, function( info )
and IsString( x[1] )
and not LowercaseString( x[1] ) in list );
if not IsEmpty( list ) then
Print( "#E the needed packages in '",
List( list, x -> x[1] ), "'\n",
"#E are currently not needed packages of GAP\n" );
if ValueOption( "quiet" ) <> true then
Print( "#E the needed packages in '",
List( list, x -> x[1] ), "'\n",
"#E are currently not needed packages of GAP\n" );
fi;
result:= false;
fi;
fi;
Expand Down
2 changes: 2 additions & 0 deletions tst/testinstall/package.tst
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ ps:// or ftp://
#E component `PackageDoc' must be bound to a record or a list of records
#E component `AvailabilityTest' must be bound to a function
false
gap> ValidatePackageInfo(rec() : quiet);
false
gap> info := rec(
> PackageName := "pkg",
> Subtitle := "desc",
Expand Down
Loading