mirror of
https://github.com/hashicorp/vault.git
synced 2026-05-05 12:26:34 +02:00
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.
This commit is contained in:
parent
8fb58b5859
commit
86651479c8
@ -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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user