You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by rk...@apache.org on 2016/02/26 22:38:48 UTC
[1/2] cordova-medic git commit: CB-10671: Killing adb server as part
of Android medic-kill step
Repository: cordova-medic
Updated Branches:
refs/heads/master 9f8002bc6 -> cea6c852e
CB-10671: Killing adb server as part of Android medic-kill step
Project: http://git-wip-us.apache.org/repos/asf/cordova-medic/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-medic/commit/e583d860
Tree: http://git-wip-us.apache.org/repos/asf/cordova-medic/tree/e583d860
Diff: http://git-wip-us.apache.org/repos/asf/cordova-medic/diff/e583d860
Branch: refs/heads/master
Commit: e583d860204fe02f633fcbfde6e5be2f29cc2e55
Parents: 9f8002b
Author: riknoll <ri...@gmail.com>
Authored: Thu Feb 25 11:17:52 2016 -0800
Committer: riknoll <ri...@gmail.com>
Committed: Thu Feb 25 11:23:49 2016 -0800
----------------------------------------------------------------------
medic/medic-kill.js | 31 ++++++++++++++++++++++++++-----
1 file changed, 26 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-medic/blob/e583d860/medic/medic-kill.js
----------------------------------------------------------------------
diff --git a/medic/medic-kill.js b/medic/medic-kill.js
index 2a77cde..934cdf1 100644
--- a/medic/medic-kill.js
+++ b/medic/medic-kill.js
@@ -49,6 +49,24 @@ function tasksOnPlatform(platformName) {
}
}
+/**
+ * CB-10671: In order to deal with issues where "ghost" emulators sometimes get
+ * left behind, we kill the ADB server
+ */
+function killAdbServer() {
+ util.medicLog("Killing adb server");
+ var killServerCommand = "adb kill-server";
+
+ util.medicLog("Running the following command:");
+ util.medicLog(" " + killServerCommand);
+
+ var killServerResult = shelljs.exec(killServerCommand, {silent: false, async: false});
+ if (killServerResult.code !== 0) {
+ util.fatal("Failed killing adb server");
+ }
+ util.medicLog("Finished killing adb server");
+}
+
function getKillCommand(taskNames) {
var cli;
@@ -76,11 +94,10 @@ function killTasks(taskNames) {
util.medicLog("running the following command:");
util.medicLog(" " + command);
- shelljs.exec(command, {silent: false, async: true}, function (returnCode, output) {
- if (returnCode !== 0) {
- console.warn("WARNING: kill command returned " + returnCode);
- }
- });
+ var killTasksResult = shelljs.exec(command, {silent: false, async: false });
+ if (killTasksResult.code !== 0) {
+ console.warn("WARNING: kill command returned " + killTasksResult.code);
+ }
}
function killTasksForPlatform(platform) {
@@ -97,6 +114,10 @@ function killTasksForPlatform(platform) {
// kill them
killTasks(platformTasks);
+
+ if (platform === util.ANDROID) {
+ killAdbServer();
+ }
}
// main
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[2/2] cordova-medic git commit: CB-10699: Attempt to uninstall
mobilespec on Android emulator before run
Posted by rk...@apache.org.
CB-10699: Attempt to uninstall mobilespec on Android emulator before run
Project: http://git-wip-us.apache.org/repos/asf/cordova-medic/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-medic/commit/cea6c852
Tree: http://git-wip-us.apache.org/repos/asf/cordova-medic/tree/cea6c852
Diff: http://git-wip-us.apache.org/repos/asf/cordova-medic/diff/cea6c852
Branch: refs/heads/master
Commit: cea6c852e39766aa54032e75879b50912f1541ba
Parents: e583d86
Author: riknoll <ri...@gmail.com>
Authored: Thu Feb 25 11:18:43 2016 -0800
Committer: riknoll <ri...@gmail.com>
Committed: Thu Feb 25 11:23:50 2016 -0800
----------------------------------------------------------------------
lib/util.js | 23 ++++++++++++++++++++++-
medic/medic-log.js | 14 +-------------
medic/medic-run.js | 20 ++++++++++++++++++++
3 files changed, 43 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-medic/blob/cea6c852/lib/util.js
----------------------------------------------------------------------
diff --git a/lib/util.js b/lib/util.js
index a636358..06da676 100644
--- a/lib/util.js
+++ b/lib/util.js
@@ -24,11 +24,14 @@
module.exports = (function () {
var os = require("os");
+ var shelljs = require("shelljs");
// constants
var ESCAPE = String.fromCharCode(27);
var RED_COLOR = ESCAPE + "[31m";
var NO_COLOR = ESCAPE + "[m";
+ var DEVICE_ROW_PATTERN = /(emulator|device|host)/m;
+ var HEADING_LINE_PATTERN = /List of devices/m;
function medicLog(message) {
console.log(RED_COLOR + "[MEDIC LOG " + new Date().toUTCString() + "]" + NO_COLOR + " " + message);
@@ -54,6 +57,23 @@ module.exports = (function () {
return Math.ceil(seconds / 60);
}
+ function countAndroidDevices() {
+ var listCommand = "adb devices";
+
+ medicLog("running:");
+ medicLog(" " + listCommand);
+
+ var numDevices = 0;
+ var result = shelljs.exec(listCommand, {silent: false, async: false});
+ result.output.split('\n').forEach(function (line) {
+ if (!HEADING_LINE_PATTERN.test(line) && DEVICE_ROW_PATTERN.test(line)) {
+ numDevices += 1;
+ }
+ });
+
+ return numDevices;
+ }
+
return {
// constants
@@ -71,6 +91,7 @@ module.exports = (function () {
isWindows: isWindows,
medicLog: medicLog,
contains: contains,
- secToMin: secToMin
+ secToMin: secToMin,
+ countAndroidDevices: countAndroidDevices
};
}());
http://git-wip-us.apache.org/repos/asf/cordova-medic/blob/cea6c852/medic/medic-log.js
----------------------------------------------------------------------
diff --git a/medic/medic-log.js b/medic/medic-log.js
index a25c5b2..660e87c 100644
--- a/medic/medic-log.js
+++ b/medic/medic-log.js
@@ -31,27 +31,15 @@ var path = require("path");
var util = require("../lib/util");
// constants
-var DEVICE_ROW_PATTERN = /(emulator|device|host)/m;
-var HEADING_LINE_PATTERN = /List of devices/m;
var DEFAULT_APP_PATH = "mobilespec";
// helpers
function logAndroid() {
var logCommand = "adb logcat -d";
- var listCommand = "adb devices";
-
- util.medicLog("running:");
- util.medicLog(" " + listCommand);
// bail out if there is more/less than one device
- var numDevices = 0;
- var result = shelljs.exec(listCommand, {silent: false, async: false});
- result.output.split('\n').forEach(function (line) {
- if (!HEADING_LINE_PATTERN.test(line) && DEVICE_ROW_PATTERN.test(line)) {
- numDevices += 1;
- }
- });
+ var numDevices = util.countAndroidDevices();
if (numDevices != 1) {
util.fatal("there must be exactly one emulator/device attached");
}
http://git-wip-us.apache.org/repos/asf/cordova-medic/blob/cea6c852/medic/medic-run.js
----------------------------------------------------------------------
diff --git a/medic/medic-run.js b/medic/medic-run.js
index 53c89c8..984c102 100644
--- a/medic/medic-run.js
+++ b/medic/medic-run.js
@@ -423,6 +423,26 @@ function main() {
util.fatal("Could not start Android emulator");
} else {
util.medicLog("Android emulator started");
+
+ // CB-10699: We try to uninstall the app once the emulator
+ // boots up, because sometimes the adb command that "cordova
+ // run" uses fails to uninstall the app and errors out
+
+ // There needs to be only one device for uninstall to work
+ var numDevices = util.countAndroidDevices();
+ if (numDevices != 1) {
+ util.medicLog("WARNING: There is more than one device/emulator attached, skipping uninstall step");
+ } else {
+ var uninstallCommand = "adb uninstall org.apache.mobilespec";
+
+ util.medicLog("Running the following command:");
+ util.medicLog(" " + uninstallCommand);
+
+ // This command will fail if the app is not installed,
+ // so we set it to silent so as to not confuse anyone
+ var uninstallResult = shelljs.exec(uninstallCommand, {silent: true, async: false});
+ }
+
runOnEmulator();
}
} else {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org