Something went wrong. Try again.
🌱 A minimal programming language and compiler. git.urbach.dev/cli/q
high-performance programming-language compiler
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677package verbose_test
import ( "io" "os" "path/filepath" "strings" "testing"
"git.urbach.dev/cli/q/src/compiler" "git.urbach.dev/cli/q/src/config" "git.urbach.dev/cli/q/src/fs" "git.urbach.dev/cli/q/src/verbose" "git.urbach.dev/go/assert" "git.urbach.dev/go/color")
func TestVerboseOutput(t *testing.T) { examples := "../../examples"
fs.Walk(examples, func(dir string) { t.Run(dir, func(t *testing.T) { b := config.New(filepath.Join(examples, dir)) test(t, b) }) })
tests := "../../tests"
fs.Walk(tests, func(file string) { if !strings.HasSuffix(file, ".q") { return }
t.Run(file, func(t *testing.T) { b := config.New(filepath.Join(tests, file)) b.Lint(false) test(t, b) }) })}
func test(t *testing.T, b *config.Build) { originalOut := ""
for range 3 { env, err := compiler.Compile(b) assert.Nil(t, err)
// Capture output stdout := os.Stdout reader, writer, err := os.Pipe() assert.Nil(t, err) color.Redirect(writer) channel := make(chan string)
go func() { out, err := io.ReadAll(reader) assert.Nil(t, err) assert.NotNil(t, out) channel <- string(out) }()
verbose.ASM(env, "") verbose.SSA(env, "")
writer.Close() color.Redirect(stdout) out := <-channel
if originalOut == "" { originalOut = out } else { assert.Equal(t, out, originalOut) } }}