mirror of
https://github.com/duke-git/lancet.git
synced 2026-02-17 11:12:28 +08:00
fix: fix ExecCommand bug forwindows
This commit is contained in:
@@ -44,21 +44,26 @@ func TestOsEnvOperation(t *testing.T) {
|
||||
func TestExecCommand(t *testing.T) {
|
||||
assert := internal.NewAssert(t, "TestExecCommand")
|
||||
|
||||
out, errout, err := ExecCommand("ls")
|
||||
t.Log("std out: ", out)
|
||||
t.Log("std err: ", errout)
|
||||
// linux or mac
|
||||
stdout, stderr, err := ExecCommand("ls")
|
||||
t.Log("std out: ", stdout)
|
||||
t.Log("std err: ", stderr)
|
||||
assert.Equal("", stderr)
|
||||
assert.IsNil(err)
|
||||
|
||||
out, errout, err = ExecCommand("abc")
|
||||
t.Log("std out: ", out)
|
||||
t.Log("std err: ", errout)
|
||||
if err != nil {
|
||||
t.Logf("error: %v\n", err)
|
||||
// windows
|
||||
stdout, stderr, err = ExecCommand("dir")
|
||||
t.Log("std out: ", stdout)
|
||||
t.Log("std err: ", stderr)
|
||||
if IsWindows() {
|
||||
assert.IsNil(err)
|
||||
}
|
||||
|
||||
if !IsWindows() {
|
||||
assert.IsNotNil(err)
|
||||
}
|
||||
// error command
|
||||
stdout, stderr, err = ExecCommand("abc")
|
||||
t.Log("std out: ", stdout)
|
||||
t.Log("std err: ", stderr)
|
||||
assert.IsNotNil(err)
|
||||
}
|
||||
|
||||
func TestGetOsBits(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user