test: use testmain for setup stuff

testing
Devin Singh 2021-06-15 13:32:16 -05:00
parent 8315dd5e70
commit 7c4bf47080
No known key found for this signature in database
GPG Key ID: 54024EA58DADC781
1 changed files with 4 additions and 2 deletions

View File

@ -7,9 +7,12 @@ import (
"testing"
)
func TestMain(m *testing.M) {
LuaInit()
}
// https://stackoverflow.com/questions/10473800/in-go-how-do-i-capture-stdout-of-a-function-into-a-string
func TestRunInputSh(t *testing.T) {
LuaInit()
cmd := "echo 'hello'"
old := os.Stdout // keep backup of the real stdout
r, w, _ := os.Pipe()
@ -36,7 +39,6 @@ func TestRunInputSh(t *testing.T) {
}
func TestRunInputLua(t *testing.T) {
LuaInit()
cmd := "print('hello')"
old := os.Stdout // keep backup of the real stdout
r, w, _ := os.Pipe()