Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
packer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kristopher Ruzic
packer
Commits
bbc5f305
Commit
bbc5f305
authored
Jun 03, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
packer: RemoteCmd.Wait
parent
fdda64f4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
0 deletions
+33
-0
packer/communicator.go
packer/communicator.go
+8
-0
packer/communicator_test.go
packer/communicator_test.go
+25
-0
No files found.
packer/communicator.go
View file @
bbc5f305
...
@@ -2,6 +2,7 @@ package packer
...
@@ -2,6 +2,7 @@ package packer
import
(
import
(
"io"
"io"
"time"
)
)
// RemoteCmd represents a remote command being prepared or run.
// RemoteCmd represents a remote command being prepared or run.
...
@@ -42,3 +43,10 @@ type Communicator interface {
...
@@ -42,3 +43,10 @@ type Communicator interface {
Upload
(
string
,
io
.
Reader
)
error
Upload
(
string
,
io
.
Reader
)
error
Download
(
string
,
io
.
Writer
)
error
Download
(
string
,
io
.
Writer
)
error
}
}
// Wait waits for the remote command to complete.
func
(
r
*
RemoteCmd
)
Wait
()
{
for
!
r
.
Exited
{
time
.
Sleep
(
50
*
time
.
Millisecond
)
}
}
packer/communicator_test.go
View file @
bbc5f305
package
packer
package
packer
import
(
"testing"
"time"
)
func
TestRemoteCmd_Wait
(
t
*
testing
.
T
)
{
var
cmd
RemoteCmd
result
:=
make
(
chan
bool
)
go
func
()
{
cmd
.
Wait
()
result
<-
true
}()
cmd
.
ExitStatus
=
42
cmd
.
Exited
=
true
select
{
case
<-
result
:
// Success
case
<-
time
.
After
(
500
*
time
.
Millisecond
)
:
t
.
Fatal
(
"never got exit notification"
)
}
}
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