Skip to content

Commit

Permalink
print the whole error output on appium command error
Browse files Browse the repository at this point in the history
  • Loading branch information
shamanec committed Jun 12, 2024
1 parent 9ebcf55 commit 47e284f
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion provider/devices/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -575,13 +575,30 @@ func startAppium(device *models.Device) {
return
}

stderr, err := cmd.StderrPipe()
if err != nil {
logger.ProviderLogger.LogError("device_setup", fmt.Sprintf("startAppium: Error creating stderrpipe on `%s` for device `%v` - %v", cmd.Args, device.UDID, err))
resetLocalDevice(device)
return
}

err = cmd.Start()
if err != nil {
logger.ProviderLogger.LogError("device_setup", fmt.Sprintf("startAppium: Error executing `%s` for device `%v` - %v", cmd.Args, device.UDID, err))
resetLocalDevice(device)
return
}

// Buffer to collect stderr output
var stderrBuffer bytes.Buffer
stderrScanner := bufio.NewScanner(stderr)
go func() {
for stderrScanner.Scan() {
line := stderrScanner.Text()
stderrBuffer.WriteString(line + "\n")
}
}()

// Create a scanner to read the command's output line by line
scanner := bufio.NewScanner(stdout)

Expand All @@ -592,7 +609,7 @@ func startAppium(device *models.Device) {

err = cmd.Wait()
if err != nil {
logger.ProviderLogger.LogError("device_setup", fmt.Sprintf("startAppium: Error waiting for `%s` command to finish, it errored out or device `%v` was disconnected - %v", cmd.Args, device.UDID, err))
logger.ProviderLogger.LogError("device_setup", fmt.Sprintf("startAppium: Error waiting for `%s` command to finish, it errored out or device `%v` was disconnected - %v - %s", cmd.Args, device.UDID, err, stderrBuffer.String()))
resetLocalDevice(device)
}
}
Expand Down

0 comments on commit 47e284f

Please sign in to comment.