modernc.org/99c@v1.0.1-0.20181109153923-a9e8197063d9/99prof/all_test.go (about) 1 // Copyright 2017 The 99c Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package main 6 7 import ( 8 "fmt" 9 "os" 10 "path" 11 "runtime" 12 "strings" 13 "testing" 14 ) 15 16 func caller(s string, va ...interface{}) { 17 if s == "" { 18 s = strings.Repeat("%v ", len(va)) 19 } 20 _, fn, fl, _ := runtime.Caller(2) 21 fmt.Fprintf(os.Stderr, "# caller: %s:%d: ", path.Base(fn), fl) 22 fmt.Fprintf(os.Stderr, s, va...) 23 fmt.Fprintln(os.Stderr) 24 _, fn, fl, _ = runtime.Caller(1) 25 fmt.Fprintf(os.Stderr, "# \tcallee: %s:%d: ", path.Base(fn), fl) 26 fmt.Fprintln(os.Stderr) 27 os.Stderr.Sync() 28 } 29 30 func dbg(s string, va ...interface{}) { 31 if s == "" { 32 s = strings.Repeat("%v ", len(va)) 33 } 34 _, fn, fl, _ := runtime.Caller(1) 35 fmt.Fprintf(os.Stderr, "# dbg %s:%d: ", path.Base(fn), fl) 36 fmt.Fprintf(os.Stderr, s, va...) 37 fmt.Fprintln(os.Stderr) 38 os.Stderr.Sync() 39 } 40 41 func TODO(...interface{}) string { //TODOOK 42 _, fn, fl, _ := runtime.Caller(1) 43 return fmt.Sprintf("# TODO: %s:%d:\n", path.Base(fn), fl) //TODOOK 44 } 45 46 func use(...interface{}) {} 47 48 func init() { 49 use(caller, dbg, TODO) //TODOOK 50 } 51 52 // ============================================================================ 53 54 func Test(t *testing.T) { 55 t.Logf("TODO") 56 }