github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/builtins/core/management/fexec_test.go (about) 1 package management_test 2 3 import ( 4 "fmt" 5 "testing" 6 7 _ "github.com/lmorg/murex/builtins" 8 "github.com/lmorg/murex/test" 9 ) 10 11 func TestFexec(t *testing.T) { 12 tests := []test.MurexTest{ 13 { 14 Block: `fexec help -> [help]`, 15 Stdout: "help", 16 }, 17 { 18 Block: `fexec builtin out "foobar"`, 19 Stdout: "foobar", 20 }, 21 { 22 Block: fmt.Sprintf(` 23 function pub.%s { out "foobar" } 24 fexec function pub.%s`, 25 t.Name(), t.Name(), 26 ), 27 Stdout: "foobar", 28 }, 29 { 30 Block: fmt.Sprintf(` 31 private pvt.%s { out "foobar" } 32 fexec private /murex/%s/pvt.%s; runtime --privates`, 33 t.Name(), t.Name(), t.Name(), 34 ), 35 Stdout: "foobar", 36 }, 37 } 38 39 test.RunMurexTestsRx(tests, t) 40 } 41 42 func TestFexecErrors(t *testing.T) { 43 tests := []test.MurexTest{ 44 { 45 Block: `fexec khlkwajfhldskjfhasdlkjfhaskdljfhasd`, 46 Stderr: "invalid flag", 47 ExitNum: 1, 48 }, 49 { 50 Block: `fexec builtin dslahfaksdljhfkasdjhflsdjahf`, 51 Stderr: "no builtin", 52 ExitNum: 1, 53 }, 54 { 55 Block: `fexec function dslahfaksdljhfkasdjhflsdjahf`, 56 Stderr: "cannot locate function", 57 ExitNum: 1, 58 }, 59 { 60 Block: `fexec private dslahfaksdljhfkasdjhflsdjahf`, 61 Stderr: "no private functions", 62 ExitNum: 1, 63 }, 64 } 65 66 test.RunMurexTestsRx(tests, t) 67 }