зеркало из https://github.com/xamarin/appium.old.git
Don't allow undefined process.argv[1] in parser
argParse breaks if process.argv[1], which is a problem if Appium is being run as a binary. Added check so that if process.argv[1] is undefined, set the prog name to 'Appium'
This commit is contained in:
Родитель
56ebf37d16
Коммит
6f5a9d1001
|
@ -782,7 +782,8 @@ function getParser () {
|
|||
let parser = new ArgumentParser({
|
||||
version: pkgObj.version,
|
||||
addHelp: true,
|
||||
description: 'A webdriver-compatible server for use with native and hybrid iOS and Android applications.'
|
||||
description: 'A webdriver-compatible server for use with native and hybrid iOS and Android applications.',
|
||||
prog: process.argv[1] || 'Appium'
|
||||
});
|
||||
let allArgs = _.union(args, deprecatedArgs);
|
||||
parser.rawArgs = allArgs;
|
||||
|
|
|
@ -194,6 +194,30 @@ describe('Config', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('parsing args with empty argv[1]', () => {
|
||||
let argv1;
|
||||
|
||||
before(() => {
|
||||
argv1 = process.argv[1];
|
||||
});
|
||||
|
||||
after(() => {
|
||||
process.argv[1] = argv1;
|
||||
});
|
||||
|
||||
it('should not fail if process.argv[1] is undefined', () => {
|
||||
process.argv[1] = undefined;
|
||||
let args = getParser();
|
||||
args.prog.should.be.equal('Appium');
|
||||
});
|
||||
|
||||
it('should set "prog" to process.argv[1]', () => {
|
||||
process.argv[1] = 'Hello World';
|
||||
let args = getParser();
|
||||
args.prog.should.be.equal('Hello World');
|
||||
});
|
||||
});
|
||||
|
||||
describe('validateServerArgs', () => {
|
||||
let parser = getParser();
|
||||
parser.debug = true; // throw instead of exit on error; pass as option instead?
|
||||
|
|
Загрузка…
Ссылка в новой задаче