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
ff23b679
Commit
ff23b679
authored
May 07, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
packer/plugin: error if command can't start
parent
f601625f
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
13 deletions
+31
-13
packer/plugin/command.go
packer/plugin/command.go
+7
-3
packer/plugin/command_test.go
packer/plugin/command_test.go
+24
-0
packer/plugin/plugin_test.go
packer/plugin/plugin_test.go
+0
-10
No files found.
packer/plugin/command.go
View file @
ff23b679
...
@@ -10,7 +10,7 @@ import (
...
@@ -10,7 +10,7 @@ import (
"time"
"time"
)
)
func
Command
(
cmd
*
exec
.
Cmd
)
packer
.
Command
{
func
Command
(
cmd
*
exec
.
Cmd
)
(
result
packer
.
Command
,
err
error
)
{
env
:=
[]
string
{
env
:=
[]
string
{
"PACKER_PLUGIN_MIN_PORT=10000"
,
"PACKER_PLUGIN_MIN_PORT=10000"
,
"PACKER_PLUGIN_MAX_PORT=25000"
,
"PACKER_PLUGIN_MAX_PORT=25000"
,
...
@@ -19,7 +19,10 @@ func Command(cmd *exec.Cmd) packer.Command {
...
@@ -19,7 +19,10 @@ func Command(cmd *exec.Cmd) packer.Command {
out
:=
new
(
bytes
.
Buffer
)
out
:=
new
(
bytes
.
Buffer
)
cmd
.
Env
=
append
(
cmd
.
Env
,
env
...
)
cmd
.
Env
=
append
(
cmd
.
Env
,
env
...
)
cmd
.
Stdout
=
out
cmd
.
Stdout
=
out
cmd
.
Start
()
err
=
cmd
.
Start
()
if
err
!=
nil
{
return
}
// TODO: timeout
// TODO: timeout
// TODO: check that command is even running
// TODO: check that command is even running
...
@@ -39,5 +42,6 @@ func Command(cmd *exec.Cmd) packer.Command {
...
@@ -39,5 +42,6 @@ func Command(cmd *exec.Cmd) packer.Command {
panic
(
err
)
panic
(
err
)
}
}
return
packrpc
.
Command
(
client
)
result
=
packrpc
.
Command
(
client
)
return
}
}
packer/plugin/command_test.go
0 → 100644
View file @
ff23b679
package
plugin
import
(
"cgl.tideland.biz/asserts"
"os/exec"
"testing"
)
func
TestCommand_NoExist
(
t
*
testing
.
T
)
{
assert
:=
asserts
.
NewTestingAsserts
(
t
,
true
)
_
,
err
:=
Command
(
exec
.
Command
(
"i-should-never-ever-ever-exist"
))
assert
.
NotNil
(
err
,
"should have an error"
)
}
func
TestCommand_Good
(
t
*
testing
.
T
)
{
assert
:=
asserts
.
NewTestingAsserts
(
t
,
true
)
command
,
err
:=
Command
(
helperProcess
(
"command"
))
assert
.
Nil
(
err
,
"should start command properly"
)
result
:=
command
.
Synopsis
()
assert
.
Equal
(
result
,
"1"
,
"should return result"
)
}
packer/plugin/plugin_test.go
View file @
ff23b679
package
plugin
package
plugin
import
(
import
(
"cgl.tideland.biz/asserts"
"github.com/mitchellh/packer/packer"
"github.com/mitchellh/packer/packer"
"os"
"os"
"os/exec"
"os/exec"
...
@@ -32,15 +31,6 @@ func helperProcess(s... string) *exec.Cmd {
...
@@ -32,15 +31,6 @@ func helperProcess(s... string) *exec.Cmd {
return
cmd
return
cmd
}
}
func
TestClient
(
t
*
testing
.
T
)
{
assert
:=
asserts
.
NewTestingAsserts
(
t
,
true
)
command
:=
Command
(
helperProcess
(
"command"
))
result
:=
command
.
Synopsis
()
assert
.
Equal
(
result
,
"1"
,
"should return result"
)
}
// This is not a real test. This is just a helper process kicked off by
// This is not a real test. This is just a helper process kicked off by
// tests.
// tests.
func
TestHelperProcess
(
*
testing
.
T
)
{
func
TestHelperProcess
(
*
testing
.
T
)
{
...
...
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