asdf/internal/exec/exec_test.go
Trevor Brown d2afb85eb8 feat(golang-rewrite): create asdf which command
* create asdf which command
* enable which_command.bats tests
* add more info to NoExecutableForPluginError
* Write tests for shims.GetExecutablePath function
* Use plugin `exec-path` callback when present to compute executable
path
2024-12-18 11:32:02 -05:00

34 lines
544 B
Go

package exec
import (
"fmt"
"os"
"os/exec"
"testing"
"github.com/rogpeppe/go-internal/testscript"
)
func execit() int {
// Exec only works with absolute path
cmdPath, _ := exec.LookPath(os.Args[1])
err := Exec(cmdPath, os.Args[2:], os.Environ())
if err != nil {
fmt.Printf("Err: %#+v\n", err.Error())
}
return 0
}
func TestMain(m *testing.M) {
os.Exit(testscript.RunMain(m, map[string]func() int{
"execit": execit,
}))
}
func TestExec(t *testing.T) {
testscript.Run(t, testscript.Params{
Dir: "testdata/script",
})
}