From 86651479c8adc6e7a1d67fdaae4f2b2e52af3da9 Mon Sep 17 00:00:00 2001 From: John-Michael Faircloth Date: Thu, 15 May 2025 15:42:44 -0500 Subject: [PATCH] test: fix CompilePlugin test helper (#30644) This PR fixes CompilePlugin which would fail when run locally in certain situations based on relative directory paths. This change makes CompilePlugin perform os.Stat on the full path to the plugin's main.go file to ensure the test changes to the appropriate directory for building the plugin. --- helper/testhelpers/pluginhelpers/pluginhelpers.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/helper/testhelpers/pluginhelpers/pluginhelpers.go b/helper/testhelpers/pluginhelpers/pluginhelpers.go index 2d9c235539..cb097cb94b 100644 --- a/helper/testhelpers/pluginhelpers/pluginhelpers.go +++ b/helper/testhelpers/pluginhelpers/pluginhelpers.go @@ -76,10 +76,6 @@ func CompilePlugin(t testing.TB, typ consts.PluginType, pluginVersion string, pl var pluginBytes []byte dir := "" - pluginRootDir := "builtin" - if typ == consts.PluginTypeDatabase { - pluginRootDir = "plugins" - } for { // So that we can assign to dir without overshadowing the other // err variables. @@ -89,7 +85,7 @@ func CompilePlugin(t testing.TB, typ consts.PluginType, pluginVersion string, pl t.Fatal(getWdErr) } // detect if we are in a subdirectory or the root directory and compensate - if _, err := os.Stat(pluginRootDir); os.IsNotExist(err) { + if _, err := os.Stat(pluginMain); os.IsNotExist(err) { err := os.Chdir("..") if err != nil { t.Fatal(err)