[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/redundantscope_test.go between version 1.3 and 1.4

version 1.3, 2019/04/20 17:43:24 version 1.4, 2019/05/06 20:27:17
Line 730  func (s *Suite) Test_RedundantScope__var
Line 730  func (s *Suite) Test_RedundantScope__var
                 "NOTE: filename.mk:4: Definition of VAR is redundant because of line 2.")                  "NOTE: filename.mk:4: Definition of VAR is redundant because of line 2.")
 }  }
   
   func (s *Suite) Test_RedundantScope__incomplete_then_default(c *check.C) {
           t := s.Init(c)
   
           include, get := t.SetUpHierarchy()
   
           include("including.mk",
                   ".if ${OPSYS} == NetBSD",
                   "VAR=\tNetBSD",
                   ".elif ${OPSYS} == FreeBSD",
                   "VAR=\tFreeBSD",
                   ".endif",
                   "",
                   "VAR?=\tdefault")
   
           mklines := get("including.mk")
   
           NewRedundantScope().Check(mklines)
   
           t.CheckOutputEmpty()
   }
   
   func (s *Suite) Test_RedundantScope__complete_then_default(c *check.C) {
           t := s.Init(c)
   
           include, get := t.SetUpHierarchy()
   
           include("including.mk",
                   ".if ${OPSYS} == NetBSD",
                   "VAR=\tNetBSD",
                   ".else",
                   "VAR=\tFreeBSD",
                   ".endif",
                   "",
                   "VAR?=\tdefault")
   
           mklines := get("including.mk")
   
           NewRedundantScope().Check(mklines)
   
           // TODO: Pkglint could know that the ?= is redundant because VAR is
           //  definitely assigned.
           t.CheckOutputEmpty()
   }
   
   func (s *Suite) Test_RedundantScope__conditional_then_override(c *check.C) {
           t := s.Init(c)
   
           include, get := t.SetUpHierarchy()
   
           include("including.mk",
                   ".if ${OPSYS} == NetBSD",
                   "VAR=\tNetBSD",
                   ".else",
                   "VAR=\tFreeBSD",
                   ".endif",
                   "",
                   "VAR=\tdefault")
   
           mklines := get("including.mk")
   
           NewRedundantScope().Check(mklines)
   
           // TODO: Pkglint could know that no matter which branch is taken,
           //  the variable will be overwritten in the last line.
           t.CheckOutputEmpty()
   }
   
   func (s *Suite) Test_RedundantScope__set_then_conditional(c *check.C) {
           t := s.Init(c)
   
           include, get := t.SetUpHierarchy()
   
           include("including.mk",
                   "VAR=\tdefault",
                   "",
                   ".if ${OPSYS} == NetBSD",
                   "VAR=\tNetBSD",
                   ".else",
                   "VAR=\tFreeBSD",
                   ".endif")
   
           mklines := get("including.mk")
   
           NewRedundantScope().Check(mklines)
   
           // TODO: Pkglint could know that no matter which branch is taken,
           //  one of the branches will overwrite the assignment from line 1.
           t.CheckOutputEmpty()
   }
   
   func (s *Suite) Test_RedundantScope__branch_with_set_then_set(c *check.C) {
           t := s.Init(c)
   
           include, get := t.SetUpHierarchy()
   
           include("including.mk",
                   ".if ${OPSYS} == NetBSD",
                   "VAR=\tfirst",
                   "VAR=\tsecond",
                   ".endif")
   
           mklines := get("including.mk")
   
           NewRedundantScope().Check(mklines)
   
           // TODO: Pkglint could know that the second assignment overwrites the
           //  first assignment since they are in the same basic block.
           t.CheckOutputEmpty()
   }
   
 // FIXME: Continue the systematic redundancy tests.  // FIXME: Continue the systematic redundancy tests.
 //  //
 // Tests where the variables are defined conditionally using .if, .else, .endif.  
 //  
 // 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.
 //  //

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

CVSweb <webmaster@jp.NetBSD.org>