From 7f26c0b344cc4e2e5adcabe11fd5fba8f2de81d7 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Mon, 4 Mar 2024 17:37:58 +0100 Subject: [PATCH] Temporary fix for consistency tests due to language change in for loops --- interp/interp_consistent_test.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/interp/interp_consistent_test.go b/interp/interp_consistent_test.go index 97010f183..85a3b9adf 100644 --- a/interp/interp_consistent_test.go +++ b/interp/interp_consistent_test.go @@ -7,6 +7,7 @@ import ( "os" "os/exec" "path/filepath" + "runtime" "strings" "testing" @@ -15,6 +16,13 @@ import ( "github.com/traefik/yaegi/stdlib/unsafe" ) +// The following tests depend on an incompatible language change in go1.22, where `for` variables are now +// defined in body (thus reallocated at each loop). We skip them until both supported versions behave the same. +// We will remove this in Go1.23. +var testsToSkipGo122 = map[string]bool{"closure9.go": true, "closure10.go": true, "closure11.go": true, "closure12.go": true} + +var go122 = strings.HasPrefix(runtime.Version(), "go1.22") + func TestInterpConsistencyBuild(t *testing.T) { if testing.Short() { t.Skip("short mode") @@ -125,6 +133,9 @@ func TestInterpConsistencyBuild(t *testing.T) { if go121 && testsToSkipGo121[file.Name()] { continue } + if go122 && testsToSkipGo122[file.Name()] { + continue + } file := file t.Run(file.Name(), func(t *testing.T) {