test: disable log and output to speed up testing

This commit is contained in:
Li Jie
2025-01-18 16:42:11 +08:00
parent 977db86700
commit a9ee323760
2 changed files with 17 additions and 0 deletions

View File

@@ -17,6 +17,9 @@
package cl_test package cl_test
import ( import (
"io"
"log"
"os"
"testing" "testing"
"github.com/goplus/llgo/compiler/cl" "github.com/goplus/llgo/compiler/cl"
@@ -24,6 +27,13 @@ import (
"github.com/goplus/llgo/compiler/internal/build" "github.com/goplus/llgo/compiler/internal/build"
) )
func init() {
devNull, _ := os.OpenFile(os.DevNull, os.O_WRONLY, 0)
os.Stderr = devNull
os.Stdout = devNull
log.SetOutput(io.Discard)
}
func testCompile(t *testing.T, src, expected string) { func testCompile(t *testing.T, src, expected string) {
t.Helper() t.Helper()
cltest.TestCompileEx(t, src, "foo.go", expected, false) cltest.TestCompileEx(t, src, "foo.go", expected, false)

View File

@@ -18,6 +18,9 @@ package ssa_test
import ( import (
"go/types" "go/types"
"io"
"log"
"os"
"testing" "testing"
"github.com/goplus/llgo/compiler/cl/cltest" "github.com/goplus/llgo/compiler/cl/cltest"
@@ -26,6 +29,10 @@ import (
) )
func init() { func init() {
devNull, _ := os.OpenFile(os.DevNull, os.O_WRONLY, 0)
os.Stderr = devNull
os.Stdout = devNull
log.SetOutput(io.Discard)
ssa.SetDebug(ssa.DbgFlagAll) ssa.SetDebug(ssa.DbgFlagAll)
} }