From cb8b6d75049faa08203cfa2b7326b3d9391f7872 Mon Sep 17 00:00:00 2001 From: Filip Petkovski Date: Thu, 11 Jul 2024 14:16:43 +0200 Subject: [PATCH] Allow built-in tests to be customized The RunBuiltinTests function accepts a concrete type which makes it hard to exclude certain tests from the suite. It would be great if we could skip tests which might not be critical in order to unblock updates. By accepting an interface instead, we can inject a custom implementation which would skips select test cases. Signed-off-by: Filip Petkovski --- promql/promqltest/test.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/promql/promqltest/test.go b/promql/promqltest/test.go index f3a773be8..83137e661 100644 --- a/promql/promqltest/test.go +++ b/promql/promqltest/test.go @@ -55,6 +55,11 @@ const ( DefaultMaxSamplesPerQuery = 10000 ) +type TBRun interface { + testing.TB + Run(string, func(*testing.T)) bool +} + var testStartTime = time.Unix(0, 0).UTC() // LoadedStorage returns storage with generated data using the provided load statements. @@ -89,7 +94,7 @@ func NewTestEngine(enablePerStepStats bool, lookbackDelta time.Duration, maxSamp } // RunBuiltinTests runs an acceptance test suite against the provided engine. -func RunBuiltinTests(t *testing.T, engine promql.QueryEngine) { +func RunBuiltinTests(t TBRun, engine promql.QueryEngine) { t.Cleanup(func() { parser.EnableExperimentalFunctions = false }) parser.EnableExperimentalFunctions = true