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
|
package pkglint
import "gopkg.in/check.v1"
func (s *Suite) Test_CheckFileAlternatives__PLIST(c *check.C) {
t := s.Init(c)
t.SetUpPackage("category/package")
t.Chdir("category/package")
t.CreateFileLines("ALTERNATIVES",
"sbin/sendmail @PREFIX@/sbin/sendmail.postfix@POSTFIXVER@",
"sbin/sendmail @PREFIX@/sbin/sendmail.exim@EXIMVER@",
"bin/echo bin/gnu-echo",
"bin/editor bin/vim -e",
"invalid",
"bin/browser\t${PREFIX}/bin/firefox",
"highscores @VARBASE@/game/scores",
"sbin/init /sbin/init")
t.CreateFileLines("PLIST",
PlistRcsID,
"bin/echo",
"bin/vim",
"sbin/sendmail.exim${EXIMVER}")
t.FinishSetUp()
G.Check(".")
t.CheckOutputLines(
"ERROR: ALTERNATIVES:1: Alternative implementation \"@PREFIX@/sbin/sendmail.postfix@POSTFIXVER@\" "+
"must appear in the PLIST as \"sbin/sendmail.postfix${POSTFIXVER}\".",
"ERROR: ALTERNATIVES:3: Alternative wrapper \"bin/echo\" must not appear in the PLIST.",
"ERROR: ALTERNATIVES:3: Alternative implementation \"bin/gnu-echo\" must appear in the PLIST.",
"ERROR: ALTERNATIVES:3: Alternative implementation \"bin/gnu-echo\" must be an absolute path.",
"ERROR: ALTERNATIVES:4: Alternative implementation \"bin/vim\" must be an absolute path.",
"ERROR: ALTERNATIVES:5: Invalid line \"invalid\".",
"ERROR: ALTERNATIVES:6: Alternative implementation \"${PREFIX}/bin/firefox\" must appear in the PLIST.",
"ERROR: ALTERNATIVES:6: Alternative implementation \"${PREFIX}/bin/firefox\" must be an absolute path.",
"ERROR: ALTERNATIVES:7: Alternative implementation \"@VARBASE@/game/scores\" "+
"must appear in the PLIST as \"${VARBASE}/game/scores\".")
t.SetUpCommandLine("--autofix")
G.Check(".")
t.CheckOutputLines(
"AUTOFIX: ALTERNATIVES:3: Replacing \"bin/gnu-echo\" with \"@PREFIX@/bin/gnu-echo\".",
"AUTOFIX: ALTERNATIVES:4: Replacing \"bin/vim\" with \"@PREFIX@/bin/vim\".")
}
func (s *Suite) Test_CheckFileAlternatives__empty(c *check.C) {
t := s.Init(c)
t.Chdir("category/package")
t.CreateFileLines("ALTERNATIVES")
G.Pkg = NewPackage(".")
CheckFileAlternatives("ALTERNATIVES")
t.CheckOutputLines(
"ERROR: ALTERNATIVES: Must not be empty.")
}
func (s *Suite) Test_CheckFileAlternatives__ALTERNATIVES_SRC(c *check.C) {
t := s.Init(c)
// It's a strange situation, having an ALTERNATIVES file defined by
// the package but then referring to another package's file by means
// of ALTERNATIVES_SRC. As of February 2019 I don't remember if I
// really had this case in mind when I initially wrote the code in
// CheckFileAlternatives.
t.SetUpPackage("category/package",
"ALTERNATIVES_SRC=\talts")
t.CreateFileLines("category/package/ALTERNATIVES",
"bin/pgm @PREFIX@/bin/gnu-program",
"bin/pgm @PREFIX@/bin/nb-program")
t.FinishSetUp()
G.Check(t.File("category/package"))
t.CheckOutputEmpty()
}
|