Skip to content

Commit

Permalink
Remove race in tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
monopole committed May 24, 2020
1 parent d2c205b commit a193129
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 16 deletions.
8 changes: 1 addition & 7 deletions api/internal/plugins/compiler/compiler.go
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 0 additions & 8 deletions api/internal/plugins/compiler/compiler_test.go
Expand Up @@ -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(
Expand All @@ -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)
}
}
3 changes: 2 additions & 1 deletion api/internal/plugins/loader/loader.go
Expand Up @@ -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)
Expand Down

0 comments on commit a193129

Please sign in to comment.