mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
```bash for file in `cat diffys`; do printf '%s\n%s\n' "// Copyright 2021 Molecula Corp. All rights reserved." "$(cat $file)" >$file; done ```
35 lines
709 B
Go
35 lines
709 B
Go
// Copyright 2021 Molecula Corp. All rights reserved.
|
|
//go:build !go1.14
|
|
// +build !go1.14
|
|
|
|
package testhook
|
|
|
|
import (
|
|
"sync"
|
|
"testing"
|
|
)
|
|
|
|
var cleanupFuncs []func()
|
|
var cleanupMu sync.Mutex
|
|
|
|
func init() {
|
|
RegisterPostTestHook(runCleanupFuncs)
|
|
}
|
|
|
|
func runCleanupFuncs() error {
|
|
cleanupMu.Lock()
|
|
defer cleanupMu.Unlock()
|
|
for _, fn := range cleanupFuncs {
|
|
fn()
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Cleanup in 1.13 logs a message about skipping a cleanup function, but
|
|
// allows things to build. Cleanup in 1.14 uses tb.Cleanup to register
|
|
// a cleanup function to call when a test completes.
|
|
func Cleanup(tb testing.TB, fn func()) {
|
|
cleanupMu.Lock()
|
|
defer cleanupMu.Unlock()
|
|
cleanupFuncs = append(cleanupFuncs, fn)
|
|
}
|