Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/pkgsrc/pkgtools/pkglint/files/Attic/pkglint_test.go,v rcsdiff: /ftp/cvs/cvsroot/pkgsrc/pkgtools/pkglint/files/Attic/pkglint_test.go,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.28 retrieving revision 1.29 diff -u -p -r1.28 -r1.29 --- pkgsrc/pkgtools/pkglint/files/Attic/pkglint_test.go 2018/12/02 01:57:48 1.28 +++ pkgsrc/pkgtools/pkglint/files/Attic/pkglint_test.go 2018/12/17 00:15:39 1.29 @@ -1,4 +1,4 @@ -package main +package pkglint import ( "io/ioutil" @@ -44,8 +44,8 @@ func (s *Suite) Test_Pkglint_Main__only( exitcode := G.ParseCommandLine([]string{"pkglint", "-Wall", "-o", ":Q", "--version"}) - if c.Check(exitcode, check.NotNil) { - c.Check(*exitcode, equals, 0) + if exitcode != -1 { + c.Check(exitcode, equals, 0) } c.Check(G.Opts.LogOnly, deepEquals, []string{":Q"}) t.CheckOutputLines( @@ -337,7 +337,7 @@ func (s *Suite) Test_Pkglint_CheckDirent "WARN: ~/category/package/Makefile: Neither PLIST nor PLIST.common exist, and PLIST_SRC is unset.", "WARN: ~/category/package/distinfo: File not found. Please run \""+confMake+" makesum\" or define NO_CHECKSUM=yes in the package Makefile.", "ERROR: ~/category/package/Makefile: Each package must define its LICENSE.", - "WARN: ~/category/package/Makefile: No COMMENT given.") + "WARN: ~/category/package/Makefile: Each package should define a COMMENT.") } func (s *Suite) Test_Pkglint_CheckDirent(c *check.C) { @@ -384,9 +384,9 @@ func (s *Suite) Test_resolveVariableRefs func (s *Suite) Test_resolveVariableRefs__multilevel(c *check.C) { t := s.Init(c) - mkline1 := t.NewMkLine("filename", 10, "_=${SECOND}") - mkline2 := t.NewMkLine("filename", 11, "_=${THIRD}") - mkline3 := t.NewMkLine("filename", 12, "_=got it") + mkline1 := t.NewMkLine("filename", 10, "FIRST=\t${SECOND}") + mkline2 := t.NewMkLine("filename", 11, "SECOND=\t${THIRD}") + mkline3 := t.NewMkLine("filename", 12, "THIRD=\tgot it") G.Pkg = NewPackage(t.File("category/pkgbase")) defineVar(mkline1, "FIRST") defineVar(mkline2, "SECOND") @@ -880,6 +880,9 @@ func (s *Suite) Test_Pkglint_checkMode__ "ERROR: device: Only files and directories are allowed in pkgsrc.") } +// A package that is very incomplete may produce lots of warnings. +// This case is unrealistic since most packages are either generated by url2pkg +// or copied from an existing working package. func (s *Suite) Test_Pkglint_checkdirPackage(c *check.C) { t := s.Init(c) @@ -893,7 +896,7 @@ func (s *Suite) Test_Pkglint_checkdirPac "WARN: Makefile: Neither PLIST nor PLIST.common exist, and PLIST_SRC is unset.", "WARN: distinfo: File not found. Please run \""+confMake+" makesum\" or define NO_CHECKSUM=yes in the package Makefile.", "ERROR: Makefile: Each package must define its LICENSE.", - "WARN: Makefile: No COMMENT given.") + "WARN: Makefile: Each package should define a COMMENT.") } func (s *Suite) Test_Pkglint_checkdirPackage__PKGDIR(c *check.C) { @@ -923,8 +926,8 @@ func (s *Suite) Test_Pkglint_checkdirPac "LICENSE=\t2-clause-bsd", "PKGDIR=\t\t../../other/package") - // DISTINFO_FILE is resolved relative to PKGDIR, the other places - // are resolved relative to the package base directory. + // DISTINFO_FILE is resolved relative to PKGDIR, + // the other locations are resolved relative to the package base directory. G.checkdirPackage(".") t.CheckOutputLines( @@ -942,8 +945,11 @@ func (s *Suite) Test_Pkglint_checkdirPac // FIXME: One of the below warnings is redundant. t.CheckOutputLines( - "WARN: ~/category/package/distinfo: File not found. Please run \""+confMake+" makesum\" or define NO_CHECKSUM=yes in the package Makefile.", - "WARN: ~/category/package/distinfo: File not found. Please run \""+confMake+" makepatchsum\".") + "WARN: ~/category/package/distinfo: File not found. "+ + "Please run \""+confMake+" makesum\" "+ + "or define NO_CHECKSUM=yes in the package Makefile.", + "WARN: ~/category/package/distinfo: File not found. "+ + "Please run \""+confMake+" makepatchsum\".") } func (s *Suite) Test_Pkglint_checkdirPackage__meta_package_without_license(c *check.C) { @@ -958,14 +964,15 @@ func (s *Suite) Test_Pkglint_checkdirPac G.checkdirPackage(".") + // No error about missing LICENSE since meta-packages don't need a license. + // They are so simple that there is no reason to have any license. t.CheckOutputLines( - "WARN: Makefile: No COMMENT given.") // No error about missing LICENSE. + "WARN: Makefile: Each package should define a COMMENT.") } func (s *Suite) Test_Pkglint_checkdirPackage__filename_with_variable(c *check.C) { t := s.Init(c) - t.SetupCommandLine("-Wall,no-order") pkg := t.SetupPackage("category/package", ".include \"../../mk/bsd.prefs.mk\"", "", @@ -981,6 +988,7 @@ func (s *Suite) Test_Pkglint_checkdirPac // because the variable \"rv\" comes from a .for loop. // // TODO: iterate over variables in simple .for loops like the above. + // TODO: when implementing the above, take care of deeply nested loops (42.zip). G.CheckDirent(pkg) t.CheckOutputEmpty() @@ -1043,7 +1051,7 @@ func (s *Suite) Test_Pkglint_checkExecut // See the "Too late" comment in Pkglint.checkExecutable. t.CheckOutputEmpty() } -func (s *Suite) Test_main(c *check.C) { +func (s *Suite) Test_Main(c *check.C) { t := s.Init(c) out, err := os.Create(t.CreateFileLines("out")) @@ -1058,21 +1066,17 @@ func (s *Suite) Test_main(c *check.C) { args := os.Args stdout := os.Stdout stderr := os.Stderr - prevExit := exit defer func() { os.Stderr = stderr os.Stdout = stdout os.Args = args - exit = prevExit }() os.Args = commandLine os.Stdout = out os.Stderr = out - exit = func(code int) { - c.Check(code, equals, 0) - } - main() + exitCode := Main() + c.Check(exitCode, equals, 0) } runMain(out, "pkglint", ".")