mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-20 14:56:19 -04:00
Fixed tests and brought test module naming in line with conventions.
This commit is contained in:
parent
9bd11dc7ad
commit
c75ebcf001
4 changed files with 6 additions and 15 deletions
|
@ -1,85 +0,0 @@
|
|||
/**
|
||||
* TestRunner.js
|
||||
*
|
||||
* For running the tests in the test register.
|
||||
*
|
||||
* @author tlwr [toby@toby.codes]
|
||||
* @author n1474335 [n1474335@gmail.com]
|
||||
* @copyright Crown Copyright 2017
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
import TestRegister from "./TestRegister.js";
|
||||
import "./tests/operations/Base58.js";
|
||||
import "./tests/operations/Compress.js";
|
||||
import "./tests/operations/FlowControl.js";
|
||||
import "./tests/operations/MorseCode.js";
|
||||
import "./tests/operations/StrUtils.js";
|
||||
|
||||
var allTestsPassing = true,
|
||||
testStatusCounts = {
|
||||
total: 0,
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Helper function to convert a status to an icon.
|
||||
*
|
||||
* @param {string} status
|
||||
* @returns {string}
|
||||
*/
|
||||
function statusToIcon(status) {
|
||||
var icons = {
|
||||
erroring: "🔥",
|
||||
failing: "❌",
|
||||
passing: "✔️️",
|
||||
};
|
||||
return icons[status] || "?";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Displays a given test result in the console.
|
||||
*
|
||||
* @param {Object} testResult
|
||||
*/
|
||||
function handleTestResult(testResult) {
|
||||
allTestsPassing = allTestsPassing && testResult.status === "passing";
|
||||
var newCount = (testStatusCounts[testResult.status] || 0) + 1;
|
||||
testStatusCounts[testResult.status] = newCount;
|
||||
testStatusCounts.total += 1;
|
||||
|
||||
console.log([
|
||||
statusToIcon(testResult.status),
|
||||
testResult.test.name
|
||||
].join(" "));
|
||||
|
||||
if (testResult.output) {
|
||||
console.log(
|
||||
testResult.output
|
||||
.trim()
|
||||
.replace(/^/, "\t")
|
||||
.replace(/\n/g, "\n\t")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TestRegister.runTests()
|
||||
.then(function(results) {
|
||||
results.forEach(handleTestResult);
|
||||
|
||||
console.log("\n");
|
||||
|
||||
for (var testStatus in testStatusCounts) {
|
||||
var count = testStatusCounts[testStatus];
|
||||
if (count > 0) {
|
||||
console.log(testStatus.toUpperCase(), count);
|
||||
}
|
||||
}
|
||||
|
||||
if (!allTestsPassing) {
|
||||
console.log("\nNot all tests are passing");
|
||||
}
|
||||
|
||||
process.exit(allTestsPassing ? 0 : 1);
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue