Skip to content

Commit 6a00dbc

Browse files
committed
[CYP-175] Parallelisation support in cli
1 parent dedbd95 commit 6a00dbc

File tree

5 files changed

+20
-1
lines changed

5 files changed

+20
-1
lines changed

bin/commands/runs.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ function runCypress(args) {
3434
capabilityHelper.validate(bsConfig).then(function (validated) {
3535
logger.info(validated);
3636

37+
// accept the number of parallels
38+
util.setParallels(bsConfig, args);
39+
3740
// Archive the spec files
3841
archiver.archive(bsConfig.run_settings, config.fileName).then(function (data) {
3942

bin/helpers/capabilityHelper.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ const caps = (bsConfig, zip) => {
5656
obj.projectNotifyURL = bsConfig.run_settings.project_notify_URL
5757
if (obj.projectNotifyURL) logger.info(`Project notify URL is: ${obj.projectNotifyURL}`);
5858

59+
obj.parallels = bsConfig.run_settings.parallels;
60+
if (obj.parallels) logger.info(`Parallels specified are: ${obj.parallels}`);
61+
5962
var data = JSON.stringify(obj);
6063
resolve(data);
6164
})

bin/helpers/constants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ const cliMessages = {
4646
STOP_MESSAGE: "Stopping build with given buildId "
4747
},
4848
RUN: {
49+
PARALLEL_DESC: "Maximum number of parallels to run",
4950
INFO: "Run your tests on BrowserStack.",
5051
DESC: "Path to BrowserStack config",
5152
CONFIG_DEMAND: "config file is required"

bin/helpers/util.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ exports.setUsageReportingFlag = (bsConfig, disableUsageReporting) => {
7070
}
7171
}
7272

73+
exports.setParallels = (bsConfig, args) => {
74+
if ((args.parallels !== undefined && !Number.isNaN(args.parallels)) && bsConfig && (bsConfig['run_settings']['parallels'] === undefined || bsConfig['run_settings']['parallels'])) {
75+
bsConfig['run_settings']['parallels'] = args.parallels;
76+
}
77+
}
78+
7379
exports.getUserAgent = () => {
7480
return `BStack-Cypress-CLI/1.x (${os.arch()}/${os.platform()}/${os.release()})`;
7581
}

bin/runner.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ var argv = yargs
101101
})
102102
.command('run', Constants.cliMessages.RUN.INFO, function(yargs) {
103103
argv = yargs
104-
.usage('usage: $0 build')
104+
.usage('usage: $0 run <options>')
105105
.options({
106106
'cf': {
107107
alias: 'config-file',
@@ -117,6 +117,12 @@ var argv = yargs
117117
description: Constants.cliMessages.COMMON.DISABLE_USAGE_REPORTING,
118118
type: "boolean"
119119
},
120+
'p': {
121+
alias: 'parallels',
122+
describe: Constants.cliMessages.RUN.PARALLEL_DESC,
123+
type: "number",
124+
default: undefined
125+
}
120126
})
121127
.help('help')
122128
.wrap(null)

0 commit comments

Comments
 (0)