"ag test" support run case in tests dir for test client project
This commit is contained in:
parent
b9254c1e6f
commit
a03cd6df88
19
main.go
19
main.go
@ -14,6 +14,8 @@ import (
|
||||
"text/template"
|
||||
)
|
||||
|
||||
var version = "v0.0.6"
|
||||
|
||||
//go:embed templates/_makePluginCode.go
|
||||
var makePluginCodeTPL string
|
||||
|
||||
@ -210,7 +212,21 @@ func _testProject(args []string, isWatch bool) {
|
||||
if isWatch {
|
||||
args = append(args, "-p", "..")
|
||||
}
|
||||
args = append(args, "test", "-v", ".")
|
||||
isRun := false
|
||||
for _, f := range u.ReadDirN(".") {
|
||||
if strings.HasSuffix(f.Name, ".go") {
|
||||
goStr := u.ReadFileN(f.FullName)
|
||||
if strings.Contains(goStr, "package main") && !strings.Contains(goStr, "package main_test") {
|
||||
isRun = true
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
if !isRun {
|
||||
args = append(args, "test", "-v", ".")
|
||||
} else {
|
||||
args = append(args, "run", ".")
|
||||
}
|
||||
} else {
|
||||
args = append(args, "test", "-v", "tests")
|
||||
}
|
||||
@ -444,6 +460,7 @@ func main() {
|
||||
}
|
||||
|
||||
fmt.Println("tools for apigo.cloud")
|
||||
fmt.Println("version ", version)
|
||||
fmt.Println()
|
||||
fmt.Println("Usage:")
|
||||
fmt.Println(" ", u.Cyan("ag [command] [...]"))
|
||||
|
Loading…
Reference in New Issue
Block a user