2008-11-18 16:29:10 -07:00
|
|
|
// Copyright 2009 The Go 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 testing
|
|
|
|
|
2008-11-18 18:52:05 -07:00
|
|
|
import (
|
|
|
|
"flag"
|
|
|
|
)
|
|
|
|
|
|
|
|
var chatty bool;
|
|
|
|
func init() {
|
|
|
|
flag.Bool("chatty", false, &chatty, "chatty");
|
|
|
|
}
|
|
|
|
|
2008-11-18 16:29:10 -07:00
|
|
|
export type Test struct {
|
|
|
|
name string;
|
|
|
|
f *() bool;
|
|
|
|
}
|
|
|
|
|
|
|
|
export func Main(tests *[]Test) {
|
2008-11-18 18:52:05 -07:00
|
|
|
flag.Parse();
|
2008-11-18 16:29:10 -07:00
|
|
|
ok := true;
|
2008-11-19 12:50:58 -07:00
|
|
|
if len(tests) == 0 {
|
|
|
|
println("warning: no tests available");
|
|
|
|
} else if chatty {
|
|
|
|
println(len(tests), "tests to run");
|
|
|
|
}
|
2008-11-18 16:29:10 -07:00
|
|
|
for i := 0; i < len(tests); i++ {
|
2008-11-18 18:52:05 -07:00
|
|
|
if chatty {
|
|
|
|
println("=== RUN ", tests[i].name);
|
|
|
|
}
|
2008-11-18 16:29:10 -07:00
|
|
|
ok1 := tests[i].f();
|
2008-11-18 18:52:05 -07:00
|
|
|
if !ok1 {
|
|
|
|
ok = false;
|
|
|
|
println("--- FAIL", tests[i].name);
|
|
|
|
} else if chatty {
|
|
|
|
println("--- PASS", tests[i].name);
|
2008-11-18 16:29:10 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if !ok {
|
|
|
|
sys.exit(1);
|
|
|
|
}
|
2008-11-18 18:52:05 -07:00
|
|
|
println("PASS");
|
2008-11-18 16:29:10 -07:00
|
|
|
}
|