use yargs to get commandline params for nodejs tests

This commit is contained in:
Shruti Ranganathan Jothi
2017-03-08 10:33:36 -08:00
parent ac26da16e2
commit 8e322de983
19 changed files with 393 additions and 47 deletions

View File

@@ -1,7 +1,7 @@
"use strict";
var colors = require("colors/safe");
var sprintf = require("sprintf-js").sprintf;
const colors = require("colors/safe");
const sprintf = require("sprintf-js").sprintf;
function getParam(key) {
var value;

View File

@@ -15,6 +15,7 @@
"node-ssdp": "^3.2.0",
"q": "~1.4.1",
"request": "^2.78.0",
"sprintf-js": "~1.0.3"
"sprintf-js": "~1.0.3",
"yargs": "^6.3.0"
}
}

View File

@@ -4,8 +4,23 @@ var dial = require("../libs/dialClient.js"),
utils = require("../libs/utils.js"),
Q = require("q");
const argv = require("yargs")
.usage("\nUsage: node " + __filename.slice(__dirname.length + 1) + "[options]")
.option("host", {
describe: "IP address of host on which DIAL server under test is running",
type: "string",
demand: true
})
.option("application", {
alias: "app",
describe: "Application to test",
type: "string",
demand: true
})
.help("help").alias("help", "h").argv;
function test() {
var testServer = utils.getParam("host");
var testServer = argv.host;
return new Q()
.then(function () {

View File

@@ -4,10 +4,31 @@ var dial = require("../libs/dialClient.js"),
utils = require("../libs/utils.js"),
Q = require("q");
const argv = require("yargs")
.usage("\nUsage: node " + __filename.slice(__dirname.length + 1) + "[options]")
.option("host", {
describe: "IP address of host on which DIAL server under test is running",
type: "string",
demand: true
})
.option("application", {
alias: "app",
describe: "Application to test",
type: "string",
demand: true
})
.option("timeToWaitForStateChange", {
alias: "ttw",
describe: "Time(ms) to wait between state changes before querying application status",
type: "string",
default: 5000
})
.help("help").alias("help", "h").argv;
function test() {
var host = utils.getParam("host");
var app = utils.getParam("app");
var timeToWaitForStateChange = utils.getParam("timeToWaitForStateChange") || 5000;
var host = argv.host;
var app = argv.application;
var timeToWaitForStateChange = argv.timeToWaitForStateChange || 5000;
return new Q()
.then(function () {

View File

@@ -4,10 +4,31 @@ var dial = require("../libs/dialClient.js"),
utils = require("../libs/utils.js"),
Q = require("q");
const argv = require("yargs")
.usage("\nUsage: node " + __filename.slice(__dirname.length + 1) + "[options]")
.option("host", {
describe: "IP address of host on which DIAL server under test is running",
type: "string",
demand: true
})
.option("application", {
alias: "app",
describe: "Application to test",
type: "string",
demand: true
})
.option("timeToWaitForStateChange", {
alias: "ttw",
describe: "Time(ms) to wait between state changes before querying application status",
type: "string",
default: 5000
})
.help("help").alias("help", "h").argv;
function test() {
var host = utils.getParam("host");
var app = utils.getParam("app");
var timeToWaitForStateChange = utils.getParam("timeToWaitForStateChange") || 5000;
var host = argv.host;
var app = argv.application;
var timeToWaitForStateChange = argv.timeToWaitForStateChange || 5000;
return new Q()
.then(function () {

View File

@@ -4,10 +4,31 @@ var dial = require("../libs/dialClient.js"),
utils = require("../libs/utils.js"),
Q = require("q");
const argv = require("yargs")
.usage("\nUsage: node " + __filename.slice(__dirname.length + 1) + "[options]")
.option("host", {
describe: "IP address of host on which DIAL server under test is running",
type: "string",
demand: true
})
.option("application", {
alias: "app",
describe: "Application to test",
type: "string",
demand: true
})
.option("timeToWaitForStateChange", {
alias: "ttw",
describe: "Time(ms) to wait between state changes before querying application status",
type: "string",
default: 5000
})
.help("help").alias("help", "h").argv;
function test() {
var host = utils.getParam("host");
var app = utils.getParam("app");
var timeToWaitForStateChange = utils.getParam("timeToWaitForStateChange") || 5000;
var host = argv.host;
var app = argv.application;
var timeToWaitForStateChange = argv.timeToWaitForStateChange || 5000;
return new Q()
.then(function () {

View File

@@ -4,10 +4,31 @@ var dial = require("../libs/dialClient.js"),
utils = require("../libs/utils.js"),
Q = require("q");
const argv = require("yargs")
.usage("\nUsage: node " + __filename.slice(__dirname.length + 1) + "[options]")
.option("host", {
describe: "IP address of host on which DIAL server under test is running",
type: "string",
demand: true
})
.option("application", {
alias: "app",
describe: "Application to test",
type: "string",
demand: true
})
.option("timeToWaitForStateChange", {
alias: "ttw",
describe: "Time(ms) to wait between state changes before querying application status",
type: "string",
default: 5000
})
.help("help").alias("help", "h").argv;
function test() {
var host = utils.getParam("host");
var app = utils.getParam("app");
var timeToWaitForStateChange = utils.getParam("timeToWaitForStateChange") || 5000;
var host = argv.host;
var app = argv.application;
var timeToWaitForStateChange = argv.timeToWaitForStateChange || 5000;
return new Q()
.then(function () {

View File

@@ -4,10 +4,31 @@ var dial = require("../libs/dialClient.js"),
utils = require("../libs/utils.js"),
Q = require("q");
const argv = require("yargs")
.usage("\nUsage: node " + __filename.slice(__dirname.length + 1) + "[options]")
.option("host", {
describe: "IP address of host on which DIAL server under test is running",
type: "string",
demand: true
})
.option("application", {
alias: "app",
describe: "Application to test",
type: "string",
demand: true
})
.option("timeToWaitForStateChange", {
alias: "ttw",
describe: "Time(ms) to wait between state changes before querying application status",
type: "string",
default: 5000
})
.help("help").alias("help", "h").argv;
function test() {
var host = utils.getParam("host");
var app = utils.getParam("app");
var timeToWaitForStateChange = utils.getParam("timeToWaitForStateChange") || 5000;
var host = argv.host;
var app = argv.application;
var timeToWaitForStateChange = argv.timeToWaitForStateChange || 5000;
return new Q()
.then(function () {

View File

@@ -4,10 +4,31 @@ var dial = require("../libs/dialClient.js"),
utils = require("../libs/utils.js"),
Q = require("q");
const argv = require("yargs")
.usage("\nUsage: node " + __filename.slice(__dirname.length + 1) + "[options]")
.option("host", {
describe: "IP address of host on which DIAL server under test is running",
type: "string",
demand: true
})
.option("application", {
alias: "app",
describe: "Application to test",
type: "string",
demand: true
})
.option("timeToWaitForStateChange", {
alias: "ttw",
describe: "Time(ms) to wait between state changes before querying application status",
type: "string",
default: 5000
})
.help("help").alias("help", "h").argv;
function test() {
var host = utils.getParam("host");
var app = utils.getParam("app");
var timeToWaitForStateChange = utils.getParam("timeToWaitForStateChange") || 5000;
var host = argv.host;
var app = argv.application;
var timeToWaitForStateChange = argv.timeToWaitForStateChange || 5000;
return new Q()
.then(function () {

View File

@@ -4,10 +4,31 @@ var dial = require("../libs/dialClient.js"),
utils = require("../libs/utils.js"),
Q = require("q");
const argv = require("yargs")
.usage("\nUsage: node " + __filename.slice(__dirname.length + 1) + "[options]")
.option("host", {
describe: "IP address of host on which DIAL server under test is running",
type: "string",
demand: true
})
.option("application", {
alias: "app",
describe: "Application to test",
type: "string",
demand: true
})
.option("timeToWaitForStateChange", {
alias: "ttw",
describe: "Time(ms) to wait between state changes before querying application status",
type: "string",
default: 5000
})
.help("help").alias("help", "h").argv;
function test() {
var host = utils.getParam("host");
var app = utils.getParam("app");
var timeToWaitForStateChange = utils.getParam("timeToWaitForStateChange") || 5000;
var host = argv.host;
var app = argv.application;
var timeToWaitForStateChange = argv.timeToWaitForStateChange || 5000;
return new Q()
.then(function () {

View File

@@ -4,10 +4,31 @@ var dial = require("../libs/dialClient.js"),
utils = require("../libs/utils.js"),
Q = require("q");
const argv = require("yargs")
.usage("\nUsage: node " + __filename.slice(__dirname.length + 1) + "[options]")
.option("host", {
describe: "IP address of host on which DIAL server under test is running",
type: "string",
demand: true
})
.option("application", {
alias: "app",
describe: "Application to test",
type: "string",
demand: true
})
.option("timeToWaitForStateChange", {
alias: "ttw",
describe: "Time(ms) to wait between state changes before querying application status",
type: "string",
default: 5000
})
.help("help").alias("help", "h").argv;
function test() {
var host = utils.getParam("host");
var app = utils.getParam("app");
var timeToWaitForStateChange = utils.getParam("timeToWaitForStateChange") || 5000;
var host = argv.host;
var app = argv.application;
var timeToWaitForStateChange = argv.timeToWaitForStateChange || 5000;
return new Q()
.then(function () {

View File

@@ -4,10 +4,31 @@ var dial = require("../libs/dialClient.js"),
utils = require("../libs/utils.js"),
Q = require("q");
const argv = require("yargs")
.usage("\nUsage: node " + __filename.slice(__dirname.length + 1) + "[options]")
.option("host", {
describe: "IP address of host on which DIAL server under test is running",
type: "string",
demand: true
})
.option("application", {
alias: "app",
describe: "Application to test",
type: "string",
demand: true
})
.option("timeToWaitForStateChange", {
alias: "ttw",
describe: "Time(ms) to wait between state changes before querying application status",
type: "string",
default: 5000
})
.help("help").alias("help", "h").argv;
function test() {
var host = utils.getParam("host");
var app = utils.getParam("app");
var timeToWaitForStateChange = utils.getParam("timeToWaitForStateChange") || 5000;
var host = argv.host;
var app = argv.application;
var timeToWaitForStateChange = argv.timeToWaitForStateChange || 5000;
return new Q()
.then(function () {

View File

@@ -4,9 +4,30 @@ var dial = require("../libs/dialClient.js"),
utils = require("../libs/utils.js"),
Q = require("q");
const argv = require("yargs")
.usage("\nUsage: node " + __filename.slice(__dirname.length + 1) + "[options]")
.option("host", {
describe: "IP address of host on which DIAL server under test is running",
type: "string",
demand: true
})
.option("application", {
alias: "app",
describe: "Application to test",
type: "string",
demand: true
})
.option("timeToWaitForStateChange", {
alias: "ttw",
describe: "Time(ms) to wait between state changes before querying application status",
type: "string",
default: 5000
})
.help("help").alias("help", "h").argv;
function test() {
var host = utils.getParam("host");
var timeToWaitForStateChange = utils.getParam("timeToWaitForStateChange") || 5000;
var host = argv.host;
var timeToWaitForStateChange = argv.timeToWaitForStateChange || 5000;
return new Q()
.then(function () {

View File

@@ -4,9 +4,24 @@ var dial = require("../libs/dialClient.js"),
utils = require("../libs/utils.js"),
Q = require("q");
const argv = require("yargs")
.usage("\nUsage: node " + __filename.slice(__dirname.length + 1) + "[options]")
.option("host", {
describe: "IP address of host on which DIAL server under test is running",
type: "string",
demand: true
})
.option("application", {
alias: "app",
describe: "Application to test",
type: "string",
demand: true
})
.help("help").alias("help", "h").argv;
function test() {
var host = utils.getParam("host");
var app = utils.getParam("app");
var host = argv.host;
var app = argv.application;
var payload = "key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&"
+ "key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&"

View File

@@ -4,10 +4,31 @@ var dial = require("../libs/dialClient.js"),
utils = require("../libs/utils.js"),
Q = require("q");
const argv = require("yargs")
.usage("\nUsage: node " + __filename.slice(__dirname.length + 1) + "[options]")
.option("host", {
describe: "IP address of host on which DIAL server under test is running",
type: "string",
demand: true
})
.option("application", {
alias: "app",
describe: "Application to test",
type: "string",
demand: true
})
.option("timeToWaitForStateChange", {
alias: "ttw",
describe: "Time(ms) to wait between state changes before querying application status",
type: "string",
default: 5000
})
.help("help").alias("help", "h").argv;
function test() {
var host = utils.getParam("host");
var app = utils.getParam("app");
var timeToWaitForStateChange = utils.getParam("timeToWaitForStateChange") || 5000;
var host = argv.host;
var app = argv.application;
var timeToWaitForStateChange = argv.timeToWaitForStateChange || 5000;
return new Q()
.then(function () {

View File

@@ -4,10 +4,31 @@ var dial = require("../libs/dialClient.js"),
utils = require("../libs/utils.js"),
Q = require("q");
const argv = require("yargs")
.usage("\nUsage: node " + __filename.slice(__dirname.length + 1) + "[options]")
.option("host", {
describe: "IP address of host on which DIAL server under test is running",
type: "string",
demand: true
})
.option("application", {
alias: "app",
describe: "Application to test",
type: "string",
demand: true
})
.option("timeToWaitForStateChange", {
alias: "ttw",
describe: "Time(ms) to wait between state changes before querying application status",
type: "string",
default: 5000
})
.help("help").alias("help", "h").argv;
function test() {
var host = utils.getParam("host");
var app = utils.getParam("app");
var timeToWaitForStateChange = utils.getParam("timeToWaitForStateChange") || 5000;
var host = argv.host;
var app = argv.application;
var timeToWaitForStateChange = argv.timeToWaitForStateChange || 5000;
return new Q()
.then(function () {

View File

@@ -4,10 +4,31 @@ var dial = require("../libs/dialClient.js"),
utils = require("../libs/utils.js"),
Q = require("q");
const argv = require("yargs")
.usage("\nUsage: node " + __filename.slice(__dirname.length + 1) + "[options]")
.option("host", {
describe: "IP address of host on which DIAL server under test is running",
type: "string",
demand: true
})
.option("application", {
alias: "app",
describe: "Application to test",
type: "string",
demand: true
})
.option("timeToWaitForStateChange", {
alias: "ttw",
describe: "Time(ms) to wait between state changes before querying application status",
type: "string",
default: 5000
})
.help("help").alias("help", "h").argv;
function test() {
var host = utils.getParam("host");
var app = utils.getParam("app");
var timeToWaitForStateChange = utils.getParam("timeToWaitForStateChange") || 5000;
var host = argv.host;
var app = argv.application;
var timeToWaitForStateChange = argv.timeToWaitForStateChange || 5000;
var instanceUrl;
return new Q()

View File

@@ -4,10 +4,31 @@ var dial = require("../libs/dialClient.js"),
utils = require("../libs/utils.js"),
Q = require("q");
const argv = require("yargs")
.usage("\nUsage: node " + __filename.slice(__dirname.length + 1) + "[options]")
.option("host", {
describe: "IP address of host on which DIAL server under test is running",
type: "string",
demand: true
})
.option("application", {
alias: "app",
describe: "Application to test",
type: "string",
demand: true
})
.option("timeToWaitForStateChange", {
alias: "ttw",
describe: "Time(ms) to wait between state changes before querying application status",
type: "string",
default: 5000
})
.help("help").alias("help", "h").argv;
function test() {
var host = utils.getParam("host");
var app = utils.getParam("app");
var timeToWaitForStateChange = utils.getParam("timeToWaitForStateChange") || 5000;
var host = argv.host;
var app = argv.application;
var timeToWaitForStateChange = argv.timeToWaitForStateChange || 5000;
return new Q()
.then(function () {

View File

@@ -2,6 +2,27 @@
var Q = require("q");
const argv = require("yargs")
.usage("\nUsage: node " + __filename.slice(__dirname.length + 1) + "[options]")
.option("host", {
describe: "IP address of host on which DIAL server under test is running",
type: "string",
demand: true
})
.option("application", {
alias: "app",
describe: "Application to test",
type: "string",
demand: true
})
.option("timeToWaitForStateChange", {
alias: "ttw",
describe: "Time(ms) to wait between state changes before querying application status",
type: "string",
default: 5000
})
.help("help").alias("help", "h").argv;
var discoverServerUnderTest = require("../tests/discoverServerUnderTest.js"),
launchApplicationNotRecognized = require("../tests/launchApplicationNotRecognized.js"),
launchApplicationInRunningStateWithNoPayload = require("../tests/launchApplicationInRunningStateWithNoPayload.js"),