diff options
Diffstat (limited to 'pkgtools/pkglint/files/shtokenizer_test.go')
-rw-r--r-- | pkgtools/pkglint/files/shtokenizer_test.go | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/pkgtools/pkglint/files/shtokenizer_test.go b/pkgtools/pkglint/files/shtokenizer_test.go index 14f08659591..b713facdadc 100644 --- a/pkgtools/pkglint/files/shtokenizer_test.go +++ b/pkgtools/pkglint/files/shtokenizer_test.go @@ -90,9 +90,13 @@ func (s *Suite) Test_ShTokenizer__fuzzing(c *check.C) { fuzzer.Char("\"'`$();|_#", 10) fuzzer.Range('a', 'z', 5) + // This "real" line is necessary because the autofix + // in MkParser.varUseBrace checks this. + line := t.NewLine("Makefile", 1, "\t:") + defer fuzzer.CheckOk() for i := 0; i < 1000; i++ { - tokenizer := NewShTokenizer(dummyLine, fuzzer.Generate(50), false) + tokenizer := NewShTokenizer(line, fuzzer.Generate(50), false) tokenizer.ShAtoms() t.Output() // Discard the output, only react on panics. } @@ -105,7 +109,8 @@ func (s *Suite) Test_ShTokenizer_ShAtom(c *check.C) { // testRest ensures that the given string is parsed to the expected // atoms, and returns the remaining text. testRest := func(s string, expectedAtoms []*ShAtom, expectedRest string) { - p := NewShTokenizer(dummyLine, s, false) + line := t.NewLine("filename.mk", 1, "") + p := NewShTokenizer(line, s, false) actualAtoms := p.ShAtoms() @@ -512,7 +517,8 @@ func (s *Suite) Test_ShTokenizer_ShAtom__quoting(c *check.C) { t := s.Init(c) test := func(input, expectedOutput string) { - p := NewShTokenizer(dummyLine, input, false) + line := t.NewLine("filename.mk", 1, "") + p := NewShTokenizer(line, input, false) q := shqPlain result := "" for { @@ -601,7 +607,8 @@ func (s *Suite) Test_ShTokenizer_ShToken(c *check.C) { // testRest ensures that the given string is parsed to the expected // tokens, and returns the remaining text. testRest := func(str string, expected ...string) string { - p := NewShTokenizer(dummyLine, str, false) + line := t.NewLine("testRest.mk", 1, "") + p := NewShTokenizer(line, str, false) for _, exp := range expected { t.CheckEquals(p.ShToken().MkText, exp) } @@ -609,7 +616,8 @@ func (s *Suite) Test_ShTokenizer_ShToken(c *check.C) { } test := func(str string, expected ...string) { - p := NewShTokenizer(dummyLine, str, false) + line := t.NewLine("test.mk", 1, "") + p := NewShTokenizer(line, str, false) for _, exp := range expected { t.CheckEquals(p.ShToken().MkText, exp) } @@ -618,7 +626,8 @@ func (s *Suite) Test_ShTokenizer_ShToken(c *check.C) { } testNil := func(str string) { - p := NewShTokenizer(dummyLine, str, false) + line := t.NewLine("testNil.mk", 1, "") + p := NewShTokenizer(line, str, false) c.Check(p.ShToken(), check.IsNil) t.CheckEquals(p.Rest(), "") t.CheckOutputEmpty() |