mirror of https://gitee.com/bigwinds/arangodb
allow more than one test target
This commit is contained in:
parent
bca7bee317
commit
251fcb8113
|
@ -86,7 +86,7 @@ function resultsToXml(results, baseName, cluster) {
|
||||||
}
|
}
|
||||||
|
|
||||||
let xml = buildXml();
|
let xml = buildXml();
|
||||||
let failuresFound = "";
|
let failuresFound = 0;
|
||||||
|
|
||||||
if (current.hasOwnProperty('failed')) {
|
if (current.hasOwnProperty('failed')) {
|
||||||
failuresFound = current.failed;
|
failuresFound = current.failed;
|
||||||
|
@ -103,8 +103,7 @@ function resultsToXml(results, baseName, cluster) {
|
||||||
for (let oneTestName in current) {
|
for (let oneTestName in current) {
|
||||||
if (isSignificant(current, oneTestName)) {
|
if (isSignificant(current, oneTestName)) {
|
||||||
const oneTest = current[oneTestName];
|
const oneTest = current[oneTestName];
|
||||||
const result = oneTest.status || false;
|
const success = (oneTest.status === true);
|
||||||
const success = (typeof(result) === 'boolean') ? result : false;
|
|
||||||
|
|
||||||
xml.elem("testcase", {
|
xml.elem("testcase", {
|
||||||
name: clprefix + oneTestName,
|
name: clprefix + oneTestName,
|
||||||
|
@ -151,15 +150,32 @@ function resultsToXml(results, baseName, cluster) {
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
function main(argv) {
|
function main(argv) {
|
||||||
const test = argv[0];
|
start_pretty_print();
|
||||||
|
|
||||||
|
// parse arguments
|
||||||
|
let cases = [];
|
||||||
let options = {};
|
let options = {};
|
||||||
|
|
||||||
if (argv.length >= 2) {
|
while (argv.length >= 1) {
|
||||||
|
if (argv[0].slice(0, 1) === '{') {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (argv[0].slice(0, 1) === '-') {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
cases.push(argv[0]);
|
||||||
|
argv = argv.slice(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// convert arguments
|
||||||
|
if (argv.length >= 1) {
|
||||||
try {
|
try {
|
||||||
if (argv[1].slice(0, 1) === '{') {
|
if (argv[0].slice(0, 1) === '{') {
|
||||||
options = JSON.parse(argv[1]);
|
options = JSON.parse(argv[0]);
|
||||||
} else {
|
} else {
|
||||||
options = internal.parseArgv(argv, 1);
|
options = internal.parseArgv(argv, 0);
|
||||||
}
|
}
|
||||||
} catch (x) {
|
} catch (x) {
|
||||||
print("failed to parse the json options: " + x.message);
|
print("failed to parse the json options: " + x.message);
|
||||||
|
@ -167,17 +183,17 @@ function main(argv) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// force json reply
|
||||||
options.jsonReply = true;
|
options.jsonReply = true;
|
||||||
|
|
||||||
|
// create output directory
|
||||||
fs.makeDirectoryRecursive("out");
|
fs.makeDirectoryRecursive("out");
|
||||||
|
|
||||||
start_pretty_print();
|
|
||||||
|
|
||||||
// run the test and store the result
|
// run the test and store the result
|
||||||
let r = {};
|
let r = {};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
r = UnitTest.UnitTest(test, options) || {};
|
r = UnitTest.unitTest(cases, options) || {};
|
||||||
} catch (x) {
|
} catch (x) {
|
||||||
print("caught exception during test execution!");
|
print("caught exception during test execution!");
|
||||||
|
|
||||||
|
@ -204,7 +220,15 @@ function main(argv) {
|
||||||
fs.write("out/UNITTEST_RESULT_EXECUTIVE_SUMMARY.json", String(r.status));
|
fs.write("out/UNITTEST_RESULT_EXECUTIVE_SUMMARY.json", String(r.status));
|
||||||
|
|
||||||
if (options.writeXmlReport) {
|
if (options.writeXmlReport) {
|
||||||
fs.write("out/UNITTEST_RESULT.json", inspect(r));
|
let j;
|
||||||
|
|
||||||
|
try {
|
||||||
|
j = JSON.stringify(r);
|
||||||
|
} catch (err) {
|
||||||
|
j = inspect(r);
|
||||||
|
}
|
||||||
|
|
||||||
|
fs.write("out/UNITTEST_RESULT.json", j);
|
||||||
fs.write("out/UNITTEST_RESULT_CRASHED.json", String(r.crashed));
|
fs.write("out/UNITTEST_RESULT_CRASHED.json", String(r.crashed));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -214,17 +238,13 @@ function main(argv) {
|
||||||
print("exception while serializing status xml!");
|
print("exception while serializing status xml!");
|
||||||
print(x.message);
|
print(x.message);
|
||||||
print(x.stack);
|
print(x.stack);
|
||||||
print(JSON.stringify(r));
|
print(inspect(r));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UnitTest.unitTestPrettyPrintResults(r);
|
UnitTest.unitTestPrettyPrintResults(r);
|
||||||
|
|
||||||
if (r.hasOwnProperty("crashed") && r.crashed) {
|
return r.crashed ? -1 : 0;
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
main(ARGUMENTS);
|
main(ARGUMENTS);
|
||||||
|
|
|
@ -172,15 +172,28 @@ let cleanupDirectories = [];
|
||||||
let serverCrashed = false;
|
let serverCrashed = false;
|
||||||
|
|
||||||
const makeResults = function(testname) {
|
const makeResults = function(testname) {
|
||||||
|
const startTime = time();
|
||||||
|
|
||||||
return function(status, message) {
|
return function(status, message) {
|
||||||
let results = {};
|
let duration = time() - startTime;
|
||||||
results[testname] = {
|
|
||||||
status: status
|
let results = {
|
||||||
|
status: status,
|
||||||
|
duration: duration
|
||||||
};
|
};
|
||||||
|
|
||||||
|
results[testname] = {
|
||||||
|
status: status,
|
||||||
|
duration: duration
|
||||||
|
};
|
||||||
|
|
||||||
if (message) {
|
if (message) {
|
||||||
results[testname].message = message;
|
results[testname].message = message;
|
||||||
}
|
}
|
||||||
return results;
|
|
||||||
|
return {
|
||||||
|
'testing.js': results
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3138,7 +3151,7 @@ testFuncs.replication_static = function(options) {
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
testFuncs.replication_sync = function(options) {
|
testFuncs.replication_sync = function(options) {
|
||||||
const mr = makeResults('replication_sync');
|
const mr = makeResults('replication');
|
||||||
let master = startInstance("tcp", options, {}, "master_sync");
|
let master = startInstance("tcp", options, {}, "master_sync");
|
||||||
|
|
||||||
if (master === false) {
|
if (master === false) {
|
||||||
|
@ -3730,7 +3743,7 @@ function unitTestPrettyPrintResults(r) {
|
||||||
|
|
||||||
function printUsage() {
|
function printUsage() {
|
||||||
print();
|
print();
|
||||||
print("Usage: UnitTest( which, options )");
|
print("Usage: UnitTest([which, ...], options)");
|
||||||
print();
|
print();
|
||||||
print(' where "which" is one of:\n');
|
print(' where "which" is one of:\n');
|
||||||
|
|
||||||
|
@ -3772,14 +3785,14 @@ function printUsage() {
|
||||||
/// Empty will give you a complete list.
|
/// Empty will give you a complete list.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
function unitTest(which, options) {
|
function unitTest(cases, options) {
|
||||||
if (typeof options !== "object") {
|
if (typeof options !== "object") {
|
||||||
options = {};
|
options = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
_.defaults(options, optionsDefaults);
|
_.defaults(options, optionsDefaults);
|
||||||
|
|
||||||
if (which === undefined) {
|
if (cases === undefined) {
|
||||||
printUsage();
|
printUsage();
|
||||||
|
|
||||||
print('FATAL: "which" is undefined\n');
|
print('FATAL: "which" is undefined\n');
|
||||||
|
@ -3792,121 +3805,86 @@ function unitTest(which, options) {
|
||||||
const jsonReply = options.jsonReply;
|
const jsonReply = options.jsonReply;
|
||||||
delete options.jsonReply;
|
delete options.jsonReply;
|
||||||
|
|
||||||
let allok = true;
|
// tests to run
|
||||||
let ok = false;
|
let caselist = [];
|
||||||
|
|
||||||
|
for (let n = 0; n < cases.length; ++n) {
|
||||||
|
let which = cases[n];
|
||||||
|
|
||||||
|
if (which === "all") {
|
||||||
|
caselist = caselist.conact(allTests);
|
||||||
|
} else if (testFuncs.hasOwnProperty(which)) {
|
||||||
|
caselist.push(which);
|
||||||
|
} else {
|
||||||
|
let line = "Unknown test '" + which + "'\nKnown tests are: ";
|
||||||
|
let sep = "";
|
||||||
|
|
||||||
|
Object.keys(testFuncs).map(function(key) {
|
||||||
|
line += sep + key;
|
||||||
|
sep = ", ";
|
||||||
|
});
|
||||||
|
|
||||||
|
print(line);
|
||||||
|
|
||||||
|
return {
|
||||||
|
status: false
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let globalStatus = true;
|
||||||
let results = {};
|
let results = {};
|
||||||
let thisReply;
|
|
||||||
|
|
||||||
// running all tests
|
// running all tests
|
||||||
if (which === "all") {
|
for (let n = 0; n < caselist.length; ++n) {
|
||||||
for (let n = 0; n < allTests.length; n++) {
|
const currentTest = caselist[n];
|
||||||
const currentTest = allTests[n];
|
|
||||||
|
|
||||||
print("Executing test", currentTest, "with options", options);
|
print("Executing test", currentTest, "with options", options);
|
||||||
|
|
||||||
results[currentTest] = thisReply = testFuncs[currentTest](options);
|
let result = testFuncs[currentTest](options);
|
||||||
ok = true;
|
results[currentTest] = result;
|
||||||
|
|
||||||
for (let i in thisReply) {
|
let status = true;
|
||||||
if (thisReply.hasOwnProperty(i)) {
|
|
||||||
if (thisReply[i].status !== true) {
|
|
||||||
ok = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
thisReply.ok = ok;
|
for (let i in result) {
|
||||||
|
if (result.hasOwnProperty(i)) {
|
||||||
if (!ok) {
|
if (result[i].status !== true) {
|
||||||
allok = false;
|
status = false;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
results.status = allok;
|
|
||||||
results.crashed = serverCrashed;
|
|
||||||
|
|
||||||
if (allok) {
|
|
||||||
cleanupDBDirectories(options);
|
|
||||||
} else {
|
|
||||||
print("since some tests weren't successfully, not cleaning up: \n" +
|
|
||||||
yaml.safeDump(cleanupDirectories));
|
|
||||||
}
|
|
||||||
|
|
||||||
yaml.safeDump(results);
|
|
||||||
|
|
||||||
if (jsonReply === true) {
|
|
||||||
return results;
|
|
||||||
} else {
|
|
||||||
return allok;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// unknown test
|
|
||||||
else if (!testFuncs.hasOwnProperty(which)) {
|
|
||||||
let line = "Unknown test '" + which + "'\nKnown tests are: ";
|
|
||||||
let sep = "";
|
|
||||||
|
|
||||||
Object.keys(testFuncs).map(function(key) {
|
|
||||||
line += sep + key;
|
|
||||||
sep = ", ";
|
|
||||||
});
|
|
||||||
|
|
||||||
print(line);
|
|
||||||
|
|
||||||
return {
|
|
||||||
status: false
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// test found in testFuncs
|
|
||||||
else {
|
|
||||||
results[which] = thisReply = testFuncs[which](options);
|
|
||||||
|
|
||||||
if (options.extremeVerbosity) {
|
|
||||||
print("Test result:", yaml.safeDump(results));
|
|
||||||
}
|
|
||||||
|
|
||||||
ok = true;
|
|
||||||
|
|
||||||
for (let i in thisReply) {
|
|
||||||
if (thisReply.hasOwnProperty(i)) {
|
|
||||||
if (thisReply[i].status !== true) {
|
|
||||||
ok = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
thisReply.status = ok;
|
result.status = status;
|
||||||
results.status = ok;
|
|
||||||
results.crashed = serverCrashed;
|
|
||||||
|
|
||||||
if (ok) {
|
if (!status) {
|
||||||
cleanupDBDirectories(options);
|
globalStatus = false;
|
||||||
} else {
|
|
||||||
print("since some tests weren't successfully, not cleaning up: \n" +
|
|
||||||
yaml.safeDump(cleanupDirectories));
|
|
||||||
}
|
|
||||||
|
|
||||||
yaml.safeDump(results);
|
|
||||||
|
|
||||||
if (jsonReply === true) {
|
|
||||||
return results;
|
|
||||||
} else {
|
|
||||||
return ok;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
results.status = globalStatus;
|
||||||
status: false
|
results.crashed = serverCrashed;
|
||||||
};
|
|
||||||
|
if (globalStatus) {
|
||||||
|
cleanupDBDirectories(options);
|
||||||
|
} else {
|
||||||
|
print("since some tests weren't successfully, not cleaning up: \n" +
|
||||||
|
yaml.safeDump(cleanupDirectories));
|
||||||
|
}
|
||||||
|
|
||||||
|
yaml.safeDump(results);
|
||||||
|
|
||||||
|
if (jsonReply === true) {
|
||||||
|
return results;
|
||||||
|
} else {
|
||||||
|
return globalStatus;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief exports
|
/// @brief exports
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
exports.UnitTest = unitTest;
|
exports.unitTest = unitTest;
|
||||||
|
|
||||||
exports.internalMembers = internalMembers;
|
exports.internalMembers = internalMembers;
|
||||||
exports.testFuncs = testFuncs;
|
exports.testFuncs = testFuncs;
|
||||||
|
|
Loading…
Reference in New Issue