modernc.org/xcb@v1.0.15/all_test.go (about) 1 // Copyright 2021 The Xcb-Go Authors. All rights reserved. 2 // Use of the source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package xcb // import "modernc.org/xcb" 6 7 import ( 8 "flag" 9 "fmt" 10 "os" 11 "path" 12 "runtime" 13 "runtime/debug" 14 "strings" 15 "testing" 16 ) 17 18 func caller(s string, va ...interface{}) { 19 if s == "" { 20 s = strings.Repeat("%v ", len(va)) 21 } 22 _, fn, fl, _ := runtime.Caller(2) 23 fmt.Fprintf(os.Stderr, "# caller: %s:%d: ", path.Base(fn), fl) 24 fmt.Fprintf(os.Stderr, s, va...) 25 fmt.Fprintln(os.Stderr) 26 _, fn, fl, _ = runtime.Caller(1) 27 fmt.Fprintf(os.Stderr, "# \tcallee: %s:%d: ", path.Base(fn), fl) 28 fmt.Fprintln(os.Stderr) 29 os.Stderr.Sync() 30 } 31 32 func dbg(s string, va ...interface{}) { 33 if s == "" { 34 s = strings.Repeat("%v ", len(va)) 35 } 36 _, fn, fl, _ := runtime.Caller(1) 37 fmt.Fprintf(os.Stderr, "# dbg %s:%d: ", path.Base(fn), fl) 38 fmt.Fprintf(os.Stderr, s, va...) 39 fmt.Fprintln(os.Stderr) 40 os.Stderr.Sync() 41 } 42 43 func TODO(...interface{}) string { //TODOOK 44 _, fn, fl, _ := runtime.Caller(1) 45 return fmt.Sprintf("# TODO: %s:%d:\n", path.Base(fn), fl) //TODOOK 46 } 47 48 func stack() string { return string(debug.Stack()) } 49 50 func use(...interface{}) {} 51 52 func init() { 53 use(caller, dbg, TODO, stack) //TODOOK 54 } 55 56 // ---------------------------------------------------------------------------- 57 58 func TestMain(m *testing.M) { 59 flag.Parse() 60 rc := m.Run() 61 os.Exit(rc) 62 } 63 64 func Test(t *testing.T) { 65 t.Log("TODO") 66 }