Skip to content

Commit

Permalink
Merge pull request appium#178 from appium/isaac-ps
Browse files Browse the repository at this point in the history
Use all processes when looking for pids
  • Loading branch information
imurchie committed Oct 7, 2016
2 parents 88b85eb + 4bc9dbf commit f41dea7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
11 changes: 1 addition & 10 deletions lib/tools/adb-commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -424,16 +424,7 @@ methods.getPIDsByName = async function (name) {
if (name.length > 15) {
name = name.substr(name.length - 15);
}
let stdout;
try {
stdout = await this.shell(["ps", name]);
} catch (err) {
// on some systems `name` is not accepted
// so get **all** the processes and skip wrong ones below
log.debug(`Unable to get process for '${name}'. Retrieving all processes.`);
stdout = await this.shell(["ps"]);
}
stdout = stdout.trim();
let stdout = await this.shell(["ps"]).trim();
let pids = [];
for (let line of stdout.split("\n")) {
if (line.indexOf(name) !== -1) {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/adb-commands-specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ describe('adb commands', () => {
describe('getPIDsByName', withMocks({adb}, (mocks) => {
it('should call shell and parse pids correctly', async () => {
mocks.adb.expects("shell")
.once().withExactArgs(['ps', '.contactmanager'])
.once().withExactArgs(['ps'])
.returns(psOutput);
(await adb.getPIDsByName(contactManagerPackage))[0].should.equal(5078);
mocks.adb.verify();
Expand Down

0 comments on commit f41dea7

Please sign in to comment.