fmt code, and fix bug(bee new has wrong path seprator in windows)

This commit is contained in:
ssx205 2013-09-12 19:20:48 +08:00
parent d8481e756f
commit 69761e3715
3 changed files with 13 additions and 13 deletions

2
new.go
View File

@ -108,7 +108,7 @@ func createApp(cmd *Command, args []string) {
writetofile(path.Join(apppath, "views", "index.tpl"), indextpl) writetofile(path.Join(apppath, "views", "index.tpl"), indextpl)
fmt.Println(path.Join(apppath, "main.go")) fmt.Println(path.Join(apppath, "main.go"))
writetofile(path.Join(apppath, "main.go"), strings.Replace(maingo, "{{.Appname}}", strings.Join(strings.Split(apppath[len(appsrcpath)+1:], string(path.Separator)), string(path.Separator)), -1)) writetofile(path.Join(apppath, "main.go"), strings.Replace(maingo, "{{.Appname}}", strings.Join(strings.Split(apppath[len(appsrcpath)+1:], string(path.Separator)), "/"), -1))
colorLog("[SUCC] New application successfully created!\n") colorLog("[SUCC] New application successfully created!\n")
} }

22
test.go
View File

@ -1,24 +1,24 @@
package main package main
import ( import (
"os"
path "path/filepath"
"os/exec"
"time"
"bytes" "bytes"
"os"
"os/exec"
path "path/filepath"
"time"
) )
var cmdTest = &Command{ var cmdTest = &Command{
UsageLine: "test [appname]", UsageLine: "test [appname]",
Short: "test the app", Short: "test the app",
Long: ``, Long: ``,
} }
func init() { func init() {
cmdTest.Run = testApp cmdTest.Run = testApp
} }
var started= make(chan bool) var started = make(chan bool)
func testApp(cmd *Command, args []string) { func testApp(cmd *Command, args []string) {
if len(args) != 1 { if len(args) != 1 {
@ -56,15 +56,15 @@ func testApp(cmd *Command, args []string) {
} }
} }
func runTest(){ func runTest() {
colorLog("[INFO] Start testing...\n") colorLog("[INFO] Start testing...\n")
time.Sleep(time.Second*5) time.Sleep(time.Second * 5)
path, _ := os.Getwd() path, _ := os.Getwd()
os.Chdir(path+"/tests") os.Chdir(path + "/tests")
var err error var err error
icmd := exec.Command("go", "test") icmd := exec.Command("go", "test")
var out,errbuffer bytes.Buffer var out, errbuffer bytes.Buffer
icmd.Stdout = &out icmd.Stdout = &out
icmd.Stderr = &errbuffer icmd.Stderr = &errbuffer
colorLog("[INFO] ============== Test Begin ===================\n") colorLog("[INFO] ============== Test Begin ===================\n")
@ -75,7 +75,7 @@ func runTest(){
if err != nil { if err != nil {
colorLog("[ERRO] ============== Test failed ===================\n") colorLog("[ERRO] ============== Test failed ===================\n")
colorLog("[ERRO] " ,err) colorLog("[ERRO] ", err)
return return
} }
colorLog("[SUCC] Test finish\n") colorLog("[SUCC] Test finish\n")

View File

@ -147,7 +147,7 @@ func Start(appname string) {
cmd.Stderr = os.Stderr cmd.Stderr = os.Stderr
go cmd.Run() go cmd.Run()
started<-true started <- true
} }
// checkTMPFile returns true if the event was for TMP files. // checkTMPFile returns true if the event was for TMP files.