zenity/zenity_test.go

28 lines
496 B
Go
Raw Normal View History

2020-01-29 09:15:21 -05:00
package zenity_test
import (
2021-06-18 10:04:09 -04:00
"errors"
"os"
"os/exec"
"runtime"
2020-01-29 09:15:21 -05:00
"testing"
"go.uber.org/goleak"
)
func TestMain(m *testing.M) {
goleak.VerifyTestMain(m)
}
2021-06-18 10:04:09 -04:00
func skip(err error) (error, bool) {
if _, ok := err.(*exec.Error); ok {
// zenity/osascript/etc were not found in path
return err, true
}
if err != nil && os.Getenv("DISPLAY") == "" && !(runtime.GOOS == "windows" || runtime.GOOS == "darwin") {
// no display
return errors.New("no display"), true
}
return nil, false
}