forked from gap-packages/PackageManager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPackageManager.tst
489 lines (442 loc) · 16.1 KB
/
PackageManager.tst
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
# Get curlInterface (for testing)
gap> InstallPackage("curlInterface");
true
gap> if DownloadURL = fail then
> Unbind(DownloadURL); # unbind dummy variable set in init.g
> fi;
gap> LoadPackage("curlInterface", false);
true
# Clean up and recompile curlInterface
gap> dir := PackageInfo("curlInterface")[1].InstallationPath;;
gap> RemoveDirectoryRecursively(Filename(Directory(dir), "bin"));
true
gap> CompilePackage("curlInterface");
true
# IO should be pre-installed for these tests to pass
gap> IsEmpty(PackageInfo("io"));
false
# Try to compile IO (which should be installed but not in the user pkg dir)
gap> CompilePackage("io");
#I Package "io" not installed in user package directory
false
# Try to compile something that's not there at all
gap> CompilePackage("madeUpPackage");
#I Package "madeuppackage" not installed in user package directory
false
# UpdatePackage for non-user packages
gap> UpdatePackage("GAPDoc", false);
#I Package "gapdoc" not installed in user package directory
false
# Install GAP's required packages
gap> conts := DirectoryContents(PKGMAN_PackageDir());;
gap> ForAny(conts, f -> StartsWith(f, "primgrp"));
false
gap> ForAny(conts, f -> StartsWith(f, "SmallGrp"));
false
gap> ForAny(conts, f -> StartsWith(f, "transgrp"));
false
gap> ForAny(conts, f -> StartsWith(f, "GAPDoc"));
false
gap> InstallRequiredPackages();
true
gap> conts := DirectoryContents(PKGMAN_PackageDir());;
gap> ForAny(conts, f -> StartsWith(f, "primgrp"));
true
gap> ForAny(conts, f -> StartsWith(f, "SmallGrp"));
true
gap> ForAny(conts, f -> StartsWith(f, "transgrp"));
true
gap> ForAny(conts, f -> StartsWith(f, "GAPDoc"));
true
gap> RemovePackage("primgrp", false);
true
gap> RemovePackage("SmallGrp", false);
true
gap> RemovePackage("transgrp", false);
true
gap> RemovePackage("GAPDoc", false);
true
# Install and remove a package by name
gap> InstallPackage("matgrp");
true
gap> InstallPackage("matgrp");
true
gap> UpdatePackage("matgrp");
true
gap> ForAny(DirectoryContents(PKGMAN_PackageDir()),
> f -> StartsWith(f, "matgrp"));
true
gap> RemovePackage("matgrp", false);
true
gap> RemovePackage("matgrp");
#I Package "matgrp" not installed in user package directory
false
# Install using a required package number
gap> InstallPackage("matgrp", ">=0.5");
true
gap> RemovePackage("matgrp", false);
true
gap> InstallPackage("matgrp", "0.5", false);
true
gap> RemovePackage("matgrp", false);
true
# Required package number too high
gap> InstallPackage("matgrp", "9999.0");
#I Version "9999.0" of package "matgrp" cannot be satisfied
false
# Fail to install a GAP required package
gap> backup := GAPInfo.Dependencies.NeededOtherPackages;;
gap> needed := ShallowCopy(backup);;
gap> Add(needed, ["packagethatgaptotallyneeds", ">= 2.0"], 1);
gap> GAPInfo.Dependencies := rec(NeededOtherPackages := needed);;
gap> InstallRequiredPackages();
#I Package "packagethatgaptotallyneeds" not found in package list
false
gap> GAPInfo.Dependencies := rec(NeededOtherPackages := backup);;
# Repositories that don't contain GAP packages
gap> InstallPackageFromGit("https://github.com/mtorpey/planets.git", true);
#I Could not find PackageInfo.g
false
gap> InstallPackageFromHg("http://hg.code.sf.net/p/pkgmanforms/empty_repo", true);
#I Could not find PackageInfo.g
false
# Install a package from a PackageInfo.g URL (includes redirect)
gap> InstallPackage("https://gap-packages.github.io/autpgrp/PackageInfo.g");
true
gap> ForAny(DirectoryContents(PKGMAN_PackageDir()),
> f -> StartsWith(f, "autpgrp"));
true
gap> RemovePackage("autpgrp", false);
true
# Install a package from a .tar.gz archive
gap> InstallPackage("https://github.com/gap-packages/example/releases/download/v4.2.1/Example-4.2.1.tar.gz");
true
gap> ForAny(DirectoryContents(PKGMAN_PackageDir()),
> f -> StartsWith(LowercaseString(f), "example"));
true
gap> RemovePackage("example", false);
true
# RemovePackage failure
gap> RemovePackage(3);
Error, PackageManager: RemovePackage: <name> must be a string
gap> RemovePackage("xyz");
#I Package "xyz" not installed in user package directory
false
gap> RemovePackage("PackageManager");
#I Package "PackageManager" not installed in user package directory
false
gap> RemovePackage("PackageManager", true, false);
Error, PackageManager: RemovePackage: requires 1 or 2 arguments (not 3)
gap> RemovePackage("PackageManager", "please default to yes");
Error, PackageManager: RemovePackage: <interactive> must be true or false
# UpdatePackage bad inputs
gap> UpdatePackage(3);
Error, PackageManager: UpdatePackage: <name> must be a string
gap> UpdatePackage("io", "yes");
Error, PackageManager: UpdatePackage: <interactive> must be true or false
gap> UpdatePackage("io", true, "master", "hello", Group(()), fail, []);
Error, PackageManager: UpdatePackage: requires 1 or 2 arguments (not 7)
# CompilePackage bad input
gap> CompilePackage(3);
Error, PackageManager: CompilePackage: <name> must be a string
gap> CompilePackage(true);
Error, PackageManager: CompilePackage: <name> must be a string
# Installing multiple versions
gap> InstallPackage("https://github.com/gap-packages/grpconst/releases/download/v2.6/grpconst-2.6.tar.gz");
true
gap> InstallPackage("https://github.com/gap-packages/grpconst/releases/download/v2.5/grpconst-2.5.tar.gz");
true
gap> RemovePackage("grpconst");
#I Multiple versions of package grpconst installed
false
# GetPackageURLs failure
gap> default_url := PKGMAN_PackageInfoURLList;;
gap> PKGMAN_PackageInfoURLList := "http://www.nothing.rubbish/abc.txt";;
gap> GetPackageURLs();
#I PackageManager: GetPackageURLs: could not contact server
rec( success := false )
gap> PKGMAN_PackageInfoURLList := "https://www.gap-system.org";;
gap> GetPackageURLs();
#I PackageManager: GetPackageURLs: bad line:
#I <?xml version="1.0" encoding="utf-8"?>
rec( success := false )
gap> PKGMAN_PackageInfoURLList := default_url;;
# InstallPackage input failure
gap> InstallPackage(3);
Error, PackageManager: InstallPackage: <string> must be a string
gap> InstallPackage("semigroups", 'y');
Error, PackageManager: InstallPackage:
2nd argument must be true or false or a version string
gap> InstallPackage("semigroups", "yes", "actually no");
Error, PackageManager: InstallPackageFromName:
if specified, <interactive> must be true or false
gap> InstallPackage("semigroups", ">=3.0", true, "i dont know");
Error, PackageManager: InstallPackage: requires 1 to 3 arguments (not 4)
# InstallPackageFromName failure
gap> InstallPackage("sillypackage");
#I Package "sillypackage" not found in package list
false
# InstallPackageFromInfo input failure
gap> InstallPackageFromInfo(42);
Error, PackageManager: InstallPackageFromInfo: <info> should be a rec or URL
# InstallPackageFromInfo failure (Remove #E messages after they leave GAP)
gap> InstallPackage("http://www.nothing.rubbish/PackageInfo.g");
#I Unable to download from http://www.nothing.rubbish/PackageInfo.g
false
# TODO: package that doesn't offer a ".tar.gz" archive
# I'm not sure any such packages currently exist.
#gap> InstallPackage("nilmat");
##I No supported archive formats available, so could not install
##I Only [ ".zip" ] available
#false
# InstallPackageFromArchive failure
gap> InstallPackage("www.gap.rubbish/somepackage.tar.gz");
#I Could not download from www.gap.rubbish/somepackage.tar.gz
false
gap> InstallPackage("https://gap-packages.github.io/PackageManager/dummy/bad-tarball.tar.gz");
#I Could not inspect tarball contents
false
gap> InstallPackage("https://gap-packages.github.io/PackageManager/dummy/twodirs.tar.gz");
#I Archive should contain 1 directory (not 2)
false
gap> InstallPackage("https://gap-packages.github.io/PackageManager/dummy/badpackage.tar.gz");
#I PackageInfo.g validation failed
false
# Fail to extract due to permissions
gap> dir := Filename(Directory(PKGMAN_PackageDir()), "badpackage");;
gap> CreateDir(dir);
true
gap> PKGMAN_Exec(".", "chmod", "000", dir);
rec( code := 0, output := "" )
gap> PKGMAN_CreateDirRecursively(Filename(Directory(dir), "subfolder"));
#I Failed to create required directory
fail
gap> InstallPackage("https://gap-packages.github.io/PackageManager/dummy/badpackage.tar.gz");
#I Target location not writable
false
gap> PKGMAN_Exec(".", "chmod", "222", dir);
rec( code := 0, output := "" )
gap> InstallPackage("https://gap-packages.github.io/PackageManager/dummy/badpackage.tar.gz");
#I Target location not readable
false
gap> PKGMAN_Exec(".", "chmod", "777", dir);
rec( code := 0, output := "" )
# InstallPackageFromGit failure
gap> InstallPackage("www.gap.rubbish/somepackage.git");
#I Cloning unsuccessful
false
gap> InstallPackage(".git");
#I Could not find repository name (bad URL?)
false
# InstallPackageFromHg failure
gap> InstallPackage("www.gap.rubbish/somepackage.hg");
#I Cloning unsuccessful
false
gap> InstallPackage(".hg");
#I Could not find repository name (bad URL?)
false
# Check a bad package directory (Remove #E messages after they leave GAP)
gap> baddir := Filename(Directory(PKGMAN_PackageDir()), "badpkg");;
gap> CreateDir(baddir);;
gap> PKGMAN_CheckPackage(baddir);
#I Could not find PackageInfo.g file
false
gap> FileString(Filename(Directory(baddir), "PackageInfo.g"),
> "SetPackageInfo(rec());");;
gap> PKGMAN_CheckPackage(baddir);
#I PackageInfo.g validation failed
false
gap> RemoveDirectoryRecursively(baddir);;
# PKGMAN_Exec failure
gap> PKGMAN_Exec(".", 3);
Error, <cmd> should be a string
gap> PKGMAN_Exec(".", "xyzabc");
fail
# PKGMAN_CustomPackageDir
gap> olddir := PKGMAN_CustomPackageDir;;
gap> PKGMAN_CustomPackageDir := "";;
gap> EndsWith(PKGMAN_PackageDir(), "/.gap/pkg");
true
gap> PKGMAN_CustomPackageDir := olddir;;
gap> PKGMAN_SetCustomPackageDir("/home"); # not ending in pkg
fail
gap> PKGMAN_InsertPackageDirectory("/home"); # not ending in pkg
fail
# PKGMAN_CompileDir error: no shell
gap> InstallPackage("example");
true
gap> InstallPackage("example"); # latest version already installed
true
gap> progs := GAPInfo.DirectoriesPrograms;;
gap> GAPInfo.DirectoriesPrograms := [];; # terrible vandalism
gap> dir := PackageInfo("example")[1].InstallationPath;;
gap> PKGMAN_CompileDir(dir);
#I No shell available called "sh"
#I Compilation failed (package may still be usable)
false
gap> GAPInfo.DirectoriesPrograms := progs;;
# PKGMAN_CompileDir error: no bin/BuildPackages.sh
gap> InstallPackage("example", false); # latest version already installed
true
gap> sysinfo_scr := PKGMAN_Sysinfo;;
gap> PKGMAN_Sysinfo := fail;;
gap> dir := PackageInfo("example")[1].InstallationPath;;
gap> PKGMAN_CompileDir(dir);
#I No sysinfo.gap found
false
gap> PKGMAN_Sysinfo := sysinfo_scr;;
# PKGMAN_CompileDir error: missing source
gap> InstallPackage("example"); # latest version already installed
true
gap> dir := PackageInfo("example")[1].InstallationPath;;
gap> RemoveFile(Filename(Directory(dir), "src/hello.c"));
true
gap> PKGMAN_CompileDir(dir);
#I Compilation failed (package may still be usable)
false
# Missing BuildPackages script
gap> temp := PKGMAN_BuildPackagesScript;;
gap> PKGMAN_BuildPackagesScript := fail;;
gap> CompilePackage("curlInterface");
#I Compilation script not found
false
gap> PKGMAN_BuildPackagesScript := temp;;
# Missing curlInterface: use wget instead
gap> ver := PKGMAN_CurlIntReqVer;;
gap> PKGMAN_CurlIntReqVer := ">= 100.0";;
gap> InstallPackage("https://gap-packages.github.io/Memoisation/PackageInfo.g");
true
gap> RemovePackage("Memoisation", false);
true
gap> PKGMAN_CurlIntReqVer := ver;;
# wget failure
gap> ver := PKGMAN_CurlIntReqVer;;
gap> PKGMAN_CurlIntReqVer := ">= 100.0";;
gap> InstallPackage("www.gap.rubbish/somepackage.tar.gz");
#I Could not download from www.gap.rubbish/somepackage.tar.gz
false
gap> PKGMAN_CurlIntReqVer := ver;;
# Missing curlInterface: use curl instead
gap> ver := PKGMAN_CurlIntReqVer;;
gap> PKGMAN_CurlIntReqVer := ">= 100.0";;
gap> tmp := PKGMAN_DownloadCmds[1];;
gap> PKGMAN_DownloadCmds[1] := PKGMAN_DownloadCmds[2];;
gap> PKGMAN_DownloadCmds[2] := tmp;;
gap> PKGMAN_DownloadCmds[1][1];
"curl"
gap> InstallPackage("uuid");
true
gap> RemovePackage("uuid", false);
true
gap> PKGMAN_CurlIntReqVer := ver;;
# Install to existing empty directory
gap> CreateDir(Filename(Directory(PKGMAN_PackageDir()), "Toric-1.9.4"));
true
gap> InstallPackage("https://github.com/gap-packages/toric/releases/download/v1.9.4/Toric-1.9.4.tar.gz");
true
# Compile already compiled
gap> CompilePackage("toric");
true
# curl failure
gap> ver := PKGMAN_CurlIntReqVer;;
gap> PKGMAN_CurlIntReqVer := ">= 100.0";;
gap> PKGMAN_DownloadCmds[1][1];
"curl"
gap> InstallPackage("www.gap.rubbish/somepackage.tar.gz");
#I Could not download from www.gap.rubbish/somepackage.tar.gz
false
gap> PKGMAN_CurlIntReqVer := ver;;
# Missing first command
gap> ver := PKGMAN_CurlIntReqVer;;
gap> PKGMAN_CurlIntReqVer := ">= 100.0";;
gap> PKGMAN_DownloadCmds[1][1] := "abababaxyz";;
gap> InstallPackage("crypting");
true
gap> PKGMAN_CurlIntReqVer := ver;;
# Installing dependencies
gap> old_paths := GAPInfo.RootPaths;;
gap> dir := PKGMAN_PackageDir();;
gap> dir := SplitString(dir, "/");;
gap> Remove(dir) = "pkg";
true
gap> dir := JoinStringsWithSeparator(dir, "/");;
gap> dir := Concatenation(dir, "/");;
gap> GAPInfo.RootPaths := Immutable([dir]);;
gap> GAPInfo.DirectoriesLibrary := AtomicRecord(rec());;
gap> if IsBound(GAPInfo.PackagesInfoInitialized) and
> GAPInfo.PackagesInfoInitialized = true then
> GAPInfo.PackagesInfoInitialized := false;
> InitializePackagesInfoRecords();
> fi;
gap> PackageInfo("HomalgToCAS");
[ ]
gap> PackageInfo("MatricesForHomalg");
[ ]
gap> InstallPackage("https://github.com/gap-packages/utils/releases/download/v0.59/utils-0.59.tar.gz"); # TEMP
true
gap> InstallPackage("HomalgToCAS");
true
gap> ForAll(["HomalgToCAS", "MatricesForHomalg", "GAPDoc", "IO"],
> name -> Length(PackageInfo(name)) = 1 or
> IsPackageLoaded(LowercaseString(name)));
true
gap> GAPInfo.RootPaths := old_paths;;
gap> GAPInfo.DirectoriesLibrary := AtomicRecord(rec());;
gap> if IsBound(GAPInfo.PackagesInfoInitialized) and
> GAPInfo.PackagesInfoInitialized = true then
> GAPInfo.PackagesInfoInitialized := false;
> InitializePackagesInfoRecords();
> fi;
# Dependency failure
gap> InstallPackage("https://gap-packages.github.io/PackageManager/dummy/uuid-badname.tar.gz");
#I Required package madeuppackage unknown
#I Dependencies not satisfied for uuid-0.6
false
gap> InstallPackageFromGit("https://github.com/mtorpey/uuid.git", false);
#I Required package MadeUpPackage unknown
#I Dependencies not satisfied for uuid
false
# TODO: hg repo with bad dependency package name
#gap> InstallPackageFromHg("https://[email protected]/mtorpey/uuid");
##I Required package MadeUpPackage unknown
##I Dependencies not satisfied for uuid
#false
# Sabotaged PackageInfoURLList to produce some special errors
gap> InstallPackage("GAPDoc");
true
gap> InstallPackage("uuid");
true
gap> urllist := PKGMAN_PackageInfoURLList;;
gap> PKGMAN_PackageInfoURLList :=
> "https://gap-packages.github.io/PackageManager/dummy/badurls.txt";;
gap> InstallPackageFromGit("https://github.com/mtorpey/uuid.git", false);
#I Could not inspect tarball contents
#I Dependencies not satisfied for uuid
false
gap> UpdatePackage("GAPDoc", false); # Installed version is newer than online
true
gap> UpdatePackage("uuid", false); # Newer version, but fails to install
#I Could not inspect tarball contents
false
gap> RemovePackage("uuid", false);
true
gap> InstallPackage("https://gap-packages.github.io/PackageManager/dummy/uuid-too-new.tar.gz");
#I Package GAPDoc = 999.0 unavailable: only version 0.2 was found
#I Dependencies not satisfied for uuid-0.6
false
gap> PKGMAN_PackageInfoURLList := urllist;;
# Fail to build doc with doc/make_doc (assumes GAP is located at ../../..)
gap> InstallPackage("https://github.com/gap-packages/grape.git");
#E component `ArchiveURLSubset' must be bound to a list of strings denoting r\
elative paths to readable files or directories
#E component `HTMLStart' must be bound to a string denoting a relative path t\
o a readable file
#E component `PDFFile' must be bound to a string denoting a relative path to \
a readable file
#E component `SixFile' must be bound to a string denoting a relative path to \
a readable file
#I PackageInfo.g validation failed
false
# FINAL TEST
# (keep this at the end of the file)
gap> PKGMAN_SetCustomPackageDir(Filename(DirectoryTemporary(), "pkg/"));