github.com/Xenoex/gopm@v0.6.5/cmd/test.go (about) 1 // Copyright 2013 gopm authors. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"): you may 4 // not use this file except in compliance with the License. You may obtain 5 // a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 // License for the specific language governing permissions and limitations 13 // under the License. 14 15 package cmd 16 17 import ( 18 "github.com/codegangsta/cli" 19 20 "github.com/gpmgo/gopm/log" 21 ) 22 23 var CmdTest = cli.Command{ 24 Name: "test", 25 Usage: "link dependencies and go test", 26 Description: `Command test links dependencies according to gopmfile, 27 and execute 'go test' 28 29 gopm test <go test commands>`, 30 Action: runTest, 31 } 32 33 func runTest(ctx *cli.Context) { 34 genNewGoPath(ctx, true) 35 36 log.Trace("Testing...") 37 38 cmdArgs := []string{"go", "test"} 39 cmdArgs = append(cmdArgs, ctx.Args()...) 40 err := execCmd(newGoPath, newCurPath, cmdArgs...) 41 if err != nil { 42 log.Error("Test", "Fail to test program") 43 log.Fatal("", err.Error()) 44 } 45 46 log.Success("SUCC", "Test", "Command execute successfully!") 47 }