mirror of
https://github.com/duke-git/lancet.git
synced 2026-11-16 05:12:11 +08:00
fix(package): [system] keep the whole command name in GetProcessInfo (#426)
* fix(package): [system] keep the whole command name in GetProcessInfo * test(package): [system] cover a command name with spaces
This commit is contained in:
1 parent
1715d14cc8
commit
b4302b2d15
2 files changed
+20
-1
No files matched your search
@@ -2,6 +2,7 @@ package system
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -142,3 +143,21 @@ func TestGetProcessInfo(t *testing.T) {
|
||||
|
||||
t.Log(processInfo)
|
||||
}
|
||||
|
||||
func TestParseProcessInfo_commandWithSpaces(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
if runtime.GOOS == "windows" {
|
||||
t.Skip("parses ps output")
|
||||
}
|
||||
|
||||
assert := internal.NewAssert(t, "TestParseProcessInfo_commandWithSpaces")
|
||||
|
||||
output := []byte(" PID %CPU %MEM STAT USER COMM\n 4242 0.1 0.2 S root Google Chrome Helper\n")
|
||||
|
||||
info, err := parseProcessInfo(output, 4242)
|
||||
assert.IsNil(err)
|
||||
assert.Equal("Google Chrome Helper", info.Cmd)
|
||||
assert.Equal("root", info.User)
|
||||
assert.Equal("S", info.State)
|
||||
}
|
||||
Reference in new issue
Block a user