From 9413bffa7d5babaaf7b31706077096f50930bae6 Mon Sep 17 00:00:00 2001 From: Lucas Hinderberger Date: Fri, 7 Jun 2024 12:26:49 +0200 Subject: [PATCH] path_util: Removing support for quoted strings --- pkg/lib/util/path_util.go | 13 +------------ pkg/lib/util/path_util_test.go | 19 +------------------ 2 files changed, 2 insertions(+), 30 deletions(-) diff --git a/pkg/lib/util/path_util.go b/pkg/lib/util/path_util.go index f2693ec..f9f0069 100644 --- a/pkg/lib/util/path_util.go +++ b/pkg/lib/util/path_util.go @@ -7,7 +7,7 @@ import ( // pathSpecRegex validates and (via its capture groups) breaks up a // path spec string in a single step (see ParsePathSpec). -var pathSpecRegex *regexp.Regexp = regexp.MustCompile(`^([0-9]*)@([^"]+)$`) +var pathSpecRegex *regexp.Regexp = regexp.MustCompile(`^([0-9]*)@(.+)$`) // PathSpec is a path specifier for including tests within manifests. type PathSpec struct { @@ -24,17 +24,6 @@ type PathSpec struct { // It returns a boolean result that indicates if parsing was successful // (i.e. if s is a valid path specifier). func ParsePathSpec(s string) (PathSpec, bool) { - // Remove outer quotes, if present - if len(s) >= 2 && s[0] == '"' { - if s[len(s)-1] != '"' { - // path spec must have matching quotes, if quotes are present - return PathSpec{}, false - } - - s = s[1 : len(s)-1] - } - - // Parse matches := pathSpecRegex.FindStringSubmatch(s) if matches == nil { return PathSpec{}, false diff --git a/pkg/lib/util/path_util_test.go b/pkg/lib/util/path_util_test.go index 2c70c7e..5518b31 100644 --- a/pkg/lib/util/path_util_test.go +++ b/pkg/lib/util/path_util_test.go @@ -43,21 +43,12 @@ func TestParsePathSpec(t *testing.T) { require.True(t, ok) require.Equal(t, testCase.expected, actual) }) - - t.Run(testCase.s+" quoted", func(t *testing.T) { - s := `"` + testCase.s + `"` - - actual, ok := ParsePathSpec(s) - require.True(t, ok) - require.Equal(t, testCase.expected, actual) - }) } }) t.Run("invalid path specs are detected", func(t *testing.T) { testCases := []string{ - "", // empty - `"@foo.json`, `@foo.json"`, // superfluous quotes + "", // empty `foo@bar.baz`, `1.23@foo.json`, // non-digit parallel runs `p@old.syntax`, `p5@old.syntax`, `p123@old.syntax`, // old syntax } @@ -70,14 +61,6 @@ func TestParsePathSpec(t *testing.T) { require.False(t, ok) require.Zero(t, actual) }) - - t.Run(s+" quoted", func(t *testing.T) { - sq := `"` + s + `"` - - actual, ok := ParsePathSpec(sq) - require.False(t, ok) - require.Zero(t, actual) - }) } }) }