mirror of https://gitee.com/bigwinds/arangodb
split unittest results into several xml files - each testsuite is one file.
This commit is contained in:
parent
76e0148db9
commit
e56aeb6fad
|
@ -1,7 +1,10 @@
|
|||
var internalMembers = ["code", "error", "status", "duration", "failed", "total"];
|
||||
var fs = require("fs");
|
||||
var print = require("internal").print;
|
||||
|
||||
|
||||
function resultsToXml(results) {
|
||||
function resultsToXml(results, baseName) {
|
||||
"use strict";
|
||||
function xmlEscape(s) {
|
||||
return s.replace(/[<>&"]/g, function (c) {
|
||||
return "&"
|
||||
|
@ -10,63 +13,65 @@ function resultsToXml(results) {
|
|||
});
|
||||
}
|
||||
|
||||
var xml = [ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" ];
|
||||
for (var test in results.shell_server_aql) {
|
||||
var xml = [ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" ];
|
||||
|
||||
xml.text = function (s) {
|
||||
Array.prototype.push.call(this, s);
|
||||
return this;
|
||||
};
|
||||
xml.text = function (s) {
|
||||
Array.prototype.push.call(this, s);
|
||||
return this;
|
||||
};
|
||||
|
||||
xml.elem = function (tagName, attrs, close) {
|
||||
this.text("<").text(tagName);
|
||||
xml.elem = function (tagName, attrs, close) {
|
||||
this.text("<").text(tagName);
|
||||
|
||||
for (var a in attrs || {}) {
|
||||
this.text(" ").text(a).text("=\"")
|
||||
.text(xmlEscape(String(attrs[a]))).text("\"");
|
||||
}
|
||||
|
||||
for (var a in attrs || {}) {
|
||||
this.text(" ").text(a).text("=\"")
|
||||
.text(xmlEscape(String(attrs[a]))).text("\"");
|
||||
}
|
||||
close && this.text("/");
|
||||
this.text(">\n");
|
||||
|
||||
close && this.text("/");
|
||||
this.text(">\n");
|
||||
return this;
|
||||
};
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
for (var i in results.shell_server_aql) {
|
||||
xml.elem("testsuite", {
|
||||
errors: 0,
|
||||
failures: results.shell_server_aql[i].failed,
|
||||
name: i,
|
||||
tests: results.shell_server_aql[i].total,
|
||||
time: results.shell_server_aql[i].duration
|
||||
failures: results.shell_server_aql[test].failed,
|
||||
name: test,
|
||||
tests: results.shell_server_aql[test].total,
|
||||
time: results.shell_server_aql[test].duration
|
||||
});
|
||||
|
||||
for (var j in results.shell_server_aql[i]) {
|
||||
if (internalMembers.indexOf(j) === -1) {
|
||||
var result = results.shell_server_aql[i][j].status;
|
||||
for (var oneTest in results.shell_server_aql[test]) {
|
||||
if (internalMembers.indexOf(oneTest) === -1) {
|
||||
var result = results.shell_server_aql[test][oneTest].status;
|
||||
var success = (typeof(result) === 'boolean')? result : false;
|
||||
|
||||
xml.elem("testcase", {
|
||||
name: j,
|
||||
name: oneTest,
|
||||
time: 0.0
|
||||
}, success);
|
||||
|
||||
if (!success) {
|
||||
xml.elem("failure", { message: results.shell_server_aql[i][j].message }, true)
|
||||
.elem("/testcase");
|
||||
xml.elem("failure");
|
||||
xml.text(results.shell_server_aql[test][oneTest].message);
|
||||
xml.elem("/failure");
|
||||
xml.elem("/testcase");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
xml.elem("/testsuite");
|
||||
}
|
||||
var fn = baseName + test.replace(/\//g, '_') + ".xml";
|
||||
//print('Writing: '+ fn);
|
||||
fs.write(fn, xml.join(""));
|
||||
|
||||
return xml.join("");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function main (argv) {
|
||||
var fs = require("fs");
|
||||
var print = require("internal").print;
|
||||
if (argv.length < 2) {
|
||||
print("Usage: unittest TESTNAME [OPTIONS]");
|
||||
return;
|
||||
|
@ -82,12 +87,11 @@ function main (argv) {
|
|||
fs.write("UNITTEST_RESULT.json",JSON.stringify(r));
|
||||
fs.write("UNITTEST_RESULT_SUMMARY.txt",JSON.stringify(r.all_ok));
|
||||
try {
|
||||
x = resultsToXml(r);
|
||||
resultsToXml(r, "UNITTEST_RESULT_");
|
||||
}
|
||||
catch (x) {
|
||||
print(x.message);
|
||||
}
|
||||
fs.write("UNITTEST_RESULT.xml", x);
|
||||
|
||||
print(r);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue