pkgtools/pkglint: update to 5.7.17 Changes since 5.7.16: * The warnings for doc/CHANGES are only enabled when the -Cglobal option is given. This is to avoid warnings that are unrelated to the package that is being checked.diff -r1.588 -r1.589 pkgsrc/pkgtools/pkglint/Makefile
(rillig)
@@ -1,16 +1,16 @@ | @@ -1,16 +1,16 @@ | |||
1 | # $NetBSD: Makefile,v 1.588 2019/07/14 21:25:47 rillig Exp $ | 1 | # $NetBSD: Makefile,v 1.589 2019/07/30 18:16:13 rillig Exp $ | |
2 | 2 | |||
3 | PKGNAME= pkglint-5.7.16 | 3 | PKGNAME= pkglint-5.7.17 | |
4 | CATEGORIES= pkgtools | 4 | CATEGORIES= pkgtools | |
5 | DISTNAME= tools | 5 | DISTNAME= tools | |
6 | MASTER_SITES= ${MASTER_SITE_GITHUB:=golang/} | 6 | MASTER_SITES= ${MASTER_SITE_GITHUB:=golang/} | |
7 | GITHUB_PROJECT= tools | 7 | GITHUB_PROJECT= tools | |
8 | GITHUB_TAG= 92d8274bd7b8a4c65f24bafe401a029e58392704 | 8 | GITHUB_TAG= 92d8274bd7b8a4c65f24bafe401a029e58392704 | |
9 | 9 | |||
10 | MAINTAINER= rillig@NetBSD.org | 10 | MAINTAINER= rillig@NetBSD.org | |
11 | HOMEPAGE= https://github.com/rillig/pkglint | 11 | HOMEPAGE= https://github.com/rillig/pkglint | |
12 | COMMENT= Verifier for NetBSD packages | 12 | COMMENT= Verifier for NetBSD packages | |
13 | LICENSE= 2-clause-bsd | 13 | LICENSE= 2-clause-bsd | |
14 | CONFLICTS+= pkglint4-[0-9]* | 14 | CONFLICTS+= pkglint4-[0-9]* | |
15 | 15 | |||
16 | USE_TOOLS+= pax | 16 | USE_TOOLS+= pax |
@@ -58,27 +58,28 @@ func (s *Suite) SetUpTest(c *check.C) { | @@ -58,27 +58,28 @@ func (s *Suite) SetUpTest(c *check.C) { | |||
58 | s.Tester = &t | 58 | s.Tester = &t | |
59 | 59 | |||
60 | G = NewPkglint() | 60 | G = NewPkglint() | |
61 | G.Testing = true | 61 | G.Testing = true | |
62 | G.Logger.out = NewSeparatorWriter(&t.stdout) | 62 | G.Logger.out = NewSeparatorWriter(&t.stdout) | |
63 | G.Logger.err = NewSeparatorWriter(&t.stderr) | 63 | G.Logger.err = NewSeparatorWriter(&t.stderr) | |
64 | trace.Out = &t.stdout | 64 | trace.Out = &t.stdout | |
65 | 65 | |||
66 | // XXX: Maybe the tests can run a bit faster when they don't | 66 | // XXX: Maybe the tests can run a bit faster when they don't | |
67 | // create a temporary directory each. | 67 | // create a temporary directory each. | |
68 | G.Pkgsrc = NewPkgsrc(t.File(".")) | 68 | G.Pkgsrc = NewPkgsrc(t.File(".")) | |
69 | 69 | |||
70 | t.c = c | 70 | t.c = c | |
71 | t.SetUpCommandLine("-Wall") // To catch duplicate warnings | 71 | t.SetUpCommandLine("-Wall") // To catch duplicate warnings | |
72 | t.seenSetUpCommandLine = false // This default call doesn't count. | |||
72 | 73 | |||
73 | // To improve code coverage and ensure that trace.Result works | 74 | // To improve code coverage and ensure that trace.Result works | |
74 | // in all cases. The latter cannot be ensured at compile time. | 75 | // in all cases. The latter cannot be ensured at compile time. | |
75 | t.EnableSilentTracing() | 76 | t.EnableSilentTracing() | |
76 | 77 | |||
77 | prevdir, err := os.Getwd() | 78 | prevdir, err := os.Getwd() | |
78 | assertNil(err, "Cannot get current working directory: %s", err) | 79 | assertNil(err, "Cannot get current working directory: %s", err) | |
79 | t.prevdir = prevdir | 80 | t.prevdir = prevdir | |
80 | 81 | |||
81 | // No longer usable; see https://github.com/go-check/check/issues/22 | 82 | // No longer usable; see https://github.com/go-check/check/issues/22 | |
82 | t.c = nil | 83 | t.c = nil | |
83 | } | 84 | } | |
84 | 85 | |||
@@ -121,54 +122,57 @@ func Test(t *testing.T) { check.TestingT | @@ -121,54 +122,57 @@ func Test(t *testing.T) { check.TestingT | |||
121 | // It is separated from the Suite since the latter contains | 122 | // It is separated from the Suite since the latter contains | |
122 | // all the test methods, which makes it difficult to find | 123 | // all the test methods, which makes it difficult to find | |
123 | // a method by auto-completion. | 124 | // a method by auto-completion. | |
124 | type Tester struct { | 125 | type Tester struct { | |
125 | c *check.C // Only usable during the test method itself | 126 | c *check.C // Only usable during the test method itself | |
126 | testName string | 127 | testName string | |
127 | 128 | |||
128 | stdout bytes.Buffer | 129 | stdout bytes.Buffer | |
129 | stderr bytes.Buffer | 130 | stderr bytes.Buffer | |
130 | tmpdir string | 131 | tmpdir string | |
131 | prevdir string // The current working directory before the test started | 132 | prevdir string // The current working directory before the test started | |
132 | relCwd string // See Tester.Chdir | 133 | relCwd string // See Tester.Chdir | |
133 | 134 | |||
134 | seenSetupPkgsrc int | 135 | seenSetUpCommandLine bool | |
135 | seenFinish bool | 136 | seenSetupPkgsrc int | |
136 | seenMain bool | 137 | seenFinish bool | |
138 | seenMain bool | |||
137 | } | 139 | } | |
138 | 140 | |||
139 | // SetUpCommandLine simulates a command line for the remainder of the test. | 141 | // SetUpCommandLine simulates a command line for the remainder of the test. | |
140 | // See Pkglint.ParseCommandLine. | 142 | // See Pkglint.ParseCommandLine. | |
141 | // | 143 | // | |
142 | // If SetUpCommandLine is not called explicitly in a test, the command line | 144 | // If SetUpCommandLine is not called explicitly in a test, the command line | |
143 | // "-Wall" is used, to provide a high code coverage in the tests. | 145 | // "-Wall" is used, to provide a high code coverage in the tests. | |
144 | func (t *Tester) SetUpCommandLine(args ...string) { | 146 | func (t *Tester) SetUpCommandLine(args ...string) { | |
145 | 147 | |||
146 | // Prevent tracing from being disabled; see EnableSilentTracing. | 148 | // Prevent tracing from being disabled; see EnableSilentTracing. | |
147 | prevTracing := trace.Tracing | 149 | prevTracing := trace.Tracing | |
148 | defer func() { trace.Tracing = prevTracing }() | 150 | defer func() { trace.Tracing = prevTracing }() | |
149 | 151 | |||
150 | exitcode := G.ParseCommandLine(append([]string{"pkglint"}, args...)) | 152 | exitcode := G.ParseCommandLine(append([]string{"pkglint"}, args...)) | |
151 | if exitcode != -1 && exitcode != 0 { | 153 | if exitcode != -1 && exitcode != 0 { | |
152 | t.CheckOutputEmpty() | 154 | t.CheckOutputEmpty() | |
153 | t.c.Fatalf("Cannot parse command line: %#v", args) | 155 | t.c.Fatalf("Cannot parse command line: %#v", args) | |
154 | } | 156 | } | |
155 | 157 | |||
156 | // Duplicate diagnostics often mean that the checking code is run | 158 | // Duplicate diagnostics often mean that the checking code is run | |
157 | // twice, which is unnecessary. | 159 | // twice, which is unnecessary. | |
158 | // | 160 | // | |
159 | // It also reveals diagnostics that are logged multiple times per | 161 | // It also reveals diagnostics that are logged multiple times per | |
160 | // line and thus can easily get annoying to the pkgsrc developers. | 162 | // line and thus can easily get annoying to the pkgsrc developers. | |
161 | G.Logger.Opts.LogVerbose = true | 163 | G.Logger.Opts.LogVerbose = true | |
164 | ||||
165 | t.seenSetUpCommandLine = true | |||
162 | } | 166 | } | |
163 | 167 | |||
164 | // SetUpVartypes registers a few hundred variables like MASTER_SITES, | 168 | // SetUpVartypes registers a few hundred variables like MASTER_SITES, | |
165 | // WRKSRC, SUBST_SED.*, so that their data types are known to pkglint. | 169 | // WRKSRC, SUBST_SED.*, so that their data types are known to pkglint. | |
166 | // | 170 | // | |
167 | // Without calling this, there will be many warnings about undefined | 171 | // Without calling this, there will be many warnings about undefined | |
168 | // or unused variables, or unknown shell commands. | 172 | // or unused variables, or unknown shell commands. | |
169 | // | 173 | // | |
170 | // See SetUpTool for registering tools like echo, awk, perl. | 174 | // See SetUpTool for registering tools like echo, awk, perl. | |
171 | func (t *Tester) SetUpVartypes() { | 175 | func (t *Tester) SetUpVartypes() { | |
172 | G.Pkgsrc.vartypes.Init(&G.Pkgsrc) | 176 | G.Pkgsrc.vartypes.Init(&G.Pkgsrc) | |
173 | } | 177 | } | |
174 | 178 | |||
@@ -663,26 +667,30 @@ func (t *Tester) FinishSetUp() { | @@ -663,26 +667,30 @@ func (t *Tester) FinishSetUp() { | |||
663 | t.Errorf("Redundant t.FinishSetup() since it was called multiple times.") | 667 | t.Errorf("Redundant t.FinishSetup() since it was called multiple times.") | |
664 | } | 668 | } | |
665 | } | 669 | } | |
666 | 670 | |||
667 | // Main runs the pkglint main program with the given command line arguments. | 671 | // Main runs the pkglint main program with the given command line arguments. | |
668 | // | 672 | // | |
669 | // Arguments that name existing files or directories in the temporary test | 673 | // Arguments that name existing files or directories in the temporary test | |
670 | // directory are transformed to their actual paths. | 674 | // directory are transformed to their actual paths. | |
671 | func (t *Tester) Main(args ...string) int { | 675 | func (t *Tester) Main(args ...string) int { | |
672 | if t.seenFinish && !t.seenMain { | 676 | if t.seenFinish && !t.seenMain { | |
673 | t.Errorf("Calling t.FinishSetup() before t.Main() is redundant " + | 677 | t.Errorf("Calling t.FinishSetup() before t.Main() is redundant " + | |
674 | "since t.Main() loads the pkgsrc infrastructure.") | 678 | "since t.Main() loads the pkgsrc infrastructure.") | |
675 | } | 679 | } | |
680 | if t.seenSetUpCommandLine { | |||
681 | t.Errorf("Calling t.SetupCommandLine() before t.Main() is redundant " + | |||
682 | "since t.Main() accepts the command line options directly.") | |||
683 | } | |||
676 | 684 | |||
677 | t.seenMain = true | 685 | t.seenMain = true | |
678 | 686 | |||
679 | // Reset the logger, for tests where t.Main is called multiple times. | 687 | // Reset the logger, for tests where t.Main is called multiple times. | |
680 | G.Logger.errors = 0 | 688 | G.Logger.errors = 0 | |
681 | G.Logger.warnings = 0 | 689 | G.Logger.warnings = 0 | |
682 | G.Logger.logged = Once{} | 690 | G.Logger.logged = Once{} | |
683 | 691 | |||
684 | argv := []string{"pkglint"} | 692 | argv := []string{"pkglint"} | |
685 | for _, arg := range args { | 693 | for _, arg := range args { | |
686 | fileArg := t.File(arg) | 694 | fileArg := t.File(arg) | |
687 | _, err := os.Lstat(fileArg) | 695 | _, err := os.Lstat(fileArg) | |
688 | if err == nil { | 696 | if err == nil { |
@@ -1504,37 +1504,37 @@ func (s *Suite) Test_MkLine_ResolveVarsI | @@ -1504,37 +1504,37 @@ func (s *Suite) Test_MkLine_ResolveVarsI | |||
1504 | 1504 | |||
1505 | test("${FILESDIR}", "files") | 1505 | test("${FILESDIR}", "files") | |
1506 | test("${PKGDIR}", ".") | 1506 | test("${PKGDIR}", ".") | |
1507 | 1507 | |||
1508 | // Just for branch coverage. | 1508 | // Just for branch coverage. | |
1509 | G.Testing = false | 1509 | G.Testing = false | |
1510 | test("${PKGSRCDIR}", "../..") | 1510 | test("${PKGSRCDIR}", "../..") | |
1511 | } | 1511 | } | |
1512 | 1512 | |||
1513 | func (s *Suite) Test_MkLine_ResolveVarsInRelativePath__directory_depth(c *check.C) { | 1513 | func (s *Suite) Test_MkLine_ResolveVarsInRelativePath__directory_depth(c *check.C) { | |
1514 | t := s.Init(c) | 1514 | t := s.Init(c) | |
1515 | 1515 | |||
1516 | t.SetUpVartypes() | 1516 | t.SetUpVartypes() | |
1517 | mklines := t.SetUpFileMkLines("multimedia/totem/bla.mk", | 1517 | mklines := t.SetUpFileMkLines("multimedia/totem/filename.mk", | |
1518 | MkCvsID, | 1518 | MkCvsID, | |
1519 | "BUILDLINK_PKGSRCDIR.totem?=\t../../multimedia/totem") | 1519 | "BUILDLINK_PKGSRCDIR.totem?=\t../../multimedia/totem") | |
1520 | 1520 | |||
1521 | mklines.Check() | 1521 | mklines.Check() | |
1522 | 1522 | |||
1523 | t.CheckOutputLines( | 1523 | t.CheckOutputLines( | |
1524 | "WARN: ~/multimedia/totem/bla.mk:2: "+ | 1524 | "WARN: ~/multimedia/totem/filename.mk:2: "+ | |
1525 | "The variable BUILDLINK_PKGSRCDIR.totem should not be given a default value in this file; "+ | 1525 | "The variable BUILDLINK_PKGSRCDIR.totem should not be given a default value in this file; "+ | |
1526 | "it would be ok in buildlink3.mk.", | 1526 | "it would be ok in buildlink3.mk.", | |
1527 | "ERROR: ~/multimedia/totem/bla.mk:2: Relative path \"../../multimedia/totem/Makefile\" does not exist.") | 1527 | "ERROR: ~/multimedia/totem/filename.mk:2: Relative path \"../../multimedia/totem/Makefile\" does not exist.") | |
1528 | } | 1528 | } | |
1529 | 1529 | |||
1530 | // Just for code coverage | 1530 | // Just for code coverage | |
1531 | func (s *Suite) Test_MkLine_ResolveVarsInRelativePath__without_tracing(c *check.C) { | 1531 | func (s *Suite) Test_MkLine_ResolveVarsInRelativePath__without_tracing(c *check.C) { | |
1532 | t := s.Init(c) | 1532 | t := s.Init(c) | |
1533 | 1533 | |||
1534 | t.DisableTracing() | 1534 | t.DisableTracing() | |
1535 | t.SetUpVartypes() | 1535 | t.SetUpVartypes() | |
1536 | mklines := t.SetUpFileMkLines("buildlink3.mk", | 1536 | mklines := t.SetUpFileMkLines("buildlink3.mk", | |
1537 | MkCvsID, | 1537 | MkCvsID, | |
1538 | "BUILDLINK_PKGSRCDIR.totem?=\t../../${PKGPATH.multimedia/totem}") | 1538 | "BUILDLINK_PKGSRCDIR.totem?=\t../../${PKGPATH.multimedia/totem}") | |
1539 | 1539 | |||
1540 | mklines.Check() | 1540 | mklines.Check() |
@@ -1145,27 +1145,26 @@ func (s *Suite) Test_MkLines_Check__auto | @@ -1145,27 +1145,26 @@ func (s *Suite) Test_MkLines_Check__auto | |||
1145 | t.SetUpCommandLine("-Wall") | 1145 | t.SetUpCommandLine("-Wall") | |
1146 | test( | 1146 | test( | |
1147 | "WARN: Makefile:7: HOMEPAGE should not be defined in terms of MASTER_SITEs.") | 1147 | "WARN: Makefile:7: HOMEPAGE should not be defined in terms of MASTER_SITEs.") | |
1148 | 1148 | |||
1149 | t.SetUpCommandLine("-Wall", "--autofix") | 1149 | t.SetUpCommandLine("-Wall", "--autofix") | |
1150 | test( | 1150 | test( | |
1151 | nil...) | 1151 | nil...) | |
1152 | 1152 | |||
1153 | } | 1153 | } | |
1154 | 1154 | |||
1155 | func (s *Suite) Test_MkLines_Check__autofix_MASTER_SITE_in_HOMEPAGE_in_package(c *check.C) { | 1155 | func (s *Suite) Test_MkLines_Check__autofix_MASTER_SITE_in_HOMEPAGE_in_package(c *check.C) { | |
1156 | t := s.Init(c) | 1156 | t := s.Init(c) | |
1157 | 1157 | |||
1158 | t.SetUpCommandLine("-Wall", "--autofix") | |||
1159 | t.SetUpPackage("category/package", | 1158 | t.SetUpPackage("category/package", | |
1160 | "MASTER_SITES=\thttps://cdn1.example.org/ https://cdn2.example.org/", | 1159 | "MASTER_SITES=\thttps://cdn1.example.org/ https://cdn2.example.org/", | |
1161 | "HOMEPAGE=\t${MASTER_SITES}") | 1160 | "HOMEPAGE=\t${MASTER_SITES}") | |
1162 | 1161 | |||
1163 | t.Main("-Wall", "-q", "category/package") | 1162 | t.Main("-Wall", "-q", "category/package") | |
1164 | 1163 | |||
1165 | // When MASTER_SITES consists of several URLs, take the first one, | 1164 | // When MASTER_SITES consists of several URLs, take the first one, | |
1166 | // assuming that it is the most appropriate. | 1165 | // assuming that it is the most appropriate. | |
1167 | t.CheckOutputLines( | 1166 | t.CheckOutputLines( | |
1168 | "WARN: ~/category/package/Makefile:9: " + | 1167 | "WARN: ~/category/package/Makefile:9: " + | |
1169 | "HOMEPAGE should not be defined in terms of MASTER_SITEs. " + | 1168 | "HOMEPAGE should not be defined in terms of MASTER_SITEs. " + | |
1170 | "Use https://cdn1.example.org/ directly.") | 1169 | "Use https://cdn1.example.org/ directly.") | |
1171 | 1170 |
@@ -491,27 +491,27 @@ func (*Pkgsrc) parseDocChange(line *Line | @@ -491,27 +491,27 @@ func (*Pkgsrc) parseDocChange(line *Line | |||
491 | } | 491 | } | |
492 | 492 | |||
493 | if warn { | 493 | if warn { | |
494 | line.Warnf("Unknown doc/CHANGES line: %s", line.Text) | 494 | line.Warnf("Unknown doc/CHANGES line: %s", line.Text) | |
495 | line.Explain( | 495 | line.Explain( | |
496 | "See mk/misc/developer.mk for the rules.") | 496 | "See mk/misc/developer.mk for the rules.") | |
497 | } | 497 | } | |
498 | 498 | |||
499 | return nil | 499 | return nil | |
500 | } | 500 | } | |
501 | 501 | |||
502 | func (src *Pkgsrc) loadDocChangesFromFile(filename string) []*Change { | 502 | func (src *Pkgsrc) loadDocChangesFromFile(filename string) []*Change { | |
503 | 503 | |||
504 | warn := !G.Wip | 504 | warn := G.Opts.CheckGlobal && !G.Wip | |
505 | 505 | |||
506 | // Each date in the file should be from the same year as the filename says. | 506 | // Each date in the file should be from the same year as the filename says. | |
507 | // This check has been added in 2018. | 507 | // This check has been added in 2018. | |
508 | // For years earlier than 2018 pkglint doesn't care because it's not a big issue anyway. | 508 | // For years earlier than 2018 pkglint doesn't care because it's not a big issue anyway. | |
509 | year := "" | 509 | year := "" | |
510 | if _, yyyy := match1(filename, `-(\d\d\d\d)$`); yyyy >= "2018" { | 510 | if _, yyyy := match1(filename, `-(\d\d\d\d)$`); yyyy >= "2018" { | |
511 | year = yyyy | 511 | year = yyyy | |
512 | } | 512 | } | |
513 | 513 | |||
514 | infra := false | 514 | infra := false | |
515 | lines := Load(filename, MustSucceed|NotEmpty) | 515 | lines := Load(filename, MustSucceed|NotEmpty) | |
516 | var changes []*Change | 516 | var changes []*Change | |
517 | for _, line := range lines.Lines { | 517 | for _, line := range lines.Lines { |
@@ -330,26 +330,27 @@ func (s *Suite) Test_Pkgsrc_loadDocChang | @@ -330,26 +330,27 @@ func (s *Suite) Test_Pkgsrc_loadDocChang | |||
330 | t.SetUpPkgsrc() | 330 | t.SetUpPkgsrc() | |
331 | t.Remove("doc/CHANGES-2018") | 331 | t.Remove("doc/CHANGES-2018") | |
332 | t.Remove("doc/TODO") | 332 | t.Remove("doc/TODO") | |
333 | t.Remove("doc") | 333 | t.Remove("doc") | |
334 | 334 | |||
335 | t.ExpectFatal( | 335 | t.ExpectFatal( | |
336 | t.FinishSetUp, | 336 | t.FinishSetUp, | |
337 | "FATAL: ~/doc: Cannot be read for loading the package changes.") | 337 | "FATAL: ~/doc: Cannot be read for loading the package changes.") | |
338 | } | 338 | } | |
339 | 339 | |||
340 | func (s *Suite) Test_Pkgsrc_loadDocChangesFromFile(c *check.C) { | 340 | func (s *Suite) Test_Pkgsrc_loadDocChangesFromFile(c *check.C) { | |
341 | t := s.Init(c) | 341 | t := s.Init(c) | |
342 | 342 | |||
343 | t.SetUpCommandLine("-Cglobal", "-Wall") | |||
343 | t.CreateFileLines("doc/CHANGES-2018", | 344 | t.CreateFileLines("doc/CHANGES-2018", | |
344 | "\tAdded category/package version 1.0 [author1 2015-01-01]", // Wrong year | 345 | "\tAdded category/package version 1.0 [author1 2015-01-01]", // Wrong year | |
345 | "\tUpdated category/package to 1.5 [author2 2018-01-02]", | 346 | "\tUpdated category/package to 1.5 [author2 2018-01-02]", | |
346 | "\tRenamed category/package to category/pkg [author3 2018-01-03]", | 347 | "\tRenamed category/package to category/pkg [author3 2018-01-03]", | |
347 | "\tMoved category/package to other/package [author4 2018-01-04]", | 348 | "\tMoved category/package to other/package [author4 2018-01-04]", | |
348 | "\tRemoved category/package [author5 2018-01-09]", // Too far in the future | 349 | "\tRemoved category/package [author5 2018-01-09]", // Too far in the future | |
349 | "\tRemoved category/package successor category/package2 [author6 2018-01-06]", | 350 | "\tRemoved category/package successor category/package2 [author6 2018-01-06]", | |
350 | "\tDowngraded category/package to 1.2 [author7 2018-01-07]", | 351 | "\tDowngraded category/package to 1.2 [author7 2018-01-07]", | |
351 | "\tReworked category/package to 1.2 [author8 2018-01-08]", | 352 | "\tReworked category/package to 1.2 [author8 2018-01-08]", | |
352 | "", | 353 | "", | |
353 | "\ttoo few fields", | 354 | "\ttoo few fields", | |
354 | "\ttoo many many many many many fields", | 355 | "\ttoo many many many many many fields", | |
355 | "\tmissing brackets around author", | 356 | "\tmissing brackets around author", | |
@@ -400,45 +401,84 @@ func (s *Suite) Test_Pkgsrc_loadDocChang | @@ -400,45 +401,84 @@ func (s *Suite) Test_Pkgsrc_loadDocChang | |||
400 | t := s.Init(c) | 401 | t := s.Init(c) | |
401 | 402 | |||
402 | t.SetUpPackage("wip/package") | 403 | t.SetUpPackage("wip/package") | |
403 | t.CreateFileLines("doc/CHANGES-2018", | 404 | t.CreateFileLines("doc/CHANGES-2018", | |
404 | CvsID, | 405 | CvsID, | |
405 | "", | 406 | "", | |
406 | "Changes to the packages collection and infrastructure in 2018:", | 407 | "Changes to the packages collection and infrastructure in 2018:", | |
407 | "", | 408 | "", | |
408 | "\tUpdated sysutils/checkperms to 1.10 [rillig 2018-01-05]", | 409 | "\tUpdated sysutils/checkperms to 1.10 [rillig 2018-01-05]", | |
409 | "\tUpdated sysutils/checkperms to 1.11 [rillig 2018-01-01]", | 410 | "\tUpdated sysutils/checkperms to 1.11 [rillig 2018-01-01]", | |
410 | "\t\tWrong indentation", | 411 | "\t\tWrong indentation", | |
411 | "\tInvalid pkgpath to 1.16 [rillig 2019-06-16]") | 412 | "\tInvalid pkgpath to 1.16 [rillig 2019-06-16]") | |
412 | 413 | |||
413 | t.Main(t.File("wip/package")) | 414 | t.Main("-Cglobal", "-Wall", "wip/package") | |
414 | 415 | |||
415 | t.CheckOutputLines( | 416 | t.CheckOutputLines( | |
416 | "Looks fine.") | 417 | "Looks fine.") | |
417 | } | 418 | } | |
418 | 419 | |||
420 | // When a single package is checked, only the lines from doc/CHANGES | |||
421 | // that are related to that package are shown. The others are too | |||
422 | // unrelated. | |||
423 | func (s *Suite) Test_Pkgsrc_loadDocChangesFromFile__default(c *check.C) { | |||
424 | t := s.Init(c) | |||
425 | ||||
426 | t.SetUpPackage("category/package") | |||
427 | t.CreateFileLines("doc/CHANGES-2018", | |||
428 | CvsID, | |||
429 | "", | |||
430 | "Changes to the packages collection and infrastructure in 2018:", | |||
431 | "", | |||
432 | "\tUpdated sysutils/checkperms to 1.10 [rillig 2018-01-05]", | |||
433 | "\tUpdated sysutils/checkperms to 1.11 [rillig 2018-01-01]", | |||
434 | "\t\tWrong indentation", | |||
435 | "\tInvalid pkgpath to 1.16 [rillig 2019-06-16]", | |||
436 | "\tUpdated category/package to 2.0 [rillig 2019-07-24]") | |||
437 | t.CreateFileLines("Makefile", | |||
438 | MkCvsID) | |||
439 | ||||
440 | t.Main("category/package") | |||
441 | ||||
442 | t.CheckOutputLines( | |||
443 | "WARN: ~/category/package/Makefile:3: The package is being downgraded from 2.0 (see ../../doc/CHANGES-2018:9) to 1.0.", | |||
444 | "1 warning found.", | |||
445 | "(Run \"pkglint -e\" to show explanations.)") | |||
446 | ||||
447 | // Only when the global checks are enabled, the errors from doc/CHANGES are shown. | |||
448 | t.Main("-Cglobal", "-Wall", ".") | |||
449 | ||||
450 | t.CheckOutputLines( | |||
451 | "WARN: ~/doc/CHANGES-2018:6: Date \"2018-01-01\" for sysutils/checkperms is earlier than \"2018-01-05\" in line 5.", | |||
452 | "WARN: ~/doc/CHANGES-2018:7: Package changes should be indented using a single tab, not \"\\t\\t\".", | |||
453 | "WARN: ~/doc/CHANGES-2018:8: Unknown doc/CHANGES line: \tInvalid pkgpath to 1.16 [rillig 2019-06-16]", | |||
454 | "WARN: ~/doc/CHANGES-2018:9: Year \"2019\" for category/package does not match the filename ~/doc/CHANGES-2018.", | |||
455 | "4 warnings found.", | |||
456 | "(Run \"pkglint -e\" to show explanations.)") | |||
457 | } | |||
458 | ||||
419 | func (s *Suite) Test_Pkgsrc_loadDocChangesFromFile__wrong_indentation(c *check.C) { | 459 | func (s *Suite) Test_Pkgsrc_loadDocChangesFromFile__wrong_indentation(c *check.C) { | |
420 | t := s.Init(c) | 460 | t := s.Init(c) | |
421 | 461 | |||
422 | t.SetUpPackage("category/package") | 462 | t.SetUpPackage("category/package") | |
423 | t.CreateFileLines("doc/CHANGES-2018", | 463 | t.CreateFileLines("doc/CHANGES-2018", | |
424 | CvsID, | 464 | CvsID, | |
425 | "", | 465 | "", | |
426 | "Changes to the packages collection and infrastructure in 2018:", | 466 | "Changes to the packages collection and infrastructure in 2018:", | |
427 | "", | 467 | "", | |
428 | " Updated sysutils/checkperms to 1.10 [rillig 2018-01-05]", | 468 | " Updated sysutils/checkperms to 1.10 [rillig 2018-01-05]", | |
429 | " \tUpdated sysutils/checkperms to 1.11 [rillig 2018-01-01]") | 469 | " \tUpdated sysutils/checkperms to 1.11 [rillig 2018-01-01]") | |
430 | 470 | |||
431 | t.Main(t.File("category/package")) | 471 | t.Main("-Cglobal", "-Wall", "category/package") | |
432 | 472 | |||
433 | t.CheckOutputLines( | 473 | t.CheckOutputLines( | |
434 | "WARN: ~/doc/CHANGES-2018:5: Package changes should be indented using a single tab, not \" \".", | 474 | "WARN: ~/doc/CHANGES-2018:5: Package changes should be indented using a single tab, not \" \".", | |
435 | "WARN: ~/doc/CHANGES-2018:6: Package changes should be indented using a single tab, not \" \\t\".", | 475 | "WARN: ~/doc/CHANGES-2018:6: Package changes should be indented using a single tab, not \" \\t\".", | |
436 | "2 warnings found.", | 476 | "2 warnings found.", | |
437 | "(Run \"pkglint -e\" to show explanations.)") | 477 | "(Run \"pkglint -e\" to show explanations.)") | |
438 | } | 478 | } | |
439 | 479 | |||
440 | // Once or twice in a decade, changes to the pkgsrc infrastructure are also | 480 | // Once or twice in a decade, changes to the pkgsrc infrastructure are also | |
441 | // documented in doc/CHANGES. These entries typically span multiple lines. | 481 | // documented in doc/CHANGES. These entries typically span multiple lines. | |
442 | func (s *Suite) Test_Pkgsrc_loadDocChangesFromFile__infrastructure(c *check.C) { | 482 | func (s *Suite) Test_Pkgsrc_loadDocChangesFromFile__infrastructure(c *check.C) { | |
443 | t := s.Init(c) | 483 | t := s.Init(c) | |
444 | 484 | |||
@@ -538,26 +578,27 @@ func (s *Suite) Test_Pkgsrc_parseDocChan | @@ -538,26 +578,27 @@ func (s *Suite) Test_Pkgsrc_parseDocChan | |||
538 | // "from" is wrong | 578 | // "from" is wrong | |
539 | test("\tMoved pkgpath from previous [author date]", | 579 | test("\tMoved pkgpath from previous [author date]", | |
540 | "WARN: doc/CHANGES-2019:123: Unknown doc/CHANGES line: \tMoved pkgpath from previous [author date]") | 580 | "WARN: doc/CHANGES-2019:123: Unknown doc/CHANGES line: \tMoved pkgpath from previous [author date]") | |
541 | 581 | |||
542 | // "Split" is wrong | 582 | // "Split" is wrong | |
543 | // TODO: Add a warning since this is probably a typo. | 583 | // TODO: Add a warning since this is probably a typo. | |
544 | test("\tSplit pkgpath into a and b [author date]", | 584 | test("\tSplit pkgpath into a and b [author date]", | |
545 | nil...) | 585 | nil...) | |
546 | } | 586 | } | |
547 | 587 | |||
548 | func (s *Suite) Test_Pkgsrc_loadDocChangesFromFile__old(c *check.C) { | 588 | func (s *Suite) Test_Pkgsrc_loadDocChangesFromFile__old(c *check.C) { | |
549 | t := s.Init(c) | 589 | t := s.Init(c) | |
550 | 590 | |||
591 | t.SetUpCommandLine("-Cglobal", "-Wall") | |||
551 | t.SetUpPkgsrc() | 592 | t.SetUpPkgsrc() | |
552 | t.CreateFileLines("doc/CHANGES-2010", | 593 | t.CreateFileLines("doc/CHANGES-2010", | |
553 | CvsID, | 594 | CvsID, | |
554 | "", | 595 | "", | |
555 | "Changes to the packages collection and infrastructure in 2015:", | 596 | "Changes to the packages collection and infrastructure in 2015:", | |
556 | "", | 597 | "", | |
557 | "\tInvalid line [3 4]") | 598 | "\tInvalid line [3 4]") | |
558 | t.CreateFileLines("doc/CHANGES-2015", | 599 | t.CreateFileLines("doc/CHANGES-2015", | |
559 | CvsID, | 600 | CvsID, | |
560 | "", | 601 | "", | |
561 | "Changes to the packages collection and infrastructure in 2015:", | 602 | "Changes to the packages collection and infrastructure in 2015:", | |
562 | "", | 603 | "", | |
563 | "\tUpdated pkgpath to 1.0 [author 2015-07-01]", | 604 | "\tUpdated pkgpath to 1.0 [author 2015-07-01]", |
@@ -492,28 +492,28 @@ func (cv *VartypeCheck) Enum(allowedValu | @@ -492,28 +492,28 @@ func (cv *VartypeCheck) Enum(allowedValu | |||
492 | } | 492 | } | |
493 | 493 | |||
494 | func (cv *VartypeCheck) FetchURL() { | 494 | func (cv *VartypeCheck) FetchURL() { | |
495 | 495 | |||
496 | // TODO: Handle leading "-". | 496 | // TODO: Handle leading "-". | |
497 | 497 | |||
498 | cv.URL() | 498 | cv.URL() | |
499 | 499 | |||
500 | for siteURL, siteName := range G.Pkgsrc.MasterSiteURLToVar { | 500 | for siteURL, siteName := range G.Pkgsrc.MasterSiteURLToVar { | |
501 | if hasPrefix(cv.Value, siteURL) { | 501 | if hasPrefix(cv.Value, siteURL) { | |
502 | subdir := cv.Value[len(siteURL):] | 502 | subdir := cv.Value[len(siteURL):] | |
503 | if hasPrefix(cv.Value, "https://github.com/") { | 503 | if hasPrefix(cv.Value, "https://github.com/") { | |
504 | subdir = strings.SplitAfter(subdir, "/")[0] | 504 | subdir = strings.SplitAfter(subdir, "/")[0] | |
505 | cv.Warnf("Please use ${%s:=%s} instead of %q and run %q for further tips.", | 505 | cv.Warnf("Please use ${%s:=%s} instead of %q and run %q for further instructions.", | |
506 | siteName, subdir, cv.Value, makeHelp("github")) | 506 | siteName, subdir, cv.Value[:len(siteURL)+len(subdir)], makeHelp("github")) | |
507 | } else { | 507 | } else { | |
508 | cv.Warnf("Please use ${%s:=%s} instead of %q.", siteName, subdir, cv.Value) | 508 | cv.Warnf("Please use ${%s:=%s} instead of %q.", siteName, subdir, cv.Value) | |
509 | } | 509 | } | |
510 | return | 510 | return | |
511 | } | 511 | } | |
512 | } | 512 | } | |
513 | 513 | |||
514 | tokens := cv.MkLine.Tokenize(cv.Value, false) | 514 | tokens := cv.MkLine.Tokenize(cv.Value, false) | |
515 | for _, token := range tokens { | 515 | for _, token := range tokens { | |
516 | varUse := token.Varuse | 516 | varUse := token.Varuse | |
517 | if varUse == nil { | 517 | if varUse == nil { | |
518 | continue | 518 | continue | |
519 | } | 519 | } |
@@ -480,28 +480,28 @@ func (s *Suite) Test_VartypeCheck_FetchU | @@ -480,28 +480,28 @@ func (s *Suite) Test_VartypeCheck_FetchU | |||
480 | G.Pkg.load() | 480 | G.Pkg.load() | |
481 | 481 | |||
482 | vt.Varname("MASTER_SITES") | 482 | vt.Varname("MASTER_SITES") | |
483 | vt.Values( | 483 | vt.Values( | |
484 | "https://github.com/example/project/", | 484 | "https://github.com/example/project/", | |
485 | "http://ftp.gnu.org/pub/gnu/bison", // Missing a slash at the end | 485 | "http://ftp.gnu.org/pub/gnu/bison", // Missing a slash at the end | |
486 | "${MASTER_SITE_GNU:=bison}", | 486 | "${MASTER_SITE_GNU:=bison}", | |
487 | "${MASTER_SITE_INVALID:=subdir/}", | 487 | "${MASTER_SITE_INVALID:=subdir/}", | |
488 | "${MASTER_SITE_OWN}", | 488 | "${MASTER_SITE_OWN}", | |
489 | "${MASTER_SITE_OWN:=subdir/}") | 489 | "${MASTER_SITE_OWN:=subdir/}") | |
490 | 490 | |||
491 | vt.Output( | 491 | vt.Output( | |
492 | "WARN: filename.mk:1: Please use ${MASTER_SITE_GITHUB:=example/} "+ | 492 | "WARN: filename.mk:1: Please use ${MASTER_SITE_GITHUB:=example/} "+ | |
493 | "instead of \"https://github.com/example/project/\" "+ | 493 | "instead of \"https://github.com/example/\" "+ | |
494 | "and run \""+confMake+" help topic=github\" for further tips.", | 494 | "and run \""+confMake+" help topic=github\" for further instructions.", | |
495 | "WARN: filename.mk:2: Please use ${MASTER_SITE_GNU:=bison} "+ | 495 | "WARN: filename.mk:2: Please use ${MASTER_SITE_GNU:=bison} "+ | |
496 | "instead of \"http://ftp.gnu.org/pub/gnu/bison\".", | 496 | "instead of \"http://ftp.gnu.org/pub/gnu/bison\".", | |
497 | "ERROR: filename.mk:3: The subdirectory in MASTER_SITE_GNU must end with a slash.", | 497 | "ERROR: filename.mk:3: The subdirectory in MASTER_SITE_GNU must end with a slash.", | |
498 | "ERROR: filename.mk:4: The site MASTER_SITE_INVALID does not exist.") | 498 | "ERROR: filename.mk:4: The site MASTER_SITE_INVALID does not exist.") | |
499 | 499 | |||
500 | // PR 46570, keyword gimp-fix-ca | 500 | // PR 46570, keyword gimp-fix-ca | |
501 | vt.Values( | 501 | vt.Values( | |
502 | "https://example.org/download.cgi?filename=filename&sha1=12341234") | 502 | "https://example.org/download.cgi?filename=filename&sha1=12341234") | |
503 | 503 | |||
504 | vt.OutputEmpty() | 504 | vt.OutputEmpty() | |
505 | 505 | |||
506 | vt.Values( | 506 | vt.Values( | |
507 | "http://example.org/distfiles/", | 507 | "http://example.org/distfiles/", | |
@@ -515,26 +515,33 @@ func (s *Suite) Test_VartypeCheck_FetchU | @@ -515,26 +515,33 @@ func (s *Suite) Test_VartypeCheck_FetchU | |||
515 | "${MASTER_SITE_GITHUB:S,^,-,:=project/archive/${DISTFILE}}") | 515 | "${MASTER_SITE_GITHUB:S,^,-,:=project/archive/${DISTFILE}}") | |
516 | 516 | |||
517 | // No warning that the part after the := must end with a slash, | 517 | // No warning that the part after the := must end with a slash, | |
518 | // since there is another modifier in the variable use, in this case :S. | 518 | // since there is another modifier in the variable use, in this case :S. | |
519 | // | 519 | // | |
520 | // That modifier adds a hyphen at the beginning (but pkglint doesn't | 520 | // That modifier adds a hyphen at the beginning (but pkglint doesn't | |
521 | // inspect this), therefore the URL is not required to end with a slash anymore. | 521 | // inspect this), therefore the URL is not required to end with a slash anymore. | |
522 | vt.OutputEmpty() | 522 | vt.OutputEmpty() | |
523 | 523 | |||
524 | // As of June 2019, the :S modifier is not analyzed since it is unusual. | 524 | // As of June 2019, the :S modifier is not analyzed since it is unusual. | |
525 | vt.Values( | 525 | vt.Values( | |
526 | "${MASTER_SITE_GNU:S,$,subdir/,}") | 526 | "${MASTER_SITE_GNU:S,$,subdir/,}") | |
527 | vt.OutputEmpty() | 527 | vt.OutputEmpty() | |
528 | ||||
529 | vt.Values( | |||
530 | "https://github.com/transmission/transmission-releases/raw/master/") | |||
531 | vt.Output( | |||
532 | "WARN: filename.mk:51: Please use ${MASTER_SITE_GITHUB:=transmission/} " + | |||
533 | "instead of \"https://github.com/transmission/\" " + | |||
534 | "and run \"" + confMake + " help topic=github\" for further instructions.") | |||
528 | } | 535 | } | |
529 | 536 | |||
530 | func (s *Suite) Test_VartypeCheck_FetchURL__without_package(c *check.C) { | 537 | func (s *Suite) Test_VartypeCheck_FetchURL__without_package(c *check.C) { | |
531 | t := s.Init(c) | 538 | t := s.Init(c) | |
532 | 539 | |||
533 | vt := NewVartypeCheckTester(t, (*VartypeCheck).FetchURL) | 540 | vt := NewVartypeCheckTester(t, (*VartypeCheck).FetchURL) | |
534 | 541 | |||
535 | vt.Varname("MASTER_SITES") | 542 | vt.Varname("MASTER_SITES") | |
536 | vt.Values( | 543 | vt.Values( | |
537 | "https://github.com/example/project/", | 544 | "https://github.com/example/project/", | |
538 | "${MASTER_SITE_OWN}") | 545 | "${MASTER_SITE_OWN}") | |
539 | 546 | |||
540 | vt.Output( | 547 | vt.Output( |