diff --git a/internal/utils/utils.go b/internal/utils/utils.go index 16bfa8b..996c0ea 100644 --- a/internal/utils/utils.go +++ b/internal/utils/utils.go @@ -27,7 +27,7 @@ func ExecAndStream(path string, command string, args []string) { err := cmd.Run() if err != nil { - log.Fatalf("cmd.Run() failed with %s\n", err) + fmt.Printf("cmd.Run() failed with %s\n", err) } outStr, errStr := string(stdoutBuf.Bytes()), string(stderrBuf.Bytes()) diff --git a/internal/utils/utils_test.go b/internal/utils/utils_test.go index f053514..840985d 100644 --- a/internal/utils/utils_test.go +++ b/internal/utils/utils_test.go @@ -30,6 +30,27 @@ func ExampleExecAndStream() { // err: } +func ExampleExecAndStreamExecutableNotFound() { + ExecAndStream("/", "testcommand", []string{"Hello"}) + // Output: + // cmd.Run() failed with exec: "testcommand": executable file not found in $PATH + // + // out: + // + // err: +} + +func ExampleExecAndStreamError() { + ExecAndStream("/", "man", []string{"Hello"}) + // Output: + // cmd.Run() failed with exit status 16 + // + // out: + // + // err: + // No manual entry for Hello +} + func TestExecAndGetLines(t *testing.T) { testCommand := "echo" testArguments := []string{"$'Line1\nLine2\nLine3'"}