fix up logging and make sure deleteSession isn't sent directly to inner execute

This commit is contained in:
Jonathan Lipps 2015-06-02 18:41:04 +01:00
Родитель 84317aaf36
Коммит 39bca1ddd0
5 изменённых файлов: 24 добавлений и 7 удалений

3
.travis.yml Normal file
Просмотреть файл

@ -0,0 +1,3 @@
language: node_js
node_js:
- "0.12"

Просмотреть файл

@ -3,4 +3,10 @@
var gulp = require('gulp'),
boilerplate = require('appium-gulp-plugins').boilerplate.use(gulp);
boilerplate({build: 'appium', jscs: false});
boilerplate({
build: 'appium',
jscs: false,
test: {
files: ['${testDir}/**/*-specs.js']
},
});

Просмотреть файл

@ -39,31 +39,33 @@ class AppiumDriver extends BaseDriver {
async createSession (caps) {
let InnerDriver = this.getDriverForCaps(caps);
log.info(`Creating new ${InnerDriver.name} session`);
let d = new InnerDriver(this.args);
let [innerSessionId, dCaps] = await d.createSession(caps);
this.sessions[innerSessionId] = d;
log.info(`New ${InnerDriver.name} session created successfully, session ` +
`${innerSessionId} added to master session list`);
return [innerSessionId, dCaps];
}
async deleteSession (sessionId) {
try {
await this.sessions[sessionId].deleteSession();
console.log('deleted session');
} catch (e) {
console.log(e);
log.error(`Had trouble ending session ${sessionId}: ${e.message}`);
throw e;
} finally {
// regardless of whether the deleteSession completes successfully or not
// make the session unavailable, because who knows what state it might
// be in otherwise
log.info(`Removing session ${sessionId} from our master session list`);
delete this.sessions[sessionId];
console.log(this.sessions);
}
}
async execute (cmd, ...args) {
if (!isSessionCommand(cmd)) {
if (isAppiumDriverCommand(cmd)) {
return super.execute(cmd, ...args);
}
let sessionId = args[args.length - 1];
@ -71,6 +73,12 @@ class AppiumDriver extends BaseDriver {
}
}
// help decide which commands should be proxied to sub-drivers and which
// should be handled by this, our umbrella driver
function isAppiumDriverCommand (cmd) {
return !isSessionCommand(cmd) || cmd === "deleteSession";
}
function getAppiumRouter (args) {
let appium = new AppiumDriver(args);
return routeConfiguringFunction(appium);

Просмотреть файл

@ -1,5 +1,5 @@
import { getLogger } from 'appium-logger';
let logger = getLogger('core');
let logger = getLogger('[Appium]');
export default logger;

Просмотреть файл

@ -5,7 +5,7 @@ import getParser from '../lib/parser';
import chai from 'chai';
const should = chai.should();
const oldArgv = _.clone(process.env);
const oldArgv = _.clone(process.argv);
describe('Parser', () => {
before(() => {