[BACK]Return to patches_test.go CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / pkgsrc / pkgtools / pkglint / files

Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.

Diff for /pkgsrc/pkgtools/pkglint/files/Attic/patches_test.go between version 1.16 and 1.17

version 1.16, 2018/02/19 12:40:38 version 1.17, 2018/07/28 18:31:23
Line 2  package main
Line 2  package main
   
 import "gopkg.in/check.v1"  import "gopkg.in/check.v1"
   
   // This is how each patch should look like.
 func (s *Suite) Test_ChecklinesPatch__with_comment(c *check.C) {  func (s *Suite) Test_ChecklinesPatch__with_comment(c *check.C) {
         t := s.Init(c)          t := s.Init(c)
   
Line 17  func (s *Suite) Test_ChecklinesPatch__wi
Line 18  func (s *Suite) Test_ChecklinesPatch__wi
                 "@@ -5,3 +5,3 @@",                  "@@ -5,3 +5,3 @@",
                 " context before",                  " context before",
                 "-old line",                  "-old line",
                 "+old line",                  "+new line",
                 " context after")                  " context after")
   
         ChecklinesPatch(lines)          ChecklinesPatch(lines)
Line 25  func (s *Suite) Test_ChecklinesPatch__wi
Line 26  func (s *Suite) Test_ChecklinesPatch__wi
         t.CheckOutputEmpty()          t.CheckOutputEmpty()
 }  }
   
   // To make the patch comment clearly visible, it should be surrounded by empty lines.
   // The missing empty lines are inserted by pkglint.
 func (s *Suite) Test_ChecklinesPatch__without_empty_line__autofix(c *check.C) {  func (s *Suite) Test_ChecklinesPatch__without_empty_line__autofix(c *check.C) {
         t := s.Init(c)          t := s.Init(c)
   
Line 36  func (s *Suite) Test_ChecklinesPatch__wi
Line 39  func (s *Suite) Test_ChecklinesPatch__wi
                 "@@ -5,3 +5,3 @@",                  "@@ -5,3 +5,3 @@",
                 " context before",                  " context before",
                 "-old line",                  "-old line",
                 "+old line",                  "+new line",
                 " context after")                  " context after")
         t.SetupFileLines("distinfo",          t.SetupFileLines("distinfo",
                 RcsID,                  RcsID,
                 "",                  "",
                 "SHA1 (some patch) = 87ffcaaa0b0677ec679fff612b44df1af05f04df") // Taken from breakpoint at AutofixDistinfo                  // The hash is taken from a breakpoint at the beginning of AutofixDistinfo, oldSha1
                   "SHA1 (some patch) = 49abd735b7e706ea9ed6671628bb54e91f7f5ffb")
   
         t.SetupCommandLine("-Wall", "--autofix")          t.SetupCommandLine("-Wall", "--autofix")
         G.CurrentDir = t.TmpDir()          G.CurrentDir = t.TmpDir()
Line 52  func (s *Suite) Test_ChecklinesPatch__wi
Line 56  func (s *Suite) Test_ChecklinesPatch__wi
         t.CheckOutputLines(          t.CheckOutputLines(
                 "AUTOFIX: ~/patch-WithoutEmptyLines:2: Inserting a line \"\" before this line.",                  "AUTOFIX: ~/patch-WithoutEmptyLines:2: Inserting a line \"\" before this line.",
                 "AUTOFIX: ~/patch-WithoutEmptyLines:3: Inserting a line \"\" before this line.",                  "AUTOFIX: ~/patch-WithoutEmptyLines:3: Inserting a line \"\" before this line.",
                 "AUTOFIX: ~/distinfo:3: Replacing \"87ffcaaa0b0677ec679fff612b44df1af05f04df\" "+                  "AUTOFIX: ~/distinfo:3: Replacing \"49abd735b7e706ea9ed6671628bb54e91f7f5ffb\" "+
                         "with \"a7c35294b3853da0acedf8a972cb266baa9582a3\".")                          "with \"4938fc8c0b483dc2e33e741b0da883d199e78164\".")
   
         t.CheckFileLines("patch-WithoutEmptyLines",          t.CheckFileLines("patch-WithoutEmptyLines",
                 RcsID,                  RcsID,
Line 65  func (s *Suite) Test_ChecklinesPatch__wi
Line 69  func (s *Suite) Test_ChecklinesPatch__wi
                 "@@ -5,3 +5,3 @@",                  "@@ -5,3 +5,3 @@",
                 " context before",                  " context before",
                 "-old line",                  "-old line",
                 "+old line",                  "+new line",
                 " context after")                  " context after")
         t.CheckFileLines("distinfo",          t.CheckFileLines("distinfo",
                 RcsID,                  RcsID,
                 "",                  "",
                 "SHA1 (some patch) = a7c35294b3853da0acedf8a972cb266baa9582a3")                  "SHA1 (some patch) = 4938fc8c0b483dc2e33e741b0da883d199e78164")
   }
   
   func (s *Suite) Test_ChecklinesPatch__no_comment_and_no_empty_lines(c *check.C) {
           t := s.Init(c)
   
           patchLines := t.SetupFileLines("patch-WithoutEmptyLines",
                   RcsID,
                   "--- file.orig",
                   "+++ file",
                   "@@ -1,1 +1,1 @@",
                   "-old line",
                   "+new line")
   
           t.SetupCommandLine("-Wall")
   
           ChecklinesPatch(patchLines)
   
           // These duplicate notes are actually correct. There should be an
           // empty line above the documentation and one below it. Since there
           // is no documentation yet, the line number for above and below is
           // the same. Outside of the testing environment, this duplicate
           // diagnostic is suppressed; see LogVerbose.
           t.CheckOutputLines(
                   "NOTE: ~/patch-WithoutEmptyLines:2: Empty line expected.",
                   "ERROR: ~/patch-WithoutEmptyLines:2: Each patch must be documented.",
                   "NOTE: ~/patch-WithoutEmptyLines:2: Empty line expected.")
 }  }
   
 func (s *Suite) Test_ChecklinesPatch__without_comment(c *check.C) {  func (s *Suite) Test_ChecklinesPatch__without_comment(c *check.C) {
Line 94  func (s *Suite) Test_ChecklinesPatch__wi
Line 124  func (s *Suite) Test_ChecklinesPatch__wi
                 "ERROR: patch-WithoutComment:3: Each patch must be documented.")                  "ERROR: patch-WithoutComment:3: Each patch must be documented.")
 }  }
   
   // Autogenerated git "comments" don't count as real comments since they
   // don't convey any intention of a human developer.
 func (s *Suite) Test_ChecklinesPatch__git_without_comment(c *check.C) {  func (s *Suite) Test_ChecklinesPatch__git_without_comment(c *check.C) {
         t := s.Init(c)          t := s.Init(c)
   
Line 125  func (s *Suite) Test_checklineOtherAbsol
Line 157  func (s *Suite) Test_checklineOtherAbsol
         t.CheckOutputEmpty()          t.CheckOutputEmpty()
 }  }
   
   // The output of BSD Make typically contains "*** Error code".
   // In some really good patches, this output is included in the patch comment,
   // to document why the patch is necessary.
 func (s *Suite) Test_ChecklinesPatch__error_code(c *check.C) {  func (s *Suite) Test_ChecklinesPatch__error_code(c *check.C) {
         t := s.Init(c)          t := s.Init(c)
   
Line 157  func (s *Suite) Test_ChecklinesPatch__wr
Line 192  func (s *Suite) Test_ChecklinesPatch__wr
                 "Text",                  "Text",
                 "Text",                  "Text",
                 "",                  "",
                 "+++ file",      // Wrong                  "+++ file",      // Wrong order
                 "--- file.orig", // Wrong                  "--- file.orig", // Wrong order
                 "@@ -5,3 +5,3 @@",                  "@@ -5,3 +5,3 @@",
                 " context before",                  " context before",
                 "-old line",                  "-old line",
Line 171  func (s *Suite) Test_ChecklinesPatch__wr
Line 206  func (s *Suite) Test_ChecklinesPatch__wr
                 "WARN: patch-WrongOrder:7: Unified diff headers should be first ---, then +++.")                  "WARN: patch-WrongOrder:7: Unified diff headers should be first ---, then +++.")
 }  }
   
   // Context diffs are old and deprecated. Therefore pkglint doesn't check them thoroughly.
 func (s *Suite) Test_ChecklinesPatch__context_diff(c *check.C) {  func (s *Suite) Test_ChecklinesPatch__context_diff(c *check.C) {
         t := s.Init(c)          t := s.Init(c)
   
Line 228  func (s *Suite) Test_ChecklinesPatch__tw
Line 264  func (s *Suite) Test_ChecklinesPatch__tw
                 "WARN: patch-aa: Contains patches for 2 files, should be only one.")                  "WARN: patch-aa: Contains patches for 2 files, should be only one.")
 }  }
   
   // The patch headers are only recognized as such if they appear directly below each other.
 func (s *Suite) Test_ChecklinesPatch__documentation_that_looks_like_patch_lines(c *check.C) {  func (s *Suite) Test_ChecklinesPatch__documentation_that_looks_like_patch_lines(c *check.C) {
         t := s.Init(c)          t := s.Init(c)
   
Line 308  func (s *Suite) Test_ChecklinesPatch__Ma
Line 345  func (s *Suite) Test_ChecklinesPatch__Ma
                 "WARN: patch-unified:10: Found absolute pathname: /bin/cp",                  "WARN: patch-unified:10: Found absolute pathname: /bin/cp",
                 "WARN: patch-unified:13: Found absolute pathname: /bin/cp")                  "WARN: patch-unified:13: Found absolute pathname: /bin/cp")
   
           // With extra warnings turned on, absolute paths in the context lines
           // are also checked, to detect absolute paths that might be overlooked.
           // TODO: Maybe this should only be checked if the patch changes
           // an absolute path to a relative one, because otherwise these
           // absolute paths may be intentional.
         G.opts.WarnExtra = true          G.opts.WarnExtra = true
   
         ChecklinesPatch(lines)          ChecklinesPatch(lines)
Line 363  func (s *Suite) Test_ChecklinesPatch__no
Line 405  func (s *Suite) Test_ChecklinesPatch__no
         t.CheckOutputEmpty()          t.CheckOutputEmpty()
 }  }
   
   // Some patch files may end before reaching the expected line count (in this case 7 lines).
   // This is ok if only context lines are missing. These context lines are assumed to be empty lines.
 func (s *Suite) Test_ChecklinesPatch__empty_lines_left_out_at_eof(c *check.C) {  func (s *Suite) Test_ChecklinesPatch__empty_lines_left_out_at_eof(c *check.C) {
         t := s.Init(c)          t := s.Init(c)
   
Line 386  func (s *Suite) Test_ChecklinesPatch__em
Line 430  func (s *Suite) Test_ChecklinesPatch__em
         t.CheckOutputEmpty()          t.CheckOutputEmpty()
 }  }
   
 // In some context lines, the leading space character is missing.  // In some context lines, the leading space character may be missing.
 // Since this is no problem for patch(1), pkglint also doesn't complain.  // Since this is no problem for patch(1), pkglint also doesn't complain.
 func (s *Suite) Test_ChecklinesPatch__context_lines_with_tab_instead_of_space(c *check.C) {  func (s *Suite) Test_ChecklinesPatch__context_lines_with_tab_instead_of_space(c *check.C) {
         t := s.Init(c)          t := s.Init(c)

Legend:
Removed from v.1.16  
changed lines
  Added in v.1.17

CVSweb <webmaster@jp.NetBSD.org>