Skip to content

Commit 7d1975f

Browse files
committed
Merge branch 'master' into pr/6
Conflicts: README.md
2 parents b9ed8ad + 95cdbee commit 7d1975f

File tree

4 files changed

+38
-19
lines changed

4 files changed

+38
-19
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ A sample configuration file:
4545
{
4646
"username": "<username>",
4747
"key": "<key>",
48-
"test_path": "relative/path/to/test/page",
4948
"test_framework": "qunit/jasmine/mocha",
49+
"test_path": ["relative/path/to/test/page1", "relative/path/to/test/page2"],
5050
"browsers": [{
5151
"browser": "firefox",
5252
"browser_version": "15.0",

bin/runner.js

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,10 @@ console.log("Launching server on port:", serverPort);
6262
var server = new Server(client, workers);
6363
server.listen(parseInt(serverPort, 10));
6464

65-
function launchBrowser(browser) {
65+
function launchBrowser(browser, url) {
6666
var browserString = utils.browserString(browser);
6767
console.log("[%s] Launching", browserString);
6868

69-
var url = 'http://localhost:' + serverPort.toString() + '/';
70-
url += config.test_path;
71-
7269
var key = utils.uuid();
7370

7471
if (url.indexOf('?') > 0) {
@@ -93,6 +90,7 @@ function launchBrowser(browser) {
9390

9491
client.createWorker(browser, function (err, worker) {
9592
if (err || typeof worker !== 'object') {
93+
console.log("Error from BrowserStack: ", err);
9694
utils.alertBrowserStack("Failed to launch worker",
9795
"Arguments: " + JSON.stringify({
9896
err: err,
@@ -138,6 +136,20 @@ function launchBrowser(browser) {
138136
});
139137
}
140138

139+
var launchBrowsers = function(config, browser) {
140+
setTimeout(function () {
141+
if(Object.prototype.toString.call(config.test_path) === '[object Array]'){
142+
config.test_path.forEach(function(path){
143+
var url = 'http://localhost:' + serverPort.toString() + '/' + path;
144+
launchBrowser(browser,url);
145+
});
146+
} else {
147+
var url = 'http://localhost:' + serverPort.toString() + '/' + config.test_path;
148+
launchBrowser(browser,url);
149+
}
150+
}, 100);
151+
}
152+
141153
if (config.browsers && config.browsers.length > 0) {
142154
tunnel = new Tunnel(config.key, serverPort, config.tunnelIdentifier, function () {
143155
console.log("Launching BrowserStack workers");
@@ -149,14 +161,11 @@ if (config.browsers && config.browsers.length > 0) {
149161
console.log("[%s] Version is %s.",
150162
utils.browserString(browser), version);
151163
browser.browser_version = version;
152-
153164
// So that all latest logs come in together
154-
setTimeout(function () {
155-
launchBrowser(browser);
156-
}, 100);
165+
launchBrowsers(config, browser);
157166
});
158167
} else {
159-
launchBrowser(browser);
168+
launchBrowsers(config, browser);
160169
}
161170
});
162171
});

lib/config.js

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,28 @@ if (commit_id) {
5656
}
5757
});
5858

59-
// Convert absoulte path into relative paths.
60-
if (config.test_path.indexOf(pwd) === 0) {
61-
config.test_path = config.test_path.slice(pwd.length + 1);
62-
}
63-
64-
if (!fs.existsSync(config.test_path)){
65-
console.error('Test path is invalid.');
66-
process.exit(1);
59+
var formatPath = function(path) {
60+
if (path.indexOf(pwd) === 0) {
61+
path= path.slice(pwd.length + 1);
62+
}
63+
if (!fs.existsSync(path)){
64+
console.error('Test path: '+ path + ' is invalid.');
65+
process.exit(1);
66+
}
67+
return path;
6768
}
6869

6970
config.tunnelIdentifier = process.env.TUNNEL_ID || process.env.TRAVIS_JOB_ID || process.env.TRAVIS_BUILD_ID;
7071

72+
if(Object.prototype.toString.call(config.test_path) === '[object Array]') {
73+
config.test_path.forEach(function(path){
74+
path = formatPath(path);
75+
});
76+
} else {
77+
//Backward Compatibility, if test_path is not array of path
78+
config.test_path = formatPath(config.test_path);
79+
}
80+
7181
for (key in config) {
7282
if (config.hasOwnProperty(key)) {
7383
exports[key] = config[key];

lib/tunnel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ var Tunnel = function Tunnel (key, port, tunnelIdentifier, callback, err) {
2424

2525
console.log("Launching tunnel");
2626
var subProcess = exec(tunnelCommand, function (error, stdout, stderr) {
27-
console.error(stderr);
27+
console.log(stderr);
2828
if (stdout.indexOf('Error') >= 0) {
2929
console.log("Tunnel launching failed");
3030
console.log(stdout);

0 commit comments

Comments
 (0)