Skip to content

Commit 754690e

Browse files
authored
Merge pull request #318 from roshan04/fix_sync_cli_count_mismatch
Fix sync cli count mismatch
2 parents 699ca7c + d6b86f4 commit 754690e

File tree

6 files changed

+70
-17
lines changed

6 files changed

+70
-17
lines changed

bin/helpers/sync/failedSpecsDetails.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,7 @@ let failedSpecsDetails = (data) => {
3838
if (spec.status && spec.status.toLowerCase() === 'failed' && !failedSpecs)
3939
failedSpecs = true;
4040

41-
let specStatus =
42-
spec.status && spec.status.toLowerCase() === 'failed'
43-
? chalk.red(spec.status)
44-
: chalk.yellow(spec.status);
41+
let specStatus = getSpecStatus(spec.status)
4542
specData.push([
4643
spec.specName,
4744
specStatus,
@@ -79,4 +76,15 @@ let failedSpecsDetails = (data) => {
7976
});
8077
}
8178

79+
let getSpecStatus = (specStatus) => {
80+
switch(specStatus.toLowerCase()) {
81+
case 'failed': return chalk.red(specStatus);
82+
case 'pending':
83+
case 'skipped':
84+
case 'passed_with_skipped': return chalk.blueBright(specStatus);
85+
default: return chalk.yellow(specStatus);
86+
}
87+
}
88+
8289
exports.failedSpecsDetails = failedSpecsDetails;
90+
exports.getSpecStatus = getSpecStatus;

bin/helpers/sync/specsSummary.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,16 @@ let printSpecsRunSummary = (data, machines, customErrorsToPrint) => {
2323
total: 0,
2424
failed: 0,
2525
passed: 0,
26-
skipped: 0
26+
skipped: 0,
27+
passed_with_skipped: 0,
28+
pending: 0
2729
};
2830

2931
data.specs.forEach((spec) => {
3032
specSummaryCount(summary, spec.status.toLowerCase());
3133
});
3234

33-
logger.info(`Total tests: ${summary.total}, passed: ${summary.passed}, failed: ${summary.failed}, skipped: ${summary.skipped}`);
35+
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}`);
3436
logger.info(`Done in ${data.duration/1000} seconds using ${machines} machines\n`);
3537

3638
if (customErrorsToPrint && customErrorsToPrint.length > 0) {
@@ -57,9 +59,15 @@ let specSummaryCount = (summary, status) => {
5759
case 'failed':
5860
summary.failed++;
5961
break;
62+
case "passed_with_skipped":
63+
summary.passed_with_skipped++;
64+
break;
6065
case 'skipped':
6166
summary.skipped++;
6267
break;
68+
case "pending":
69+
summary.pending++;
70+
break;
6371
case 'passed':
6472
summary.passed++;
6573
break;

bin/helpers/sync/syncSpecsLogs.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -201,13 +201,14 @@ let printInitialLog = () => {
201201

202202
let printSpecData = (data) => {
203203
let combination = getCombinationName(data["spec"]);
204-
let status = getStatus(data["spec"]["status"]);
205-
writeToTable(combination, data["path"], status)
206-
addSpecToSummary(data["path"], data["spec"]["status"], combination, data["session_id"])
204+
let status = data["spec"]["status"];
205+
let statusMark = getStatus(status);
206+
writeToTable(combination, data["path"], status, statusMark)
207+
addSpecToSummary(data["path"], status, combination, data["session_id"])
207208
}
208209

209-
let writeToTable = (combination, specName, status) => {
210-
stream.write([combination , ":", `${specName} ${status}`]);
210+
let writeToTable = (combination, specName, status, statusMark) => {
211+
stream.write([combination , ":", `${specName} ${statusMark} [${status}]`]);
211212
}
212213

213214
let addCustomErrorToPrint = (error_object) => {
@@ -241,6 +242,8 @@ let getStatus = (status) => {
241242
return chalk.green("✔");
242243
case "failed":
243244
return chalk.red("✘");
245+
case "passed_with_skipped":
246+
return chalk.blueBright("✔");
244247
default:
245248
return chalk.blue(`[${status}]`);
246249
}

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

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
'use strict';
22
const chai = require("chai"),
33
expect = chai.expect,
4-
chaiAsPromised = require("chai-as-promised");
4+
chaiAsPromised = require("chai-as-promised"),
5+
chalk = require('chalk');
56

67
const sinon = require("sinon");
78
chai.use(chaiAsPromised);
@@ -74,3 +75,36 @@ describe("failedSpecsDetails", () => {
7475
});
7576
});
7677
});
78+
79+
describe("#getSpecStatus", () => {
80+
81+
it("returns failed in red if specStatus is failed", () => {
82+
let specStatus = "failed";
83+
let response = chalk.red(specStatus);
84+
expect(specDetails.getSpecStatus(specStatus)).to.eq(response);
85+
});
86+
87+
it("returns passed_with_skipped in blueBright if specStatus is passed_with_skipped", () => {
88+
let specStatus = "passed_with_skipped";
89+
let response = chalk.blueBright(specStatus);
90+
expect(specDetails.getSpecStatus(specStatus)).to.eq(response);
91+
});
92+
93+
it("returns pending in blueBright if specStatus is pending", () => {
94+
let specStatus = "pending";
95+
let response = chalk.blueBright(specStatus);
96+
expect(specDetails.getSpecStatus(specStatus)).to.eq(response);
97+
});
98+
99+
it("returns skipped in blueBright if specStatus is skipped", () => {
100+
let specStatus = "skipped";
101+
let response = chalk.blueBright(specStatus);
102+
expect(specDetails.getSpecStatus(specStatus)).to.eq(response);
103+
});
104+
105+
it("returns other statuses in yellow if specStatus is other than something known", () => {
106+
let specStatus = "xyz";
107+
let response = chalk.yellow(specStatus);
108+
expect(specDetails.getSpecStatus(specStatus)).to.eq(response);
109+
});
110+
});

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ describe("printSpecsRunSummary", () => {
4747
var loggerInfoSpy = sinon.spy(logger, 'info');
4848

4949
specSummary.printSpecsRunSummary(data, machines);
50-
sinon.assert.calledWith(loggerInfoSpy, 'Total tests: 4, passed: 1, failed: 2, skipped: 1');
50+
sinon.assert.calledWith(loggerInfoSpy, 'Total tests: 4, passed: 1, failed: 2, skipped: 1, passed_with_skipped: 0, pending: 0');
5151
sinon.assert.calledWith(loggerInfoSpy, `Done in ${time / 1000} seconds using ${machines} machines\n`);
5252

5353
loggerInfoSpy.restore();
@@ -77,7 +77,7 @@ describe("printSpecsRunSummary", () => {
7777
var loggerWarnSpy = sinon.spy(winstonLogger, 'warn');
7878

7979
specSummary.printSpecsRunSummary(data, machines, customErrorsToPrint);
80-
sinon.assert.calledWith(loggerInfoSpy, 'Total tests: 4, passed: 1, failed: 2, skipped: 1');
80+
sinon.assert.calledWith(loggerInfoSpy, 'Total tests: 4, passed: 1, failed: 2, skipped: 1, passed_with_skipped: 0, pending: 0');
8181
sinon.assert.calledWith(loggerInfoSpy, `Done in ${time / 1000} seconds using ${machines} machines\n`);
8282
sinon.assert.calledWith(loggerWarnSpy, `custom error message`);
8383

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,9 @@ describe("syncSpecsLogs", () => {
172172
const stream = sandbox.stub();
173173
stream.write = sandbox.stub();
174174
syncSpecsLogs.__set__('stream', stream);
175-
let combination = "Windows 10", path = "path", status = "passed";
176-
writeToTable(combination, path, status);
177-
sinon.assert.calledOnceWithExactly(stream.write, [combination , ":", `${path} ${status}`]);
175+
let combination = "Windows 10", path = "path", status = "passed", statusMark = "passed";
176+
writeToTable(combination, path, status, statusMark);
177+
sinon.assert.calledOnceWithExactly(stream.write, [combination , ":", `${path} ${statusMark} [${status}]`]);
178178
});
179179
});
180180

0 commit comments

Comments
 (0)