From 7c2852145153026ca6adbe9280b64fd35c91ad39 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Wed, 3 Apr 2024 10:10:35 +0100 Subject: [PATCH] [TESTS] Truncate some long test names, for readability The strings produced by these tests can run to thousands of characters, which makes test logs difficult to read. Signed-off-by: Bryan Boreham --- model/labels/regexp_test.go | 10 +++++++++- promql/parser/parse_test.go | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/model/labels/regexp_test.go b/model/labels/regexp_test.go index ac48bdc5b..3a15b52b4 100644 --- a/model/labels/regexp_test.go +++ b/model/labels/regexp_test.go @@ -100,7 +100,7 @@ func TestFastRegexMatcher_MatchString(t *testing.T) { r := r for _, v := range testValues { v := v - t.Run(r+` on "`+v+`"`, func(t *testing.T) { + t.Run(readable(r)+` on "`+readable(v)+`"`, func(t *testing.T) { t.Parallel() m, err := NewFastRegexMatcher(r) require.NoError(t, err) @@ -111,6 +111,14 @@ func TestFastRegexMatcher_MatchString(t *testing.T) { } } +func readable(s string) string { + const maxReadableStringLen = 40 + if len(s) < maxReadableStringLen { + return s + } + return s[:maxReadableStringLen] + "..." +} + func TestOptimizeConcatRegex(t *testing.T) { cases := []struct { regex string diff --git a/promql/parser/parse_test.go b/promql/parser/parse_test.go index ff6e0b082..c56d84594 100644 --- a/promql/parser/parse_test.go +++ b/promql/parser/parse_test.go @@ -3696,9 +3696,17 @@ func makeInt64Pointer(val int64) *int64 { return valp } +func readable(s string) string { + const maxReadableStringLen = 40 + if len(s) < maxReadableStringLen { + return s + } + return s[:maxReadableStringLen] + "..." +} + func TestParseExpressions(t *testing.T) { for _, test := range testExpr { - t.Run(test.input, func(t *testing.T) { + t.Run(readable(test.input), func(t *testing.T) { expr, err := ParseExpr(test.input) // Unexpected errors are always caused by a bug.