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 failuresFound = "";
|
||||
let failuresFound = 0;
|
||||
|
||||
if (current.hasOwnProperty('failed')) {
|
||||
failuresFound = current.failed;
|
||||
|
@ -103,8 +103,7 @@ function resultsToXml(results, baseName, cluster) {
|
|||
for (let oneTestName in current) {
|
||||
if (isSignificant(current, oneTestName)) {
|
||||
const oneTest = current[oneTestName];
|
||||
const result = oneTest.status || false;
|
||||
const success = (typeof(result) === 'boolean') ? result : false;
|
||||
const success = (oneTest.status === true);
|
||||
|
||||
xml.elem("testcase", {
|
||||
name: clprefix + oneTestName,
|
||||
|
@ -151,15 +150,32 @@ function resultsToXml(results, baseName, cluster) {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
function main(argv) {
|
||||
const test = argv[0];
|
||||
start_pretty_print();
|
||||
|
||||
// parse arguments
|
||||
let cases = [];
|
||||
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 {
|
||||
if (argv[1].slice(0, 1) === '{') {
|
||||
options = JSON.parse(argv[1]);
|
||||
if (argv[0].slice(0, 1) === '{') {
|
||||
options = JSON.parse(argv[0]);
|
||||
} else {
|
||||
options = internal.parseArgv(argv, 1);
|
||||
options = internal.parseArgv(argv, 0);
|
||||
}
|
||||
} catch (x) {
|
||||
print("failed to parse the json options: " + x.message);
|
||||
|
@ -167,17 +183,17 @@ function main(argv) {
|
|||
}
|
||||
}
|
||||
|
||||
// force json reply
|
||||
options.jsonReply = true;
|
||||
|
||||
// create output directory
|
||||
fs.makeDirectoryRecursive("out");
|
||||
|
||||
start_pretty_print();
|
||||
|
||||
// run the test and store the result
|
||||
let r = {};
|
||||
|
||||
try {
|
||||
r = UnitTest.UnitTest(test, options) || {};
|
||||
r = UnitTest.unitTest(cases, options) || {};
|
||||
} catch (x) {
|
||||
print("caught exception during test execution!");
|
||||
|
||||
|
@ -204,7 +220,15 @@ function main(argv) {
|
|||
fs.write("out/UNITTEST_RESULT_EXECUTIVE_SUMMARY.json", String(r.status));
|
||||
|
||||
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));
|
||||
|
||||
try {
|
||||
|
@ -214,17 +238,13 @@ function main(argv) {
|
|||
print("exception while serializing status xml!");
|
||||
print(x.message);
|
||||
print(x.stack);
|
||||
print(JSON.stringify(r));
|
||||
print(inspect(r));
|
||||
}
|
||||
}
|
||||
|
||||
UnitTest.unitTestPrettyPrintResults(r);
|
||||
|
||||
if (r.hasOwnProperty("crashed") && r.crashed) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return r.crashed ? -1 : 0;
|
||||
}
|
||||
|
||||
main(ARGUMENTS);
|
||||
|
|
|
@ -172,15 +172,28 @@ let cleanupDirectories = [];
|
|||
let serverCrashed = false;
|
||||
|
||||
const makeResults = function(testname) {
|
||||
const startTime = time();
|
||||
|
||||
return function(status, message) {
|
||||
let results = {};
|
||||
results[testname] = {
|
||||
status: status
|
||||
let duration = time() - startTime;
|
||||
|
||||
let results = {
|
||||
status: status,
|
||||
duration: duration
|
||||
};
|
||||
|
||||
results[testname] = {
|
||||
status: status,
|
||||
duration: duration
|
||||
};
|
||||
|
||||
if (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) {
|
||||
const mr = makeResults('replication_sync');
|
||||
const mr = makeResults('replication');
|
||||
let master = startInstance("tcp", options, {}, "master_sync");
|
||||
|
||||
if (master === false) {
|
||||
|
@ -3730,7 +3743,7 @@ function unitTestPrettyPrintResults(r) {
|
|||
|
||||
function printUsage() {
|
||||
print();
|
||||
print("Usage: UnitTest( which, options )");
|
||||
print("Usage: UnitTest([which, ...], options)");
|
||||
print();
|
||||
print(' where "which" is one of:\n');
|
||||
|
||||
|
@ -3772,14 +3785,14 @@ function printUsage() {
|
|||
/// Empty will give you a complete list.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
function unitTest(which, options) {
|
||||
function unitTest(cases, options) {
|
||||
if (typeof options !== "object") {
|
||||
options = {};
|
||||
}
|
||||
|
||||
_.defaults(options, optionsDefaults);
|
||||
|
||||
if (which === undefined) {
|
||||
if (cases === undefined) {
|
||||
printUsage();
|
||||
|
||||
print('FATAL: "which" is undefined\n');
|
||||
|
@ -3792,121 +3805,86 @@ function unitTest(which, options) {
|
|||
const jsonReply = options.jsonReply;
|
||||
delete options.jsonReply;
|
||||
|
||||
let allok = true;
|
||||
let ok = false;
|
||||
// tests to run
|
||||
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 thisReply;
|
||||
|
||||
// running all tests
|
||||
if (which === "all") {
|
||||
for (let n = 0; n < allTests.length; n++) {
|
||||
const currentTest = allTests[n];
|
||||
for (let n = 0; n < caselist.length; ++n) {
|
||||
const currentTest = caselist[n];
|
||||
|
||||
print("Executing test", currentTest, "with options", options);
|
||||
print("Executing test", currentTest, "with options", options);
|
||||
|
||||
results[currentTest] = thisReply = testFuncs[currentTest](options);
|
||||
ok = true;
|
||||
let result = testFuncs[currentTest](options);
|
||||
results[currentTest] = result;
|
||||
|
||||
for (let i in thisReply) {
|
||||
if (thisReply.hasOwnProperty(i)) {
|
||||
if (thisReply[i].status !== true) {
|
||||
ok = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
let status = true;
|
||||
|
||||
thisReply.ok = ok;
|
||||
|
||||
if (!ok) {
|
||||
allok = 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;
|
||||
for (let i in result) {
|
||||
if (result.hasOwnProperty(i)) {
|
||||
if (result[i].status !== true) {
|
||||
status = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
thisReply.status = ok;
|
||||
results.status = ok;
|
||||
results.crashed = serverCrashed;
|
||||
result.status = status;
|
||||
|
||||
if (ok) {
|
||||
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 ok;
|
||||
if (!status) {
|
||||
globalStatus = false;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
status: false
|
||||
};
|
||||
results.status = globalStatus;
|
||||
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
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
exports.UnitTest = unitTest;
|
||||
exports.unitTest = unitTest;
|
||||
|
||||
exports.internalMembers = internalMembers;
|
||||
exports.testFuncs = testFuncs;
|
||||
|
|
Loading…
Reference in New Issue