-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathci.g
81 lines (76 loc) · 2.67 KB
/
ci.g
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# Functions to test package
#
# Getting package name from its PackageInfo.g file
#
# Borrowed from `ValidatePackageInfo` in GAP's lib/package.gi
GetNameFromPackageInfo := function(info)
local record, pkgdir, i;
if IsString( info ) then
if IsReadableFile( info ) then
Unbind( GAPInfo.PackageInfoCurrent );
Read( info );
if IsBound( GAPInfo.PackageInfoCurrent ) then
record:= GAPInfo.PackageInfoCurrent;
Unbind( GAPInfo.PackageInfoCurrent );
else
Error( "the file <info> is not a `PackageInfo.g' file" );
fi;
pkgdir:= "./";
for i in Reversed( [ 1 .. Length( info ) ] ) do
if info[i] = '/' then
pkgdir:= info{ [ 1 .. i ] };
break;
fi;
od;
else
Error( "<info> is not the name of a readable file" );
fi;
elif IsRecord( info ) then
pkgdir:= fail;
record:= info;
else
Error( "<info> must be either a record or a filename" );
fi;
return record.PackageName;
end;
# Running standard test for the package
#
TestOnePackage := function(pkgname)
local testfile, str;
if not IsBound( GAPInfo.PackagesInfo.(pkgname) ) then
Print("#I No package with the name ", pkgname, " is available\n");
return fail;
elif LoadPackage( pkgname ) = fail then
Print( "#I ", pkgname, " package can not be loaded\n" );
return fail;
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 fail;
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 fail;
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");
return true;
else
Print( "#I Errors detected while testing package ", pkgname,
" version ", GAPInfo.PackagesInfo.(pkgname)[1].Version,
"\n#I using the test file `", testfile, "'\n");
return false;
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;