Print PASS on pass when running standalone test binaries (#3229)
* Add test.batch flag so standalone tests print PASS on pass * Add comment; use single-dash flag style to match usage elsewhere * Don't add test.batch for wasmtime * Skip test.batch unless emulator name is blank * Remove test.batch flag; buffer test output and show only on verbose or failure * Remove FAIL when all tests fail to match go test output
Этот коммит содержится в:
родитель
5937f03a07
коммит
b734b3c7a1
2 изменённых файлов: 7 добавлений и 5 удалений
8
main.go
8
main.go
|
@ -235,8 +235,9 @@ func Test(pkgName string, stdout, stderr io.Writer, options *compileopts.Options
|
|||
flags = append(flags, "-test.benchmem")
|
||||
}
|
||||
|
||||
buf := bytes.Buffer{}
|
||||
passed := false
|
||||
err = buildAndRun(pkgName, config, os.Stdout, flags, nil, 0, func(cmd *exec.Cmd, result builder.BuildResult) error {
|
||||
err = buildAndRun(pkgName, config, &buf, flags, nil, 0, func(cmd *exec.Cmd, result builder.BuildResult) error {
|
||||
if testCompileOnly || outpath != "" {
|
||||
// Write test binary to the specified file name.
|
||||
if outpath == "" {
|
||||
|
@ -308,8 +309,12 @@ func Test(pkgName string, stdout, stderr io.Writer, options *compileopts.Options
|
|||
importPath := strings.TrimSuffix(result.ImportPath, ".test")
|
||||
passed = err == nil
|
||||
if passed {
|
||||
if testVerbose {
|
||||
buf.WriteTo(stdout)
|
||||
}
|
||||
fmt.Fprintf(stdout, "ok \t%s\t%.3fs\n", importPath, duration.Seconds())
|
||||
} else {
|
||||
buf.WriteTo(stdout)
|
||||
fmt.Fprintf(stdout, "FAIL\t%s\t%.3fs\n", importPath, duration.Seconds())
|
||||
}
|
||||
if _, ok := err.(*exec.ExitError); ok {
|
||||
|
@ -1657,7 +1662,6 @@ func main() {
|
|||
wg.Wait()
|
||||
close(fail)
|
||||
if _, fail := <-fail; fail {
|
||||
fmt.Println("FAIL")
|
||||
os.Exit(1)
|
||||
}
|
||||
case "monitor":
|
||||
|
|
|
@ -449,9 +449,7 @@ func (m *M) Run() (code int) {
|
|||
fmt.Println("FAIL")
|
||||
m.exitCode = 1
|
||||
} else {
|
||||
if flagVerbose {
|
||||
fmt.Println("PASS")
|
||||
}
|
||||
fmt.Println("PASS")
|
||||
m.exitCode = 0
|
||||
}
|
||||
return
|
||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче