Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to redirect devserver stdout/stderr to a file #1452

Merged
merged 3 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions testsuite/devserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ type DevServerOptions struct {
LogLevel string
// Additional arguments to the dev server.
ExtraArgs []string
// Where to redirect stdout and stderr, if nil they will be redirected to the current process.
Stdout io.Writer
Stderr io.Writer
}

// Temporal CLI based DevServer
Expand Down Expand Up @@ -111,6 +114,13 @@ func StartDevServer(ctx context.Context, options DevServerOptions) (*DevServer,
args := prepareCommand(&options, host, port, clientOptions.Namespace)

cmd := newCmd(exePath, args...)
if options.Stdout != nil {
cmd.Stdout = options.Stdout
}
if options.Stderr != nil {
cmd.Stderr = options.Stderr
}

clientOptions.Logger.Info("Starting DevServer", "ExePath", exePath, "Args", args)
if err := cmd.Start(); err != nil {
return nil, fmt.Errorf("failed starting: %w", err)
Expand Down
3 changes: 2 additions & 1 deletion testsuite/process_nonwindows.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ import (
// newCmd creates a new command with the given executable path and arguments.
func newCmd(exePath string, args ...string) *exec.Cmd {
cmd := exec.Command(exePath, args...)
cmd.Stdout, cmd.Stderr = os.Stdout, os.Stderr
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
return cmd
}

Expand Down
4 changes: 3 additions & 1 deletion testsuite/process_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ func newCmd(exePath string, args ...string) *exec.Cmd {
// isolate the process and signals sent to it from the current console
CreationFlags: syscall.CREATE_NEW_PROCESS_GROUP,
}
cmd.Stdout, cmd.Stderr = os.Stdout, os.Stderr
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr

return cmd
}

Expand Down
Loading