@sasjs/cli 3.2.0 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -6,3 +6,4 @@ export declare const saveResultCsv: (outDirectory: string, result: TestResults,
|
|
|
6
6
|
csvPath: string;
|
|
7
7
|
}>;
|
|
8
8
|
export declare const saveResultXml: (outDirectory: string, result: TestResults) => Promise<string>;
|
|
9
|
+
export declare const saveCoverageLcov: (outDirectory: string, tests: string[]) => Promise<string>;
|
|
@@ -60,7 +60,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
60
60
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
61
61
|
};
|
|
62
62
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
63
|
-
exports.saveResultXml = exports.saveResultCsv = exports.saveResultJson = exports.saveLog = void 0;
|
|
63
|
+
exports.saveCoverageLcov = exports.saveResultXml = exports.saveResultCsv = exports.saveResultJson = exports.saveLog = void 0;
|
|
64
64
|
var path_1 = __importDefault(require("path"));
|
|
65
65
|
var utils_1 = require("@sasjs/utils");
|
|
66
66
|
var file_1 = require("../../../utils/file");
|
|
@@ -262,3 +262,43 @@ var saveResultXml = function (outDirectory, result) { return __awaiter(void 0, v
|
|
|
262
262
|
});
|
|
263
263
|
}); };
|
|
264
264
|
exports.saveResultXml = saveResultXml;
|
|
265
|
+
var saveCoverageLcov = function (outDirectory, tests) { return __awaiter(void 0, void 0, void 0, function () {
|
|
266
|
+
var testsPrefixRegExp, coverageReport, coveringFile, filePath;
|
|
267
|
+
return __generator(this, function (_a) {
|
|
268
|
+
switch (_a.label) {
|
|
269
|
+
case 0:
|
|
270
|
+
testsPrefixRegExp = new RegExp("^tests/");
|
|
271
|
+
coverageReport = [];
|
|
272
|
+
coveringFile = function (filePath) { return __awaiter(void 0, void 0, void 0, function () {
|
|
273
|
+
return __generator(this, function (_a) {
|
|
274
|
+
switch (_a.label) {
|
|
275
|
+
case 0: return [4 /*yield*/, utils_1.fileExists(path_1.default.join(process.sasjsConstants.buildDestinationFolder, filePath))];
|
|
276
|
+
case 1: return [2 /*return*/, (_a.sent())
|
|
277
|
+
? filePath
|
|
278
|
+
: 'standalone'];
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
}); };
|
|
282
|
+
return [4 /*yield*/, utils_1.asyncForEach(tests, function (test) { return __awaiter(void 0, void 0, void 0, function () {
|
|
283
|
+
var _a, _b, _c;
|
|
284
|
+
return __generator(this, function (_d) {
|
|
285
|
+
switch (_d.label) {
|
|
286
|
+
case 0:
|
|
287
|
+
_b = (_a = coverageReport).push;
|
|
288
|
+
_c = "TN:" + test.split('/').pop() + "\nSF:";
|
|
289
|
+
return [4 /*yield*/, coveringFile(test.replace(testsPrefixRegExp, '').replace(utils_1.testFileRegExp, '.sas'))];
|
|
290
|
+
case 1: return [2 /*return*/, _b.apply(_a, [_c + (_d.sent()) + "\nFNF:1\nFNH:1\nLF:1\nLH:1\nBRF:1\nBRH:1\nend_of_record"])];
|
|
291
|
+
}
|
|
292
|
+
});
|
|
293
|
+
}); })];
|
|
294
|
+
case 1:
|
|
295
|
+
_a.sent();
|
|
296
|
+
filePath = path_1.default.join(outDirectory, 'coverage.lcov');
|
|
297
|
+
return [4 /*yield*/, utils_1.createFile(filePath, coverageReport.join('\n'))];
|
|
298
|
+
case 2:
|
|
299
|
+
_a.sent();
|
|
300
|
+
return [2 /*return*/, filePath];
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
}); };
|
|
304
|
+
exports.saveCoverageLcov = saveCoverageLcov;
|
|
@@ -99,7 +99,7 @@ describe('sasjs test', function () {
|
|
|
99
99
|
});
|
|
100
100
|
}); });
|
|
101
101
|
it('should execute tests and create result CSV, XML and JSON files using default source and output locations', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
102
|
-
var expectedResultsJson, expectedResultsCsv, resultsFolderPath, resultsJsonPath, resultsJson, resultsCsvPath, parsedResults, resultsCsv, resultsXmlPath, resultsXml, expectedResultsXml;
|
|
102
|
+
var expectedResultsJson, expectedResultsCsv, resultsFolderPath, resultsJsonPath, resultsJson, resultsCsvPath, parsedResults, resultsCsv, resultsXmlPath, resultsXml, expectedResultsXml, coverageLcovPath, expectedCoverageLcov, coverageLcov;
|
|
103
103
|
return __generator(this, function (_a) {
|
|
104
104
|
switch (_a.label) {
|
|
105
105
|
case 0:
|
|
@@ -232,6 +232,15 @@ describe('sasjs test', function () {
|
|
|
232
232
|
resultsXml = resultsXml.replace(/testsuites id="[^ ]*"/gm, "testsuites id=\"\"");
|
|
233
233
|
resultsXml = resultsXml.replace(/testcase id="[^ ]*"/gm, "testcase id=\"\"");
|
|
234
234
|
expect(resultsXml).toEqual(expectedResultsXml);
|
|
235
|
+
coverageLcovPath = path_1.default.join(resultsFolderPath, 'coverage.lcov');
|
|
236
|
+
return [4 /*yield*/, expect(utils_1.fileExists(coverageLcovPath)).resolves.toEqual(true)];
|
|
237
|
+
case 9:
|
|
238
|
+
_a.sent();
|
|
239
|
+
expectedCoverageLcov = "TN:testsetup.sas\nSF:standalone\nFNF:1\nFNH:1\nLF:1\nLH:1\nBRF:1\nBRH:1\nend_of_record\nTN:exampleprogram.test.sas\nSF:jobs/jobs/exampleprogram.sas\nFNF:1\nFNH:1\nLF:1\nLH:1\nBRF:1\nBRH:1\nend_of_record\nTN:standalone.test.sas\nSF:standalone\nFNF:1\nFNH:1\nLF:1\nLH:1\nBRF:1\nBRH:1\nend_of_record\nTN:examplemacro.test.sas\nSF:standalone\nFNF:1\nFNH:1\nLF:1\nLH:1\nBRF:1\nBRH:1\nend_of_record\nTN:shouldFail.test.sas\nSF:standalone\nFNF:1\nFNH:1\nLF:1\nLH:1\nBRF:1\nBRH:1\nend_of_record\nTN:dostuff.test.0.sas\nSF:services/admin/dostuff.sas\nFNF:1\nFNH:1\nLF:1\nLH:1\nBRF:1\nBRH:1\nend_of_record\nTN:dostuff.test.1.sas\nSF:services/admin/dostuff.sas\nFNF:1\nFNH:1\nLF:1\nLH:1\nBRF:1\nBRH:1\nend_of_record\nTN:testteardown.sas\nSF:standalone\nFNF:1\nFNH:1\nLF:1\nLH:1\nBRF:1\nBRH:1\nend_of_record";
|
|
240
|
+
return [4 /*yield*/, utils_1.readFile(coverageLcovPath)];
|
|
241
|
+
case 10:
|
|
242
|
+
coverageLcov = _a.sent();
|
|
243
|
+
expect(coverageLcov).toEqual(expectedCoverageLcov);
|
|
235
244
|
return [2 /*return*/];
|
|
236
245
|
}
|
|
237
246
|
});
|
|
@@ -86,7 +86,7 @@ function runTest(target, testRegExps, outDirectory, flowSourcePath) {
|
|
|
86
86
|
var _a, _b;
|
|
87
87
|
if (testRegExps === void 0) { testRegExps = []; }
|
|
88
88
|
return __awaiter(this, void 0, void 0, function () {
|
|
89
|
-
var testFlowData, testFlow, flow, sasjs, authConfig, username, password, sas9CredentialsError, result, isCodeExamplePrinted, printCodeExample, jsonPath, xmlPath, _c, csvData, csvPath, resultTable, testsCount, passedTestsCount, testsWithResultsCount;
|
|
89
|
+
var testFlowData, testFlow, flow, sasjs, authConfig, username, password, sas9CredentialsError, result, isCodeExamplePrinted, printCodeExample, jsonPath, xmlPath, _c, csvData, csvPath, coverageReportPath, resultTable, testsCount, passedTestsCount, testsWithResultsCount;
|
|
90
90
|
var _this = this;
|
|
91
91
|
return __generator(this, function (_d) {
|
|
92
92
|
switch (_d.label) {
|
|
@@ -328,6 +328,9 @@ function runTest(target, testRegExps, outDirectory, flowSourcePath) {
|
|
|
328
328
|
return [4 /*yield*/, saveOutput_1.saveResultCsv(outDirectory, result)];
|
|
329
329
|
case 7:
|
|
330
330
|
_c = _d.sent(), csvData = _c.csvData, csvPath = _c.csvPath;
|
|
331
|
+
return [4 /*yield*/, saveOutput_1.saveCoverageLcov(outDirectory, flow)];
|
|
332
|
+
case 8:
|
|
333
|
+
coverageReportPath = _d.sent();
|
|
331
334
|
resultTable = {};
|
|
332
335
|
if (Array.isArray(csvData)) {
|
|
333
336
|
csvData.forEach(function (item) {
|
|
@@ -353,6 +356,7 @@ function runTest(target, testRegExps, outDirectory, flowSourcePath) {
|
|
|
353
356
|
testsWithResultsCount = Object.values(resultTable).filter(function (res) { return res.test_suite_result !== types_1.TestResultStatus.notProvided; }).length;
|
|
354
357
|
(_b = process.logger) === null || _b === void 0 ? void 0 : _b.info("Tests provided results: " + (testsWithResultsCount + '/' + testsCount) + " (" + chalk_1.default.greenBright(Math.round((testsWithResultsCount / testsCount) * 100 || 0) + '%') + ")\n Tests that pass: " + (passedTestsCount + '/' + testsWithResultsCount) + " (" + chalk_1.default.greenBright(Math.round((passedTestsCount / testsWithResultsCount) * 100 || 0) + '%') + ")\n ");
|
|
355
358
|
displayResult_1.displaySuccess("Tests execution finished. The results are stored at:\n " + jsonPath + "\n " + csvPath + "\n " + xmlPath);
|
|
359
|
+
displayResult_1.displaySuccess("Tests coverage report:\n " + coverageReportPath);
|
|
356
360
|
return [2 /*return*/];
|
|
357
361
|
}
|
|
358
362
|
});
|
package/package.json
CHANGED