forked from qiuyesuifeng/goyacc
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathall_test.go
65 lines (55 loc) · 1.32 KB
/
all_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Copyright 2014 The goyacc Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"flag"
"fmt"
"os"
"path"
"runtime"
"strings"
"testing"
)
func caller(s string, va ...interface{}) {
_, fn, fl, _ := runtime.Caller(2)
fmt.Printf("caller: %s:%d: ", path.Base(fn), fl)
fmt.Printf(s, va...)
fmt.Println()
_, fn, fl, _ = runtime.Caller(1)
fmt.Printf("\tcallee: %s:%d: ", path.Base(fn), fl)
fmt.Println()
}
func dbg(s string, va ...interface{}) {
if s == "" {
s = strings.Repeat("%v ", len(va))
}
_, fn, fl, _ := runtime.Caller(1)
fmt.Printf("dbg %s:%d: ", path.Base(fn), fl)
fmt.Printf(s, va...)
fmt.Println()
}
func TODO(...interface{}) string {
_, fn, fl, _ := runtime.Caller(1)
return fmt.Sprintf("TODO: %s:%d:\n", path.Base(fn), fl)
}
func use(...interface{}) {}
// ============================================================================
var (
oSrc = flag.String("src", "", "test src")
oDev = flag.Bool("dev", false, "enable dev test(s)")
oDevOut = flag.String("devout", os.DevNull, "dev test -o replacement")
)
func TestDev(t *testing.T) {
if !*oDev {
t.Log("use -dev to enable")
return
}
*oOut = *oDevOut
if s := *oSrc; s != "" {
err := main1(s)
if err != nil {
t.Fatal(err)
}
}
}