1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
//go:build windows
// +build windows
package system
import (
"os/exec"
"testing"
)
func TestCommandWrapper(t *testing.T) {
t.Parallel()
c := commandWrapper("echo hello world")
cmdPath, _ := exec.LookPath(windowsShell)
if c.Cmd.Path != cmdPath {
t.Errorf("Command not wrapped properly for Windows os. got %s, want: %s", c.Cmd.Path, cmdPath)
}
if c.Cmd.SysProcAttr.CmdLine != "/c echo hello world" {
t.Errorf("Command not wrapped properly for Windows cmd.exe. got %s, want: %s", c.Cmd.SysProcAttr.CmdLine, "/c echo hello world")
}
if len(c.Cmd.Args) != 1 {
t.Errorf("Args length should be blank. got: %d, want: %d", len(c.Cmd.Args), 1)
}
}
|