lib/ADB.rb in ADB-0.5.4 vs lib/ADB.rb in ADB-0.5.5
- old
+ new
@@ -19,11 +19,11 @@
# @param timeout value for the command to complete. Defaults to 30
# seconds.
#
def start_server(timeout=30)
execute_adb_with(timeout, 'start-server')
- raise ADBError, "Server didn't start" unless stdout_contains "daemon started successfully"
+ raise ADBError, "Server didn't start#{stdout_stderr_message}" unless stdout_contains "daemon started successfully"
end
#
# stop the server process
#
@@ -42,11 +42,11 @@
# @param timeout value for the command to complete. Defaults to 30
# seconds.
#
def connect(hostname='localhost', port='5555', timeout=30)
execute_adb_with(timeout, "connect #{hostname}:#{port}")
- raise ADBError, "Could not connect to device at #{hostname}:#{port}" unless stdout_contains "connected to #{hostname}"
+ raise ADBError, "Could not connect to device at #{hostname}:#{port}#{stdout_stderr_message}" unless stdout_contains "connected to #{hostname}"
end
#
# disconnect from a device
#
@@ -93,11 +93,11 @@
# @param timeout value for the command to complete. Defaults to 30
# seconds.
#
def install(installable, options=nil, target={}, timeout=30)
execute_adb_with_exactly(timeout, *"#{which_one(target)} wait-for-device install #{options}".split, installable)
- raise ADBError, "Could not install #{installable}" unless stdout_contains "Success"
+ raise ADBError, "Could not install #{installable}#{stdout_stderr_message}" unless stdout_contains "Success"
end
#
# uninstall an apk file to a device
#
@@ -107,11 +107,11 @@
# @param timeout value for the command to complete. Defaults to 30
# seconds.
#
def uninstall(package, target={}, timeout=30)
execute_adb_with(timeout, "#{which_one(target)} uninstall #{package}")
- raise ADBError, "Could not uninstall #{package}" unless stdout_contains "Success"
+ raise ADBError, "Could not uninstall #{package}#{stdout_stderr_message}" unless stdout_contains "Success"
end
#
# execute shell command
#
@@ -201,9 +201,22 @@
def root(target={}, timeout=30)
execute_adb_with(timeout, "#{which_one(target)} root")
end
private
+
+ def stdout_stderr_message
+ if not last_stdout.empty?
+ if not last_stderr.empty?
+ return " Cause: #{last_stdout}, and Error: #{last_stderr}"
+ else
+ return " Cause: #{last_stdout}"
+ end
+ elsif not last_stderr.empty?
+ return " Error: #{last_stderr}"
+ end
+ ''
+ end
def execute_adb_with(timeout, arguments)
args = arguments.split
execute_adb_with_exactly timeout, *args
end