Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
55e8357c
Commit
55e8357c
authored
Feb 11, 2015
by
Filipe Brandenburger
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4339 from zmerlynn/issue_4177
Fix hack/e2e.go exit status for -test
parents
1df34358
f08f7e69
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
44 deletions
+11
-44
e2e.go
hack/e2e.go
+11
-44
No files found.
hack/e2e.go
View file @
55e8357c
...
...
@@ -146,21 +146,21 @@ func main() {
}
}
failure
:=
fals
e
success
:=
tru
e
switch
{
case
*
ctlCmd
!=
""
:
ctlArgs
:=
strings
.
Fields
(
*
ctlCmd
)
os
.
Setenv
(
"KUBE_CONFIG_FILE"
,
"config-test.sh"
)
failure
=
!
finishRunning
(
"'kubectl "
+*
ctlCmd
+
"'"
,
exec
.
Command
(
path
.
Join
(
versionRoot
,
"cluster/kubectl.sh"
),
ctlArgs
...
))
success
=
finishRunning
(
"'kubectl "
+*
ctlCmd
+
"'"
,
exec
.
Command
(
path
.
Join
(
versionRoot
,
"cluster/kubectl.sh"
),
ctlArgs
...
))
case
*
test
:
failure
=
Test
()
success
=
Test
()
}
if
*
down
{
TearDown
()
}
if
failure
{
if
!
success
{
os
.
Exit
(
1
)
}
}
...
...
@@ -277,8 +277,8 @@ func Test() bool {
// call the returned anonymous function to stop.
func
runBashUntil
(
stepName
string
,
cmd
*
exec
.
Cmd
)
func
()
{
log
.
Printf
(
"Running in background: %v"
,
stepName
)
stdout
,
stderr
:=
bytes
.
NewBuffer
(
nil
),
bytes
.
NewBuffer
(
nil
)
cmd
.
Stdout
,
cmd
.
Stderr
=
stdout
,
stderr
output
:=
bytes
.
NewBuffer
(
nil
)
cmd
.
Stdout
,
cmd
.
Stderr
=
output
,
output
if
err
:=
cmd
.
Start
();
err
!=
nil
{
log
.
Printf
(
"Unable to start '%v': '%v'"
,
stepName
,
err
)
return
func
()
{}
...
...
@@ -287,7 +287,7 @@ func runBashUntil(stepName string, cmd *exec.Cmd) func() {
cmd
.
Process
.
Signal
(
os
.
Interrupt
)
headerprefix
:=
stepName
+
" "
lineprefix
:=
" "
printBashOutputs
(
headerprefix
,
lineprefix
,
string
(
stdout
.
Bytes
()),
string
(
stderr
.
Bytes
()),
false
)
printBashOutputs
(
headerprefix
,
lineprefix
,
string
(
output
.
Bytes
()),
false
)
}
}
...
...
@@ -327,44 +327,11 @@ func finishRunning(stepName string, cmd *exec.Cmd) bool {
return
result
}
func
printBashOutputs
(
headerprefix
,
lineprefix
,
stdout
,
stderr
string
,
escape
bool
)
{
// The |'s (plus appropriate prefixing) are to make this look
// "YAMLish" to the Jenkins TAP plugin:
// https://wiki.jenkins-ci.org/display/JENKINS/TAP+Plugin
if
stdout
!=
""
{
fmt
.
Printf
(
"%vstdout: |
\n
"
,
headerprefix
)
if
escape
{
stdout
=
escapeOutput
(
stdout
)
}
printPrefixedLines
(
lineprefix
,
stdout
)
}
if
stderr
!=
""
{
fmt
.
Printf
(
"%vstderr: |
\n
"
,
headerprefix
)
if
escape
{
stderr
=
escapeOutput
(
stderr
)
}
printPrefixedLines
(
lineprefix
,
stderr
)
}
}
// Escape stdout/stderr so the Jenkins YAMLish parser doesn't barf on
// it. This escaping is crude (it masks all colons as something humans
// will hopefully see as a colon, for instance), but it should get the
// job done without pulling in a whole YAML package.
func
escapeOutput
(
s
string
)
(
out
string
)
{
for
_
,
r
:=
range
s
{
switch
{
case
r
==
'\n'
:
out
+=
string
(
r
)
case
!
strconv
.
IsPrint
(
r
)
:
out
+=
" "
case
r
==
':'
:
out
+=
"
\ua789
"
// "꞉", modifier letter colon
default
:
out
+=
string
(
r
)
}
func
printBashOutputs
(
headerprefix
,
lineprefix
,
output
string
,
escape
bool
)
{
if
output
!=
""
{
fmt
.
Printf
(
"%voutput: |
\n
"
,
headerprefix
)
printPrefixedLines
(
lineprefix
,
output
)
}
return
}
func
printPrefixedLines
(
prefix
,
s
string
)
{
...
...
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