good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
7bf7bd2f
Commit
7bf7bd2f
authored
6 years ago
by
Javier Peletier
Committed by
Viktor Trón
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
internal/cmdtest: Expose process exit status and errors (#18046)
parent
d31f1f4f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
internal/cmdtest/test_cmd.go
+19
-2
19 additions, 2 deletions
internal/cmdtest/test_cmd.go
with
19 additions
and
2 deletions
internal/cmdtest/test_cmd.go
+
19
−
2
View file @
7bf7bd2f
...
@@ -27,6 +27,7 @@ import (
...
@@ -27,6 +27,7 @@ import (
"regexp"
"regexp"
"strings"
"strings"
"sync"
"sync"
"syscall"
"testing"
"testing"
"text/template"
"text/template"
"time"
"time"
...
@@ -50,6 +51,8 @@ type TestCmd struct {
...
@@ -50,6 +51,8 @@ type TestCmd struct {
stdout
*
bufio
.
Reader
stdout
*
bufio
.
Reader
stdin
io
.
WriteCloser
stdin
io
.
WriteCloser
stderr
*
testlogger
stderr
*
testlogger
// Err will contain the process exit error or interrupt signal error
Err
error
}
}
// Run exec's the current binary using name as argv[0] which will trigger the
// Run exec's the current binary using name as argv[0] which will trigger the
...
@@ -182,11 +185,25 @@ func (tt *TestCmd) ExpectExit() {
...
@@ -182,11 +185,25 @@ func (tt *TestCmd) ExpectExit() {
}
}
func
(
tt
*
TestCmd
)
WaitExit
()
{
func
(
tt
*
TestCmd
)
WaitExit
()
{
tt
.
cmd
.
Wait
()
tt
.
Err
=
tt
.
cmd
.
Wait
()
}
}
func
(
tt
*
TestCmd
)
Interrupt
()
{
func
(
tt
*
TestCmd
)
Interrupt
()
{
tt
.
cmd
.
Process
.
Signal
(
os
.
Interrupt
)
tt
.
Err
=
tt
.
cmd
.
Process
.
Signal
(
os
.
Interrupt
)
}
// ExitStatus exposes the process' OS exit code
// It will only return a valid value after the process has finished.
func
(
tt
*
TestCmd
)
ExitStatus
()
int
{
if
tt
.
Err
!=
nil
{
exitErr
:=
tt
.
Err
.
(
*
exec
.
ExitError
)
if
exitErr
!=
nil
{
if
status
,
ok
:=
exitErr
.
Sys
()
.
(
syscall
.
WaitStatus
);
ok
{
return
status
.
ExitStatus
()
}
}
}
return
0
}
}
// StderrText returns any stderr output written so far.
// StderrText returns any stderr output written so far.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment