From a1931299208c74f0474ecf34175457bb817dd021 Mon Sep 17 00:00:00 2001 From: jregan Date: Sat, 23 May 2020 17:51:32 -0700 Subject: [PATCH] Remove race in tests. --- api/internal/plugins/compiler/compiler.go | 8 +------- api/internal/plugins/compiler/compiler_test.go | 8 -------- api/internal/plugins/loader/loader.go | 3 ++- 3 files changed, 3 insertions(+), 16 deletions(-) diff --git a/api/internal/plugins/compiler/compiler.go b/api/internal/plugins/compiler/compiler.go index 1ec33bb32..04f827eff 100644 --- a/api/internal/plugins/compiler/compiler.go +++ b/api/internal/plugins/compiler/compiler.go @@ -55,12 +55,6 @@ func (b *Compiler) ObjPath() string { return filepath.Join(b.workDir, b.objFile()) } -// Cleanup provides a hook to delete the .so file. -// Ignore errors. -func (b *Compiler) Cleanup() { - _ = os.Remove(b.ObjPath()) -} - // Compile changes its working directory to // ${pluginRoot}/${g}/${v}/$lower(${k} and places // object code next to source code. @@ -98,7 +92,7 @@ func (b *Compiler) Compile() error { } result := filepath.Join(b.workDir, b.objFile()) if utils.FileExists(result) { - log.Printf("Created %s", result) + log.Printf("compiler created: %s", result) return nil } return fmt.Errorf("post compile, cannot find '%s'", result) diff --git a/api/internal/plugins/compiler/compiler_test.go b/api/internal/plugins/compiler/compiler_test.go index eaa9a5f25..e4cd5b2a2 100644 --- a/api/internal/plugins/compiler/compiler_test.go +++ b/api/internal/plugins/compiler/compiler_test.go @@ -33,10 +33,6 @@ func TestCompiler(t *testing.T) { if !utils.FileExists(expectObj) { t.Errorf("didn't find expected obj file %s", expectObj) } - c.Cleanup() - if utils.FileExists(expectObj) { - t.Errorf("obj file '%s' should be gone", expectObj) - } c.SetGVK("builtin", "", "SecretGenerator") expectObj = filepath.Join( @@ -52,8 +48,4 @@ func TestCompiler(t *testing.T) { if !utils.FileExists(expectObj) { t.Errorf("didn't find expected obj file %s", expectObj) } - c.Cleanup() - if utils.FileExists(expectObj) { - t.Errorf("obj file '%s' should be gone", expectObj) - } } diff --git a/api/internal/plugins/loader/loader.go b/api/internal/plugins/loader/loader.go index 59ad5858e..09dc3a167 100644 --- a/api/internal/plugins/loader/loader.go +++ b/api/internal/plugins/loader/loader.go @@ -206,7 +206,8 @@ func (l *Loader) loadGoPlugin(id resid.ResId) (resmap.Configurable, error) { } absPath := l.absolutePluginPath(id) + ".so" if !utils.FileExists(absPath) { - return nil, fmt.Errorf("cannot find Go object code '%s'", absPath) + return nil, fmt.Errorf( + "expected file with Go object code at: %s", absPath) } log.Printf("Attempting plugin load from '%s'", absPath) p, err := plugin.Open(absPath)