mirror of
https://github.com/fatedier/frp.git
synced 2026-01-11 22:23:12 +00:00
refactor ci test
This commit is contained in:
29
tests/util/process.go
Normal file
29
tests/util/process.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
type Process struct {
|
||||
cmd *exec.Cmd
|
||||
cancel context.CancelFunc
|
||||
}
|
||||
|
||||
func NewProcess(path string, params []string) *Process {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
cmd := exec.CommandContext(ctx, path, params...)
|
||||
return &Process{
|
||||
cmd: cmd,
|
||||
cancel: cancel,
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Process) Start() error {
|
||||
return p.cmd.Start()
|
||||
}
|
||||
|
||||
func (p *Process) Stop() error {
|
||||
p.cancel()
|
||||
return p.cmd.Wait()
|
||||
}
|
||||
Reference in New Issue
Block a user