]> Cypherpunks repositories - gostls13.git/commitdiff
add -chatty flag to test.
authorRuss Cox <rsc@golang.org>
Wed, 19 Nov 2008 01:52:05 +0000 (17:52 -0800)
committerRuss Cox <rsc@golang.org>
Wed, 19 Nov 2008 01:52:05 +0000 (17:52 -0800)
was supposed to be in some other cl but got dropped.

R=r
DELTA=21  (16 added, 2 deleted, 3 changed)
OCL=19531
CL=19539

src/lib/testing.go

index 121baca888415ad45d575a78ccab67c443ba780a..a5d960fe8076ae0139840d5df9169ca70d3d0054 100644 (file)
@@ -4,23 +4,37 @@
 
 package testing
 
+import (
+       "flag"
+)
+
+var chatty bool;
+func init() {
+       flag.Bool("chatty", false, &chatty, "chatty");
+}
+
 export type Test struct {
        name string;
        f *() bool;
 }
 
 export func Main(tests *[]Test) {
+       flag.Parse();
        ok := true;
        for i := 0; i < len(tests); i++ {
+               if chatty {
+                       println("=== RUN ", tests[i].name);
+               }
                ok1 := tests[i].f();
-               status := "FAIL";
-               if ok1 {
-                       status = "PASS"
+               if !ok1 {
+                       ok = false;
+                       println("--- FAIL", tests[i].name);
+               } else if chatty {
+                       println("--- PASS", tests[i].name);
                }
-               ok = ok && ok1;
-               println(status, tests[i].name);
        }
        if !ok {
                sys.exit(1);
        }
+       println("PASS");
 }