Fri Dec 21 19:46:48 2018 UTC ()
pkgtools/pkglint: fix alternatives check

The alternatives implementation may have command line arguments.


(rillig)
diff -r1.9 -r1.10 pkgsrc/pkgtools/pkglint/files/alternatives.go
diff -r1.10 -r1.11 pkgsrc/pkgtools/pkglint/files/alternatives_test.go
diff -r1.4 -r1.5 pkgsrc/pkgtools/pkglint/files/lines_test.go

cvs diff -r1.9 -r1.10 pkgsrc/pkgtools/pkglint/files/Attic/alternatives.go (expand / switch to context diff)
--- pkgsrc/pkgtools/pkglint/files/Attic/alternatives.go 2018/12/21 08:05:24 1.9
+++ pkgsrc/pkgtools/pkglint/files/Attic/alternatives.go 2018/12/21 19:46:48 1.10
@@ -45,7 +45,7 @@
 	}
 
 	for _, line := range lines.Lines {
-		m, wrapper, space, alternative := match3(line.Text, `^([^\t ]+)([ \t]+)([^\t ]+)$`)
+		m, wrapper, space, alternative := match3(line.Text, `^([^\t ]+)([ \t]+)([^\t ]+)`)
 		if !m {
 			line.Errorf("Invalid line %q.", line.Text)
 			G.Explain(

cvs diff -r1.10 -r1.11 pkgsrc/pkgtools/pkglint/files/Attic/alternatives_test.go (expand / switch to context diff)
--- pkgsrc/pkgtools/pkglint/files/Attic/alternatives_test.go 2018/12/21 08:05:24 1.10
+++ pkgsrc/pkgtools/pkglint/files/Attic/alternatives_test.go 2018/12/21 19:46:48 1.11
@@ -30,7 +30,7 @@
 		"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: Invalid line \"bin/editor bin/vim -e\".",
+		"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.",
@@ -42,7 +42,8 @@
 	G.Check(".")
 
 	t.CheckOutputLines(
-		"AUTOFIX: ALTERNATIVES:3: Replacing \"bin/gnu-echo\" with \"@PREFIX@/bin/gnu-echo\".")
+		"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) {

cvs diff -r1.4 -r1.5 pkgsrc/pkgtools/pkglint/files/Attic/lines_test.go (expand / switch to context diff)
--- pkgsrc/pkgtools/pkglint/files/Attic/lines_test.go 2018/12/21 08:05:24 1.4
+++ pkgsrc/pkgtools/pkglint/files/Attic/lines_test.go 2018/12/21 19:46:48 1.5
@@ -57,8 +57,8 @@
 	G.Check(t.File("wip/package"))
 
 	t.CheckOutputLines(
-		"AUTOFIX: ~/wip/package/file1.mk:1: Replacing \"# $NetBSD: lines_test.go,v 1.4 2018/12/21 08:05:24 rillig Exp $\" with \"# $NetBSD: lines_test.go,v 1.4 2018/12/21 08:05:24 rillig Exp $\".",
-		"AUTOFIX: ~/wip/package/file3.mk:1: Inserting a line \"# $NetBSD: lines_test.go,v 1.4 2018/12/21 08:05:24 rillig Exp $\" before this line.",
-		"AUTOFIX: ~/wip/package/file4.mk:1: Inserting a line \"# $NetBSD: lines_test.go,v 1.4 2018/12/21 08:05:24 rillig Exp $\" before this line.",
-		"AUTOFIX: ~/wip/package/file5.mk:1: Inserting a line \"# $NetBSD: lines_test.go,v 1.4 2018/12/21 08:05:24 rillig Exp $\" before this line.")
+		"AUTOFIX: ~/wip/package/file1.mk:1: Replacing \"# $"+"NetBSD: dummy $\" with \"# $"+"NetBSD$\".",
+		"AUTOFIX: ~/wip/package/file3.mk:1: Inserting a line \"# $"+"NetBSD$\" before this line.",
+		"AUTOFIX: ~/wip/package/file4.mk:1: Inserting a line \"# $"+"NetBSD$\" before this line.",
+		"AUTOFIX: ~/wip/package/file5.mk:1: Inserting a line \"# $"+"NetBSD$\" before this line.")
 }