[BACK]Return to redundantscope_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/redundantscope_test.go between version 1.9 and 1.11

version 1.9, 2019/12/02 23:32:09 version 1.11, 2019/12/13 01:39:23
Line 25  func (s *Suite) Test_RedundantScope__sin
Line 25  func (s *Suite) Test_RedundantScope__sin
         t.CheckOutputLines(          t.CheckOutputLines(
                 "NOTE: file.mk:7: Default assignment of VAR.def has no effect because of line 1.",                  "NOTE: file.mk:7: Default assignment of VAR.def has no effect because of line 1.",
                 "NOTE: file.mk:8: Definition of VAR.asg is redundant because of line 2.",                  "NOTE: file.mk:8: Definition of VAR.asg is redundant because of line 2.",
                 "WARN: file.mk:4: Variable VAR.evl is overwritten in line 10.")                  "NOTE: file.mk:10: Definition of VAR.evl is redundant because of line 4.")
         // TODO: "VAR.shl: is overwritten later"          // TODO: "VAR.shl: is overwritten later"
 }  }
   
Line 52  func (s *Suite) Test_RedundantScope__sin
Line 52  func (s *Suite) Test_RedundantScope__sin
         t.CheckOutputLines(          t.CheckOutputLines(
                 "NOTE: file.mk:7: Default assignment of VAR.def has no effect because of line 1.",                  "NOTE: file.mk:7: Default assignment of VAR.def has no effect because of line 1.",
                 "NOTE: file.mk:8: Definition of VAR.asg is redundant because of line 2.",                  "NOTE: file.mk:8: Definition of VAR.asg is redundant because of line 2.",
                 "WARN: file.mk:4: Variable VAR.evl is overwritten in line 10.")                  "NOTE: file.mk:10: Definition of VAR.evl is redundant because of line 4.")
         // TODO: "VAR.shl: is overwritten later"          // TODO: "VAR.shl: is overwritten later"
 }  }
   
Line 107  func (s *Suite) Test_RedundantScope__sin
Line 107  func (s *Suite) Test_RedundantScope__sin
         t.CheckOutputLines(          t.CheckOutputLines(
                 "NOTE: file.mk:7: Default assignment of VAR.def has no effect because of line 1.",                  "NOTE: file.mk:7: Default assignment of VAR.def has no effect because of line 1.",
                 "NOTE: file.mk:8: Definition of VAR.asg is redundant because of line 2.",                  "NOTE: file.mk:8: Definition of VAR.asg is redundant because of line 2.",
                 "WARN: file.mk:4: Variable VAR.evl is overwritten in line 10.")                  "NOTE: file.mk:10: Definition of VAR.evl is redundant because of line 4.")
         // TODO: "VAR.shl: is overwritten later"          // TODO: "VAR.shl: is overwritten later"
 }  }
   
Line 840  func (s *Suite) Test_RedundantScope__bra
Line 840  func (s *Suite) Test_RedundantScope__bra
         t.CheckOutputEmpty()          t.CheckOutputEmpty()
 }  }
   
 // FIXME: Continue the systematic redundancy tests.  // TODO: Continue the systematic redundancy tests.
 //  //
 // Tests where the variables are defined in a .for loop that might not be  // Tests where the variables are defined in a .for loop that might not be
 // evaluated at all.  // evaluated at all.
Line 1246  func (s *Suite) Test_RedundantScope__inc
Line 1246  func (s *Suite) Test_RedundantScope__inc
                 "CONFIGURE_ARGS=         two",                  "CONFIGURE_ARGS=         two",
                 "CONFIGURE_ARGS+=        three")                  "CONFIGURE_ARGS+=        three")
         t.SetUpPackage("category/dependency")          t.SetUpPackage("category/dependency")
         t.CreateFileDummyBuildlink3("category/dependency/buildlink3.mk")          t.CreateFileBuildlink3("category/dependency/buildlink3.mk")
         t.CreateFileLines("category/dependency/builtin.mk",          t.CreateFileLines("category/dependency/builtin.mk",
                 MkCvsID,                  MkCvsID,
                 "CONFIGURE_ARGS.Darwin+= darwin")                  "CONFIGURE_ARGS.Darwin+= darwin")
Line 1332  func (s *Suite) Test_RedundantScope__eva
Line 1332  func (s *Suite) Test_RedundantScope__eva
         NewRedundantScope().Check(mklines)          NewRedundantScope().Check(mklines)
   
         t.CheckOutputLines(          t.CheckOutputLines(
                 "WARN: filename.mk:1: Variable VAR is overwritten in line 2.",                  "NOTE: filename.mk:2: Definition of VAR is redundant because of line 1.",
                 "WARN: filename.mk:2: Variable VAR is overwritten in line 3.")                  "WARN: filename.mk:2: Variable VAR is overwritten in line 3.")
 }  }
   
Line 1427  func (s *Suite) Test_RedundantScope__pro
Line 1427  func (s *Suite) Test_RedundantScope__pro
         t.CheckOutputEmpty()          t.CheckOutputEmpty()
 }  }
   
   func (s *Suite) Test_RedundantScope__infra(c *check.C) {
           t := s.Init(c)
   
           t.CreateFileLines("mk/bsd.options.mk",
                   "PKG_OPTIONS:=\t# empty",
                   "PKG_OPTIONS=\t# empty")
           t.CreateFileLines("options.mk",
                   "OUTSIDE:=\t# empty",
                   "OUTSIDE=\t# empty",
                   ".include \"mk/bsd.options.mk\"")
   
           test := func(diagnostics ...string) {
                   mklines := t.LoadMkInclude("options.mk")
                   scope := NewRedundantScope()
                   scope.IsRelevant = func(mkline *MkLine) bool {
                           // See checkfilePackageMakefile.
                           if !G.Infrastructure && !G.Opts.CheckGlobal {
                                   return !G.Pkgsrc.IsInfra(mkline.Filename)
                           }
                           return true
                   }
   
                   scope.Check(mklines)
   
                   // No note about the redundant variable assignment in bsd.options.mk
                   // because it is part of the infrastructure, which is filtered out.
                   t.CheckOutput(diagnostics)
           }
   
           test(
                   "NOTE: ~/options.mk:2: " +
                           "Definition of OUTSIDE is redundant because of line 1.")
   
           t.SetUpCommandLine("-Cglobal")
   
           test(
                   "NOTE: ~/options.mk:2: "+
                           "Definition of OUTSIDE is redundant because of line 1.",
                   "NOTE: ~/mk/bsd.options.mk:2: "+
                           "Definition of PKG_OPTIONS is redundant because of line 1.")
   }
   
 // Branch coverage for info.vari.IsConstant(). The other tests typically  // Branch coverage for info.vari.IsConstant(). The other tests typically
 // make a variable non-constant by adding conditional assignments between  // make a variable non-constant by adding conditional assignments between
 // .if/.endif. But there are other ways. The output of shell commands is  // .if/.endif. But there are other ways. The output of shell commands is
Line 1522  func (s *Suite) Test_RedundantScope_hand
Line 1564  func (s *Suite) Test_RedundantScope_hand
                 "NOTE: main.mk:3: Definition of VAR is redundant because of redundant.mk:1.")                  "NOTE: main.mk:3: Definition of VAR is redundant because of redundant.mk:1.")
 }  }
   
   func (s *Suite) Test_RedundantScope_handleVarassign__assign_then_eval(c *check.C) {
           t := s.Init(c)
   
           mklines := t.NewMkLines("mk/bsd.options.mk",
                   "PKG_OPTIONS=\t# empty",
                   "PKG_OPTIONS:=\t# empty")
   
           scope := NewRedundantScope()
           scope.Check(mklines)
   
           t.CheckOutputLines(
                   "NOTE: mk/bsd.options.mk:2: " +
                           "Definition of PKG_OPTIONS is redundant because of line 1.")
   }
   
 func (s *Suite) Test_includePath_includes(c *check.C) {  func (s *Suite) Test_includePath_includes(c *check.C) {
         t := s.Init(c)          t := s.Init(c)
   

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.11

CVSweb <webmaster@jp.NetBSD.org>