"path/filepath"
"runtime"
"strings"
+ "time"
"unicode"
"utf8"
)
xFlag bool
)
+// elapsed returns time elapsed since gotest started.
+func elapsed() float64 {
+ return float64(time.Nanoseconds()-start) / 1e9
+}
+
+var start = time.Nanoseconds()
+
// File represents a file that contains tests.
type File struct {
name string
if !cFlag {
runTestWithArgs("./" + O + ".out")
}
+ if xFlag {
+ fmt.Printf("gotest %.2fs: done\n", elapsed())
+ }
}
// needMakefile tests that we have a Makefile in this directory.
// Basic environment.
GOROOT = runtime.GOROOT()
addEnv("GOROOT", GOROOT)
- GOARCH = runtime.GOARCH
+ GOARCH = os.Getenv("GOARCH")
+ if GOARCH == "" {
+ GOARCH = runtime.GOARCH
+ }
addEnv("GOARCH", GOARCH)
O = theChar[GOARCH]
if O == "" {
// retrieve standard output.
func doRun(argv []string, returnStdout bool) string {
if xFlag {
- fmt.Printf("gotest: %s\n", strings.Join(argv, " "))
+ fmt.Printf("gotest %.2fs: %s\n", elapsed(), strings.Join(argv, " "))
+ t := -time.Nanoseconds()
+ defer func() {
+ t += time.Nanoseconds()
+ fmt.Printf(" [+%.2fs]\n", float64(t)/1e9)
+ }()
}
command := argv[0]
if runtime.GOOS == "windows" && command == "gomake" {