From b77eeee4c6acacf5b79106117e472ee0918b7234 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Wed, 29 Jul 2015 11:52:07 +0200 Subject: [PATCH] shiny/vendor: make BurntSushi/xgb/xproto tests skip when $DISPLAY is empty The builders don't have X. (notably Darwin) Perhaps the Linux ones should. Or some should. Please file a separate bug for that. Somebody else might want to upstream this fix to BurntSushi. Updates golang/go#11811 Change-Id: I6d270a83fc59a3923723b5bfbd0b92057a484a1c Reviewed-on: https://go-review.googlesource.com/12765 Reviewed-by: Nigel Tao --- .../BurntSushi/xgb/xproto/xproto_test.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/shiny/vendor/github.com/BurntSushi/xgb/xproto/xproto_test.go b/shiny/vendor/github.com/BurntSushi/xgb/xproto/xproto_test.go index a5bec714e..30ec533b2 100644 --- a/shiny/vendor/github.com/BurntSushi/xgb/xproto/xproto_test.go +++ b/shiny/vendor/github.com/BurntSushi/xgb/xproto/xproto_test.go @@ -23,6 +23,7 @@ import ( "fmt" "log" "math/rand" + "os" "testing" "time" @@ -32,19 +33,21 @@ import ( // The X connection used throughout testing. var X *xgb.Conn -// init initializes the X connection, seeds the RNG and starts waiting -// for events. -func init() { - var err error +func TestMain(m *testing.M) { + if os.Getenv("DISPLAY") == "" { + log.Printf("No X; Skipping tests") + os.Exit(0) + } + var err error X, err = xgb.NewConn() if err != nil { log.Fatal(err) } - rand.Seed(time.Now().UnixNano()) - go grabEvents() + + os.Exit(m.Run()) } /******************************************************************************/