mirror of https://gitee.com/bigwinds/arangodb
Unwurst results
This commit is contained in:
parent
381a266fcc
commit
8312c64f60
|
@ -71,78 +71,39 @@ function resultsToXml(results, baseName, cluster) {
|
|||
clprefix = 'CL_';
|
||||
}
|
||||
|
||||
const isSignificant = function(a, b) {
|
||||
return (internalMembers.indexOf(b) === -1) && a.hasOwnProperty(b);
|
||||
};
|
||||
let cleanedResults = UnitTest.unwurst(results);
|
||||
print(JSON.stringify(cleanedResults));
|
||||
cleanedResults.forEach(suite => {
|
||||
print(suite.suiteName);
|
||||
let xml = buildXml();
|
||||
xml.elem('testsuite', {
|
||||
errors: suite.tests.filter(test => test.hasOwnProperty('error')).length,
|
||||
failures: suite.tests.filter(test => test.hasOwnProperty('failure')).length,
|
||||
tests: suite.tests.length,
|
||||
name: suite.suiteName,
|
||||
});
|
||||
|
||||
for (let resultName in results) {
|
||||
if (isSignificant(results, resultName)) {
|
||||
let run = results[resultName];
|
||||
|
||||
for (let runName in run) {
|
||||
if (isSignificant(run, runName)) {
|
||||
const xmlName = clprefix + resultName + "_" + runName;
|
||||
const current = run[runName];
|
||||
|
||||
if (current.skipped) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let xml = buildXml();
|
||||
let total = 0;
|
||||
|
||||
if (current.hasOwnProperty('total')) {
|
||||
total = current.total;
|
||||
}
|
||||
|
||||
let failuresFound = current.failed;
|
||||
xml.elem("testsuite", {
|
||||
errors: 0,
|
||||
failures: failuresFound,
|
||||
tests: total,
|
||||
name: xmlName,
|
||||
time: 0 + current.duration
|
||||
});
|
||||
|
||||
let seen = false;
|
||||
|
||||
for (let oneTestName in current) {
|
||||
if (isSignificant(current, oneTestName)) {
|
||||
const oneTest = current[oneTestName];
|
||||
const success = (oneTest.status === true);
|
||||
|
||||
seen = true;
|
||||
|
||||
xml.elem("testcase", {
|
||||
name: clprefix + oneTestName,
|
||||
time: 0 + oneTest.duration
|
||||
}, success);
|
||||
|
||||
if (!success) {
|
||||
xml.elem("failure");
|
||||
xml.text('<![CDATA[' + oneTest.message + ']]>\n');
|
||||
xml.elem("/failure");
|
||||
xml.elem("/testcase");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!seen) {
|
||||
xml.elem("testcase", {
|
||||
name: 'all_tests_in_' + xmlName,
|
||||
time: 0 + current.duration
|
||||
}, true);
|
||||
}
|
||||
|
||||
xml.elem("/testsuite");
|
||||
|
||||
const fn = makePathGeneric(baseName + xmlName + ".xml").join('_');
|
||||
|
||||
fs.write(testOutputDirectory + fn, xml.join(""));
|
||||
}
|
||||
suite.tests.forEach(test => {
|
||||
xml.elem('testcase', {
|
||||
name: test.testName,
|
||||
});
|
||||
if (test.error) {
|
||||
xml.elem('error');
|
||||
xml.text('<![CDATA[' + test.error + ']]>\n');
|
||||
xml.elem('/error');
|
||||
}
|
||||
}
|
||||
}
|
||||
if (test.failure) {
|
||||
xml.elem('failure');
|
||||
xml.text('<![CDATA[' + test.failure + ']]>\n');
|
||||
xml.elem('/failure');
|
||||
}
|
||||
xml.elem('/testcase');
|
||||
});
|
||||
xml.elem('/testsuite');
|
||||
|
||||
const fn = makePathGeneric(baseName + suite.suiteName + ".xml").join('_');
|
||||
fs.write(testOutputDirectory + fn, xml.join(""));
|
||||
});
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -198,6 +198,117 @@ function testCaseMessage (test) {
|
|||
}
|
||||
}
|
||||
|
||||
function unwurst(r) {
|
||||
function skipInternalMember (r, a) {
|
||||
return !r.hasOwnProperty(a) || internalMembers.indexOf(a) !== -1;
|
||||
}
|
||||
|
||||
let testSuites = [];
|
||||
/* jshint forin: false */
|
||||
for (let testrunName in r) {
|
||||
if (skipInternalMember(r, testrunName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let testrun = r[testrunName];
|
||||
|
||||
let successCases = {};
|
||||
let failedCases = {};
|
||||
let isSuccess = true;
|
||||
|
||||
let suiteDefinition = {
|
||||
suiteName: testrunName,
|
||||
tests: [],
|
||||
}
|
||||
|
||||
for (let testName in testrun) {
|
||||
if (skipInternalMember(testrun, testName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let test = testrun[testName];
|
||||
|
||||
if (test.status) {
|
||||
successCases[testName] = test;
|
||||
} else {
|
||||
isSuccess = false;
|
||||
++failedSuite;
|
||||
|
||||
if (test.hasOwnProperty('message')) {
|
||||
++failedTests;
|
||||
failedCases[testName] = {
|
||||
test: testCaseMessage(test)
|
||||
};
|
||||
} else {
|
||||
let fails = failedCases[testName] = {};
|
||||
|
||||
for (let oneName in test) {
|
||||
if (skipInternalMember(test, oneName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let oneTest = test[oneName];
|
||||
|
||||
if (!oneTest.status) {
|
||||
++failedTests;
|
||||
fails[oneName] = testCaseMessage(oneTest);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (let name in successCases) {
|
||||
if (!successCases.hasOwnProperty(name)) {
|
||||
continue;
|
||||
}
|
||||
let thisTest = {
|
||||
testName: name,
|
||||
}
|
||||
let details = successCases[name];
|
||||
|
||||
if (details.skipped) {
|
||||
thisTest.skipped = true;
|
||||
}
|
||||
|
||||
suiteDefinition.tests.push(thisTest);
|
||||
}
|
||||
|
||||
for (let name in failedCases) {
|
||||
if (!failedCases.hasOwnProperty(name)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let details = failedCases[name];
|
||||
let message = '';
|
||||
for (let one in details) {
|
||||
if (!details.hasOwnProperty(one)) {
|
||||
continue;
|
||||
}
|
||||
message += details[one];
|
||||
}
|
||||
|
||||
suiteDefinition.tests.push({
|
||||
testName: name,
|
||||
failure: message,
|
||||
});
|
||||
}
|
||||
testSuites.push(suiteDefinition);
|
||||
}
|
||||
|
||||
let arangodStatusBogusTest = {
|
||||
testName: 'arangod',
|
||||
}
|
||||
if (r.crashed) {
|
||||
arangodStatusBogusTest.error = 'arangod crashed during execution!';
|
||||
}
|
||||
testSuites.push({
|
||||
suiteName: 'arangod-status',
|
||||
tests: [arangodStatusBogusTest],
|
||||
});
|
||||
return testSuites;
|
||||
}
|
||||
|
||||
function unitTestPrettyPrintResults (r, testOutputDirectory, options) {
|
||||
function skipInternalMember (r, a) {
|
||||
return !r.hasOwnProperty(a) || internalMembers.indexOf(a) !== -1;
|
||||
|
@ -546,6 +657,7 @@ function unitTest (cases, options) {
|
|||
exports.unitTest = unitTest;
|
||||
|
||||
exports.internalMembers = internalMembers;
|
||||
exports.unwurst = unwurst;
|
||||
exports.testFuncs = testFuncs;
|
||||
exports.unitTestPrettyPrintResults = unitTestPrettyPrintResults;
|
||||
|
||||
|
|
Loading…
Reference in New Issue