-
Notifications
You must be signed in to change notification settings - Fork 712
[CI]: quality of life: minor debugging output fixes #4111
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -70,6 +70,7 @@ type Result struct { | |
| Stderr string | ||
| ExitCode int | ||
| Signal os.Signal | ||
| Duration time.Duration | ||
| } | ||
|
|
||
| type execution struct { | ||
|
|
@@ -102,9 +103,10 @@ type Command struct { | |
| ptyStderr bool | ||
| ptyStdin bool | ||
|
|
||
| exec *execution | ||
| mutex sync.Mutex | ||
| result *Result | ||
| exec *execution | ||
| mutex sync.Mutex | ||
| result *Result | ||
| startTime time.Time | ||
| } | ||
|
|
||
| // Clone does just duplicate a command, resetting its execution. | ||
|
|
@@ -184,12 +186,12 @@ func (gc *Command) Run(parentCtx context.Context) error { | |
| ) | ||
|
|
||
| // Get a timing-out context | ||
| timeout := gc.Timeout | ||
| if timeout == 0 { | ||
| timeout = defaultTimeout | ||
| if gc.Timeout == 0 { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix |
||
| gc.Timeout = defaultTimeout | ||
| } | ||
|
|
||
| ctx, ctxCancel = context.WithTimeout(parentCtx, timeout) | ||
| ctx, ctxCancel = context.WithTimeout(parentCtx, gc.Timeout) | ||
| gc.startTime = time.Now() | ||
|
|
||
| // Create a contextual command, set the logger | ||
| cmd = gc.buildCommand(ctx) | ||
|
|
@@ -366,6 +368,7 @@ func (gc *Command) wrap() error { | |
| Stderr: pipes.fromStderr, | ||
| Environ: cmd.Environ(), | ||
| Signal: signal, | ||
| Duration: time.Since(gc.startTime), | ||
| } | ||
|
|
||
| if gc.exec.err == nil { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -108,7 +108,10 @@ func chunk(s string, maxLength, maxLines int) []string { | |
| } | ||
|
|
||
| if len(chunks) > maxLines { | ||
| chunks = append(chunks[0:maxLines], "...") | ||
| abbreviator := "..." | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of stripping anything after line |
||
| chunks = append( | ||
| append(chunks[0:maxLines/2], abbreviator+strings.Repeat(spacer, maxLength-len(abbreviator))), | ||
| chunks[len(chunks)-maxLines/2:]...) | ||
| } else if len(chunks) == 0 { | ||
| chunks = []string{strings.Repeat(spacer, maxLength)} | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,6 +39,10 @@ const ( | |
| exitDecorator = "⚠️" | ||
| stdoutDecorator = "🟢" | ||
| stderrDecorator = "🟠" | ||
| timeoutDecorator = "⏰" | ||
| cwdDecorator = "📁" | ||
| envDecorator = "🌱" | ||
| sigDecorator = "⚡" | ||
| ) | ||
|
|
||
| // CustomizableCommand is an interface meant for people who want to heavily customize the base | ||
|
|
@@ -138,6 +142,10 @@ func (gc *GenericCommand) WithBlacklist(env []string) { | |
| gc.cmd.EnvBlackList = env | ||
| } | ||
|
|
||
| func (gc *GenericCommand) WithWhitelist(env []string) { | ||
| gc.cmd.EnvWhiteList = env | ||
| } | ||
|
|
||
| func (gc *GenericCommand) WithTimeout(timeout time.Duration) { | ||
| gc.cmd.Timeout = timeout | ||
| } | ||
|
|
@@ -193,12 +201,18 @@ func (gc *GenericCommand) Run(expect *Expected) { | |
| } | ||
|
|
||
| if result.Signal != nil { | ||
| debug = append(debug, []any{"Signal", result.Signal.String()}) | ||
| debug = append(debug, []any{"", sigDecorator + " " + result.Signal.String()}) | ||
| } | ||
|
|
||
| duration := result.Duration.String() | ||
| if result.Duration < time.Second { | ||
| duration = "<1s" | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do not want to see |
||
| } | ||
|
|
||
| debug = append(debug, | ||
| []any{"Limit", gc.cmd.Timeout}, | ||
| []any{"Environ", strings.Join(result.Environ, "\n")}, | ||
| []any{envDecorator, strings.Join(result.Environ, "\n")}, | ||
| []any{timeoutDecorator, duration + " (limit: " + gc.cmd.Timeout.String() + ")"}, | ||
| []any{cwdDecorator, gc.cmd.WorkingDir}, | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Show cwd and better duration info. |
||
| ) | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -82,17 +82,14 @@ func newNerdCommand(conf test.Config, t *testing.T) *nerdCommand { | |
| } | ||
|
|
||
| ret.WithBinary(binary) | ||
| // Not interested in these - and insulate us from parent environment side effects | ||
| ret.WithBlacklist([]string{ | ||
| "LS_COLORS", | ||
| "DOCKER_CONFIG", | ||
| "CONTAINERD_SNAPSHOTTER", | ||
| "NERDCTL_TOML", | ||
| "CONTAINERD_ADDRESS", | ||
| "CNI_PATH", | ||
| "NETCONFPATH", | ||
| "NERDCTL_EXPERIMENTAL", | ||
| "NERDCTL_HOST_GATEWAY_IP", | ||
| ret.WithWhitelist([]string{ | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use whitelist to tame os.Environ on the CI. |
||
| "PATH", | ||
| "HOME", | ||
| "XDG_*", | ||
| // Windows needs ProgramData, AppData, etc | ||
| "Program*", | ||
| "PROGRAM*", | ||
| "APPDATA", | ||
| }) | ||
| return ret | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Store command execution time.