Skip to content

Commit 69bd7b8

Browse files
committed
The --no-wrap logic enahancements.
- Added util for setting the no-wrap on process level as a BOOL val. - Moved the no-wrap logic to centralizeds place. - Added default value and the type accepted in the help text for yargs.
1 parent ebcddda commit 69bd7b8

File tree

5 files changed

+37
-9
lines changed

5 files changed

+37
-9
lines changed

bin/commands/runs.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ module.exports = function run(args) {
5454
// run test in headed mode
5555
utils.setHeaded(bsConfig, args);
5656

57+
// set the no-wrap
58+
utils.setNoWrap(bsConfig, args);
59+
5760
// Validate browserstack.json values and parallels specified via arguments
5861
return capabilityHelper.validate(bsConfig, args).then(function (cypressJson) {
5962

@@ -119,7 +122,7 @@ module.exports = function run(args) {
119122
utils.sendUsageReport(bsConfig, args, err, Constants.messageTypes.ERROR, 'build_failed');
120123
});
121124
}).catch(function (err) {
122-
// Zip Upload failed | Local Start failed
125+
// Zip Upload failed | Local Start failed
123126
logger.error(err);
124127
if(err === Constants.userMessages.LOCAL_START_FAILED){
125128
utils.sendUsageReport(bsConfig, args, `${err}\n${Constants.userMessages.LOCAL_START_FAILED}`, Constants.messageTypes.ERROR, 'local_start_failed');

bin/helpers/constants.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ const cliMessages = {
105105
LOCAL_MODE: 'Accepted values: ("always-on" | "on-demand") - if you choose to keep the binary "always-on", it will speed up your tests by keeping the Local connection warmed up in the background; otherwise, you can choose to have it spawn and killed for every build',
106106
LOCAL_IDENTIFIER: "Accepted values: String - assign an identifier to your Local process instance",
107107
LOCAL_CONFIG_FILE: "Accepted values: String - path to local config-file to your Local process instance. Learn more at https://www.browserstack.com/local-testing/binary-params",
108-
NO_WRAP: "Wrap the spec names in --sync mode in case of smaller terminal window size pass --no-wrap"
108+
SYNC_NO_WRAP: "Wrap the spec names in --sync mode in case of smaller terminal window size pass --no-wrap"
109109
},
110110
COMMON: {
111111
DISABLE_USAGE_REPORTING: "Disable usage reporting",

bin/helpers/sync/syncSpecsLogs.js

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,12 @@ let specSummary = {
1313
"specs": [],
1414
"duration": null
1515
}
16-
let noWrap = utils.searchForOption('--no-wrap')
16+
let noWrap = (process.env.SYNC_NO_WRAP || false);
1717
let terminalWidth = (process.stdout.columns) * 0.9;
18+
let lineSeparator = "\n--------------------------------------------------------------------------------";
19+
if (noWrap) {
20+
lineSeparator = "\n" + "-".repeat(terminalWidth);
21+
}
1822

1923
let getOptions = (auth, build_id) => {
2024
return {
@@ -32,14 +36,25 @@ let getOptions = (auth, build_id) => {
3236
}
3337

3438
let getTableConfig = () => {
39+
let centerWidth = Math.ceil(terminalWidth * 0.01),
40+
leftWidth = Math.floor(terminalWidth * 0.75),
41+
colWidth = Math.floor(terminalWidth * 0.2);
42+
43+
// Do not autosize on terminal's width if no-wrap provided
44+
if (noWrap) {
45+
centerWidth = 1;
46+
leftWidth = 100;
47+
colWidth = 30;
48+
}
49+
3550
return {
3651
border: getBorderConfig(),
3752
columns: {
38-
1: {alignment: 'center', width: noWrap ? 1 : Math.ceil(terminalWidth * 0.01)},
39-
2: {alignment: 'left', width: noWrap ? 100 : Math.floor(terminalWidth * 0.75)}
53+
1: {alignment: 'center', width: centerWidth},
54+
2: {alignment: 'left', width: leftWidth}
4055
},
4156
columnDefault: {
42-
width: noWrap ? 30 : Math.floor(terminalWidth * 0.2),
57+
width: colWidth,
4358
},
4459
columnCount: 3,
4560
};
@@ -82,7 +97,7 @@ let printSpecsStatus = (bsConfig, buildDetails) => {
8297
whileProcess(callback)
8398
},
8499
function(err, result) { // when loop ends
85-
noWrap ? logger.info("\n--------------------------------------------------------------------------------") : logger.info("\n" + "-".repeat(terminalWidth))
100+
logger.info(lineSeparator);
86101
specSummary.duration = endTime - startTime
87102
resolve(specSummary)
88103
}
@@ -140,7 +155,7 @@ let showSpecsStatus = (data) => {
140155

141156
let printInitialLog = () => {
142157
logger.info(`\n${Constants.syncCLI.LOGS.INIT_LOG}`)
143-
noWrap ? logger.info("\n--------------------------------------------------------------------------------") : logger.info("\n" + "-".repeat(terminalWidth))
158+
logger.info(lineSeparator);
144159
n = Constants.syncCLI.INITIAL_DELAY_MULTIPLIER
145160
}
146161

bin/helpers/utils.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,14 @@ exports.setHeaded = (bsConfig, args) => {
571571
}
572572
};
573573

574+
exports.setNoWrap = (_bsConfig, args) => {
575+
if (args.noWrap === true) {
576+
process.env.SYNC_NO_WRAP = true;
577+
} else {
578+
process.env.SYNC_NO_WRAP = false;
579+
}
580+
}
581+
574582
exports.getNumberOfSpecFiles = (bsConfig, args, cypressJson) => {
575583
let testFolderPath = cypressJson.integrationFolder || Constants.DEFAULT_CYPRESS_SPEC_PATH;
576584
let globSearchPattern = this.sanitizeSpecsPattern(bsConfig.run_settings.specs) || `${testFolderPath}/**/*.+(${Constants.specFileTypes.join("|")})`;

bin/runner.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,9 @@ var argv = yargs
223223
type: "string"
224224
},
225225
'no-wrap': {
226-
describe: Constants.cliMessages.RUN.NO_WRAP
226+
default: false,
227+
describe: Constants.cliMessages.RUN.SYNC_NO_WRAP,
228+
type: "boolean"
227229
}
228230
})
229231
.help('help')

0 commit comments

Comments
 (0)