Skip to content

Commit dbc2843

Browse files
committed
chore: fix alignment issues of the duration output
1 parent 6880880 commit dbc2843

File tree

4 files changed

+18
-33
lines changed

4 files changed

+18
-33
lines changed

bin/helpers/sync/specsSummary.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ let printSpecsRunSummary = (data, machines, customErrorsToPrint) => {
3333
});
3434

3535
logger.info(`Total tests: ${summary.total}, passed: ${summary.passed}, failed: ${summary.failed}, skipped: ${summary.skipped}, passed_with_skipped: ${summary.passed_with_skipped}, pending: ${summary.pending}`);
36-
logger.debug(`CLI calculated duration: ${data.duration/1000} seconds using ${machines} machines\n`);
36+
logger.info(`Done in ${data.duration} seconds using ${data.parallels} machines\n`);
37+
winstonlogger.debug(`CLI calculated duration is ${data.cliDuration}\n`);
3738

3839
if (customErrorsToPrint && customErrorsToPrint.length > 0) {
3940
for (const error of customErrorsToPrint) {

bin/helpers/sync/syncSpecsLogs.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ let specSummary = {
1414
"buildError": null,
1515
"specs": [],
1616
"duration": null,
17+
"parallels": null,
18+
"cliDuration": null,
1719
"customErrorsToPrint": []
1820
}
1921

@@ -120,7 +122,7 @@ let printSpecsStatus = (bsConfig, buildDetails, rawArgs, buildReportData) => {
120122
}
121123
}
122124
logger.info(lineSeparator);
123-
specSummary.duration = endTime - startTime
125+
specSummary.cliDuration = endTime - startTime
124126
resolve(specSummary);
125127
}
126128
);
@@ -196,7 +198,8 @@ let showSpecsStatus = (data, statusCode) => {
196198
const buildDetails = specData.buildData;
197199
const totalDuration = buildDetails.duration?.total_duration
198200
const parallels = buildDetails.parallels
199-
logger.info(`Done in ${totalDuration} seconds with ${parallels} parallels.\n`);
201+
specSummary.duration = totalDuration;
202+
specSummary.parallels = parallels;
200203
} else {
201204
logger.debug(`Build details not sent`)
202205
}

test/unit/bin/helpers/sync/specSummary.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ describe("printSpecsRunSummary", () => {
2929
});
3030

3131
context("with data", () => {
32-
let time = 6000,
32+
let time = 6,
3333
machines = 2,
3434
specs = [
3535
{specName: 'spec2.name.js', status: 'Failed', combination: 'Win 10 / Chrome 78', sessionId: '3d3rdf3r...'},
@@ -40,24 +40,23 @@ describe("printSpecsRunSummary", () => {
4040
data = {
4141
specs: specs,
4242
duration: time,
43+
parallels: machines,
4344
exitCode: 0
4445
};
4546

4647
it('returns passed specs data', () => {
4748
var loggerInfoSpy = sinon.spy(logger, 'info');
48-
var loggerDebugSpy = sinon.spy(logger, 'debug');
4949

5050
specSummary.printSpecsRunSummary(data, machines);
5151
sinon.assert.calledWith(loggerInfoSpy, 'Total tests: 4, passed: 1, failed: 2, skipped: 1, passed_with_skipped: 0, pending: 0');
52-
sinon.assert.calledWith(loggerDebugSpy, `CLI calculated duration: ${time / 1000} seconds using ${machines} machines\n`);
52+
sinon.assert.calledWith(loggerInfoSpy, `Done in ${data.duration} seconds using ${data.parallels} machines\n`);
5353

5454
loggerInfoSpy.restore();
55-
loggerDebugSpy.restore();
5655
});
5756
});
5857

5958
context("with custom error data", () => {
60-
let time = 6000,
59+
let time = 6,
6160
machines = 2,
6261
specs = [
6362
{specName: 'spec2.name.js', status: 'Failed', combination: 'Win 10 / Chrome 78', sessionId: '3d3rdf3r...'},
@@ -68,6 +67,7 @@ describe("printSpecsRunSummary", () => {
6867
data = {
6968
specs: specs,
7069
duration: time,
70+
parallels: machines,
7171
exitCode: 0
7272
},
7373
customErrorsToPrint = [
@@ -76,16 +76,15 @@ describe("printSpecsRunSummary", () => {
7676

7777
it('prints the custom error message along with build details', () => {
7878
var loggerInfoSpy = sinon.spy(logger, 'info');
79-
var loggerDebugSpy = sinon.spy(logger, 'debug');
8079
var loggerWarnSpy = sinon.spy(winstonLogger, 'warn');
8180

8281
specSummary.printSpecsRunSummary(data, machines, customErrorsToPrint);
8382
sinon.assert.calledWith(loggerInfoSpy, 'Total tests: 4, passed: 1, failed: 2, skipped: 1, passed_with_skipped: 0, pending: 0');
84-
sinon.assert.calledWith(loggerDebugSpy, `CLI calculated duration: ${time / 1000} seconds using ${machines} machines\n`);
83+
sinon.assert.calledWith(loggerInfoSpy, `Done in ${data.duration} seconds using ${data.parallels} machines\n`);
84+
8585
sinon.assert.calledWith(loggerWarnSpy, `custom error message`);
8686

8787
loggerInfoSpy.restore();
88-
loggerDebugSpy.restore();
8988
loggerWarnSpy.restore();
9089
});
9190
});

test/unit/bin/helpers/sync/syncSpecsLogs.js

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ describe("syncSpecsLogs", () => {
9393
"buildError": null,
9494
"specs": [],
9595
"duration": null,
96+
"parallels": null,
97+
"cliDuration": null,
9698
"customErrorsToPrint": [
9799
{ id: "custom_error_1", type: "custom_errors_to_print", level: "warn", should_be_unique: true, message: "custom error message" }
98100
]
@@ -268,26 +270,6 @@ describe("syncSpecsLogs", () => {
268270
expect(printInitialLog.calledOnce).to.be.true;
269271
expect(addCustomErrorToPrint.calledOnce).to.be.true;
270272
});
271-
272-
it('should add custom error, print initial and spec details when spec related data and duration is sent in polling response', () => {
273-
let specResult = JSON.stringify({"path": "path"})
274-
let customError = { id: "custom_error_1", type: "custom_errors_to_print", level: "warn", should_be_unique: true, message: "custom error message" }
275-
var loggerInfoSpy = sinon.spy(logger, 'info');
276-
syncSpecsLogs.__set__('buildStarted', false)
277-
let data = JSON.stringify({ "specData": ["created", specResult, customError], "buildData": {"duration": {"total_duration": "87"}, "parallels": "2"}})
278-
var printSpecData = sandbox.stub();
279-
syncSpecsLogs.__set__('printSpecData', printSpecData);
280-
var printInitialLog = sandbox.stub();
281-
syncSpecsLogs.__set__('printInitialLog', printInitialLog);
282-
var addCustomErrorToPrint = sandbox.stub();
283-
syncSpecsLogs.__set__('addCustomErrorToPrint', addCustomErrorToPrint);
284-
showSpecsStatus(data, buildCompletedStatusCode);
285-
expect(printSpecData.calledOnce).to.be.true;
286-
expect(printInitialLog.calledOnce).to.be.true;
287-
expect(addCustomErrorToPrint.calledOnce).to.be.true;
288-
sinon.assert.calledWith(loggerInfoSpy, 'Done in 87 seconds with 2 parallels.\n');
289-
loggerInfoSpy.restore();
290-
});
291273
});
292274

293275
context("printSpecsStatus", () => {
@@ -330,7 +312,7 @@ describe("syncSpecsLogs", () => {
330312
expect(tableStream.calledOnce).to.be.true;
331313
expect(whileProcess.calledOnce).to.be.false;
332314
expect(specSummary.specs).deep.to.equal([])
333-
expect(specSummary.duration).to.eql(endTime - startTime);
315+
expect(specSummary.cliDuration).to.eql(endTime - startTime);
334316
});
335317
});
336318

@@ -345,7 +327,7 @@ describe("syncSpecsLogs", () => {
345327
expect(getTableConfig.calledOnce).to.be.true;
346328
expect(tableStream.calledOnce).to.be.true;
347329
expect(whileProcess.callCount).to.eql(3);
348-
expect(specSummary.duration).to.eql(endTime - startTime);
330+
expect(specSummary.cliDuration).to.eql(endTime - startTime);
349331
});
350332
});
351333
});

0 commit comments

Comments
 (0)