Permalink
Browse files

Print to stdout instead of logging

  • Loading branch information...
1 parent 112a809 commit 51984ced0c36ecb29a3017531e92a213957d90a6 @ryanslade committed Sep 20, 2012
Showing with 12 additions and 8 deletions.
  1. +12 −8 goautotest.go
View
20 goautotest.go
@@ -4,7 +4,6 @@ import (
"fmt"
"github.com/howeyc/fsnotify"
"io"
- "log"
"os"
"os/exec"
"strings"
@@ -13,17 +12,20 @@ import (
func main() {
watcher, err := fsnotify.NewWatcher()
if err != nil {
- log.Fatal(err)
+ fmt.Println(err)
+ return
}
wd, err := os.Getwd()
if err != nil {
- log.Fatal(err)
+ fmt.Println(err)
+ return
}
err = watcher.Watch(wd)
if err != nil {
- log.Fatal(err)
+ fmt.Println(err)
+ return
}
defer watcher.Close()
@@ -32,30 +34,32 @@ func main() {
select {
case ev := <-watcher.Event:
if strings.HasSuffix(ev.Name, ".go") {
+ fmt.Println("Running tests...")
+
cmd := exec.Command("go", "test")
stdout, err := cmd.StdoutPipe()
if err != nil {
- log.Println(err)
+ fmt.Println(err)
break
}
err = cmd.Start()
if err != nil {
- log.Println(err)
+ fmt.Println(err)
break
}
go io.Copy(os.Stdout, stdout)
err = cmd.Wait()
if err != nil {
- log.Println(err)
+ fmt.Println(err)
}
fmt.Println()
}
case err := <-watcher.Error:
- log.Println(err)
+ fmt.Println(err)
}
}

0 comments on commit 51984ce

Please sign in to comment.