Merge pull request #2530 from monopole/deleteRace

Remove race in tests.
This commit is contained in:
Jeff Regan
2020-05-23 18:22:22 -07:00
committed by GitHub
3 changed files with 3 additions and 16 deletions

View File

@@ -55,12 +55,6 @@ func (b *Compiler) ObjPath() string {
return filepath.Join(b.workDir, b.objFile()) 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 // Compile changes its working directory to
// ${pluginRoot}/${g}/${v}/$lower(${k} and places // ${pluginRoot}/${g}/${v}/$lower(${k} and places
// object code next to source code. // object code next to source code.
@@ -98,7 +92,7 @@ func (b *Compiler) Compile() error {
} }
result := filepath.Join(b.workDir, b.objFile()) result := filepath.Join(b.workDir, b.objFile())
if utils.FileExists(result) { if utils.FileExists(result) {
log.Printf("Created %s", result) log.Printf("compiler created: %s", result)
return nil return nil
} }
return fmt.Errorf("post compile, cannot find '%s'", result) return fmt.Errorf("post compile, cannot find '%s'", result)

View File

@@ -33,10 +33,6 @@ func TestCompiler(t *testing.T) {
if !utils.FileExists(expectObj) { if !utils.FileExists(expectObj) {
t.Errorf("didn't find expected obj file %s", 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") c.SetGVK("builtin", "", "SecretGenerator")
expectObj = filepath.Join( expectObj = filepath.Join(
@@ -52,8 +48,4 @@ func TestCompiler(t *testing.T) {
if !utils.FileExists(expectObj) { if !utils.FileExists(expectObj) {
t.Errorf("didn't find expected obj file %s", 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)
}
} }

View File

@@ -206,7 +206,8 @@ func (l *Loader) loadGoPlugin(id resid.ResId) (resmap.Configurable, error) {
} }
absPath := l.absolutePluginPath(id) + ".so" absPath := l.absolutePluginPath(id) + ".so"
if !utils.FileExists(absPath) { 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) log.Printf("Attempting plugin load from '%s'", absPath)
p, err := plugin.Open(absPath) p, err := plugin.Open(absPath)