Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
7bf7bd2f
Commit
7bf7bd2f
authored
Nov 20, 2018
by
Javier Peletier
Committed by
Viktor Trón
Nov 20, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
internal/cmdtest: Expose process exit status and errors (#18046)
parent
d31f1f4f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
2 deletions
+19
-2
test_cmd.go
internal/cmdtest/test_cmd.go
+19
-2
No files found.
internal/cmdtest/test_cmd.go
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.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment