Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tests for nomad/client/driver/spawn package to work on Windows. #442

Merged
merged 4 commits into from
Nov 20, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions client/driver/spawn/spawn.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ func (s *Spawner) Spawn(cb func(pid int) error) error {
}

exitFile, err := os.OpenFile(s.StateFile, os.O_CREATE|os.O_WRONLY, 0666)
defer exitFile.Close()
if err != nil {
return fmt.Errorf("Error opening file to store exit status: %v", err)
}
defer exitFile.Close()

config, err := s.spawnConfig()
if err != nil {
Expand All @@ -87,17 +87,17 @@ func (s *Spawner) Spawn(cb func(pid int) error) error {

// Capture stdout
spawnStdout, err := spawn.StdoutPipe()
defer spawnStdout.Close()
if err != nil {
return fmt.Errorf("Failed to capture spawn-daemon stdout: %v", err)
}
defer spawnStdout.Close()

// Capture stdin.
spawnStdin, err := spawn.StdinPipe()
defer spawnStdin.Close()
if err != nil {
return fmt.Errorf("Failed to capture spawn-daemon stdin: %v", err)
}
defer spawnStdin.Close()

if err := spawn.Start(); err != nil {
return fmt.Errorf("Failed to call spawn-daemon on nomad executable: %v", err)
Expand Down Expand Up @@ -264,10 +264,10 @@ func (s *Spawner) pollWait() *structs.WaitResult {
// returns an error if the file can't be read.
func (s *Spawner) readExitCode() *structs.WaitResult {
f, err := os.Open(s.StateFile)
defer f.Close()
if err != nil {
return structs.NewWaitResult(-1, 0, fmt.Errorf("Failed to open %v to read exit code: %v", s.StateFile, err))
}
defer f.Close()

stat, err := f.Stat()
if err != nil {
Expand All @@ -289,7 +289,7 @@ func (s *Spawner) readExitCode() *structs.WaitResult {

// Valid checks that the state of the Spawner is valid and that a subsequent
// Wait could be called. This is useful to call when reopening a Spawner
// throught client restarts. If Valid a nil error is returned.
// through client restarts. If Valid a nil error is returned.
func (s *Spawner) Valid() error {
// If the spawner is still alive, then the task is running and we can wait
// on it.
Expand Down
Loading