"ag test" support run case in tests dir for test client project
This commit is contained in:
parent
b9254c1e6f
commit
a03cd6df88
17
main.go
17
main.go
@ -14,6 +14,8 @@ import (
|
|||||||
"text/template"
|
"text/template"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var version = "v0.0.6"
|
||||||
|
|
||||||
//go:embed templates/_makePluginCode.go
|
//go:embed templates/_makePluginCode.go
|
||||||
var makePluginCodeTPL string
|
var makePluginCodeTPL string
|
||||||
|
|
||||||
@ -210,7 +212,21 @@ func _testProject(args []string, isWatch bool) {
|
|||||||
if isWatch {
|
if isWatch {
|
||||||
args = append(args, "-p", "..")
|
args = append(args, "-p", "..")
|
||||||
}
|
}
|
||||||
|
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", ".")
|
args = append(args, "test", "-v", ".")
|
||||||
|
} else {
|
||||||
|
args = append(args, "run", ".")
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
args = append(args, "test", "-v", "tests")
|
args = append(args, "test", "-v", "tests")
|
||||||
}
|
}
|
||||||
@ -444,6 +460,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("tools for apigo.cloud")
|
fmt.Println("tools for apigo.cloud")
|
||||||
|
fmt.Println("version ", version)
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
fmt.Println("Usage:")
|
fmt.Println("Usage:")
|
||||||
fmt.Println(" ", u.Cyan("ag [command] [...]"))
|
fmt.Println(" ", u.Cyan("ag [command] [...]"))
|
||||||
|
Loading…
Reference in New Issue
Block a user