mirror of https://gitee.com/bigwinds/arangodb
parent
525a9a0d4c
commit
6527c8ceed
|
@ -71,39 +71,78 @@ function resultsToXml(results, baseName, cluster) {
|
||||||
clprefix = 'CL_';
|
clprefix = 'CL_';
|
||||||
}
|
}
|
||||||
|
|
||||||
let cleanedResults = UnitTest.unwurst(results);
|
const isSignificant = function(a, b) {
|
||||||
print(JSON.stringify(cleanedResults));
|
return (internalMembers.indexOf(b) === -1) && a.hasOwnProperty(b);
|
||||||
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,
|
|
||||||
});
|
|
||||||
|
|
||||||
suite.tests.forEach(test => {
|
for (let resultName in results) {
|
||||||
xml.elem('testcase', {
|
if (isSignificant(results, resultName)) {
|
||||||
name: test.testName,
|
let run = results[resultName];
|
||||||
});
|
|
||||||
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('_');
|
for (let runName in run) {
|
||||||
fs.write(testOutputDirectory + fn, xml.join(""));
|
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(""));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -198,117 +198,6 @@ 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 unitTestPrettyPrintResults (r, testOutputDirectory, options) {
|
||||||
function skipInternalMember (r, a) {
|
function skipInternalMember (r, a) {
|
||||||
return !r.hasOwnProperty(a) || internalMembers.indexOf(a) !== -1;
|
return !r.hasOwnProperty(a) || internalMembers.indexOf(a) !== -1;
|
||||||
|
@ -657,7 +546,6 @@ function unitTest (cases, options) {
|
||||||
exports.unitTest = unitTest;
|
exports.unitTest = unitTest;
|
||||||
|
|
||||||
exports.internalMembers = internalMembers;
|
exports.internalMembers = internalMembers;
|
||||||
exports.unwurst = unwurst;
|
|
||||||
exports.testFuncs = testFuncs;
|
exports.testFuncs = testFuncs;
|
||||||
exports.unitTestPrettyPrintResults = unitTestPrettyPrintResults;
|
exports.unitTestPrettyPrintResults = unitTestPrettyPrintResults;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue