zenity/zenity_test.go

30 lines
498 B
Go
Raw Normal View History

2020-01-29 09:15:21 -05:00
package zenity_test
import (
2021-07-06 20:01:22 -04:00
"fmt"
2021-06-18 10:04:09 -04:00
"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
2021-07-06 20:01:22 -04:00
func skip(err error) (bool, error) {
if runtime.GOOS != "windows" && runtime.GOOS != "darwin" {
if _, ok := err.(*exec.Error); ok {
// zenity was not found in path
return true, err
}
if err != nil && os.Getenv("DISPLAY") == "" {
// no display
return true, fmt.Errorf("no display: %w", err)
}
2021-06-18 10:04:09 -04:00
}
2021-07-06 20:01:22 -04:00
return false, err
2021-06-18 10:04:09 -04:00
}