Merge pull request #25068 from cpuguy83/fix_test_parse_words
Fix issue with test ordering for TestParseWords
This commit is contained in:
commit
4e3d6e36a6
|
@ -36,19 +36,19 @@ type Node struct {
|
||||||
EndLine int // the line in the original dockerfile where the node ends
|
EndLine int // the line in the original dockerfile where the node ends
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const defaultTokenEscape = "\\"
|
||||||
|
|
||||||
var (
|
var (
|
||||||
dispatch map[string]func(string) (*Node, map[string]bool, error)
|
dispatch map[string]func(string) (*Node, map[string]bool, error)
|
||||||
tokenWhitespace = regexp.MustCompile(`[\t\v\f\r ]+`)
|
tokenWhitespace = regexp.MustCompile(`[\t\v\f\r ]+`)
|
||||||
tokenLineContinuation *regexp.Regexp
|
tokenLineContinuation *regexp.Regexp
|
||||||
tokenEscape rune
|
tokenEscape = rune(defaultTokenEscape[0])
|
||||||
tokenEscapeCommand = regexp.MustCompile(`^#[ \t]*escape[ \t]*=[ \t]*(?P<escapechar>.).*$`)
|
tokenEscapeCommand = regexp.MustCompile(`^#[ \t]*escape[ \t]*=[ \t]*(?P<escapechar>.).*$`)
|
||||||
tokenComment = regexp.MustCompile(`^#.*$`)
|
tokenComment = regexp.MustCompile(`^#.*$`)
|
||||||
lookingForDirectives bool
|
lookingForDirectives bool
|
||||||
directiveEscapeSeen bool
|
directiveEscapeSeen bool
|
||||||
)
|
)
|
||||||
|
|
||||||
const defaultTokenEscape = "\\"
|
|
||||||
|
|
||||||
// setTokenEscape sets the default token for escaping characters in a Dockerfile.
|
// setTokenEscape sets the default token for escaping characters in a Dockerfile.
|
||||||
func setTokenEscape(s string) error {
|
func setTokenEscape(s string) error {
|
||||||
if s != "`" && s != "\\" {
|
if s != "`" && s != "\\" {
|
||||||
|
|
|
@ -121,11 +121,11 @@ func TestParseWords(t *testing.T) {
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
words := parseWords(test["input"][0])
|
words := parseWords(test["input"][0])
|
||||||
if len(words) != len(test["expect"]) {
|
if len(words) != len(test["expect"]) {
|
||||||
t.Fatalf("length check failed. input: %v, expect: %v, output: %v", test["input"][0], test["expect"], words)
|
t.Fatalf("length check failed. input: %v, expect: %q, output: %q", test["input"][0], test["expect"], words)
|
||||||
}
|
}
|
||||||
for i, word := range words {
|
for i, word := range words {
|
||||||
if word != test["expect"][i] {
|
if word != test["expect"][i] {
|
||||||
t.Fatalf("word check failed for word: %q. input: %v, expect: %v, output: %v", word, test["input"][0], test["expect"], words)
|
t.Fatalf("word check failed for word: %q. input: %q, expect: %q, output: %q", word, test["input"][0], test["expect"], words)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue