mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-20 06:55:08 -04:00
Fixed linebreaks in test index (thanks VSCode)
This commit is contained in:
parent
24e4e268dc
commit
e6f19c3dfd
1 changed files with 135 additions and 135 deletions
270
test/index.mjs
270
test/index.mjs
|
@ -1,135 +1,135 @@
|
||||||
/* eslint no-console: 0 */
|
/* eslint no-console: 0 */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TestRunner.js
|
* TestRunner.js
|
||||||
*
|
*
|
||||||
* For running the tests in the test register.
|
* For running the tests in the test register.
|
||||||
*
|
*
|
||||||
* @author tlwr [toby@toby.codes]
|
* @author tlwr [toby@toby.codes]
|
||||||
* @author n1474335 [n1474335@gmail.com]
|
* @author n1474335 [n1474335@gmail.com]
|
||||||
* @copyright Crown Copyright 2017
|
* @copyright Crown Copyright 2017
|
||||||
* @license Apache-2.0
|
* @license Apache-2.0
|
||||||
*/
|
*/
|
||||||
import "babel-polyfill";
|
import "babel-polyfill";
|
||||||
|
|
||||||
// Define global environment functions
|
// Define global environment functions
|
||||||
global.ENVIRONMENT_IS_WORKER = function() {
|
global.ENVIRONMENT_IS_WORKER = function() {
|
||||||
return typeof importScripts === "function";
|
return typeof importScripts === "function";
|
||||||
};
|
};
|
||||||
global.ENVIRONMENT_IS_NODE = function() {
|
global.ENVIRONMENT_IS_NODE = function() {
|
||||||
return typeof process === "object" && typeof require === "function";
|
return typeof process === "object" && typeof require === "function";
|
||||||
};
|
};
|
||||||
global.ENVIRONMENT_IS_WEB = function() {
|
global.ENVIRONMENT_IS_WEB = function() {
|
||||||
return typeof window === "object";
|
return typeof window === "object";
|
||||||
};
|
};
|
||||||
|
|
||||||
import TestRegister from "./TestRegister";
|
import TestRegister from "./TestRegister";
|
||||||
// import "./tests/operations/Base58.js";
|
// import "./tests/operations/Base58.js";
|
||||||
import "./tests/operations/Base64";
|
import "./tests/operations/Base64";
|
||||||
// import "./tests/operations/BCD.js";
|
// import "./tests/operations/BCD.js";
|
||||||
// import "./tests/operations/BitwiseOp.js";
|
// import "./tests/operations/BitwiseOp.js";
|
||||||
// import "./tests/operations/BSON.js";
|
// import "./tests/operations/BSON.js";
|
||||||
// import "./tests/operations/ByteRepr.js";
|
// import "./tests/operations/ByteRepr.js";
|
||||||
import "./tests/operations/CartesianProduct";
|
import "./tests/operations/CartesianProduct";
|
||||||
// import "./tests/operations/CharEnc.js";
|
// import "./tests/operations/CharEnc.js";
|
||||||
import "./tests/operations/Ciphers";
|
import "./tests/operations/Ciphers";
|
||||||
//import "./tests/operations/Checksum.js";
|
//import "./tests/operations/Checksum.js";
|
||||||
// import "./tests/operations/Code.js";
|
// import "./tests/operations/Code.js";
|
||||||
// import "./tests/operations/Compress.js";
|
// import "./tests/operations/Compress.js";
|
||||||
// import "./tests/operations/DateTime.js";
|
// import "./tests/operations/DateTime.js";
|
||||||
// import "./tests/operations/FlowControl.js";
|
// import "./tests/operations/FlowControl.js";
|
||||||
// import "./tests/operations/Hash.js";
|
// import "./tests/operations/Hash.js";
|
||||||
// import "./tests/operations/Hexdump.js";
|
// import "./tests/operations/Hexdump.js";
|
||||||
// import "./tests/operations/Image.js";
|
// import "./tests/operations/Image.js";
|
||||||
// import "./tests/operations/MorseCode.js";
|
// import "./tests/operations/MorseCode.js";
|
||||||
// import "./tests/operations/MS.js";
|
// import "./tests/operations/MS.js";
|
||||||
// import "./tests/operations/PHP.js";
|
// import "./tests/operations/PHP.js";
|
||||||
// import "./tests/operations/NetBIOS.js";
|
// import "./tests/operations/NetBIOS.js";
|
||||||
// import "./tests/operations/OTP.js";
|
// import "./tests/operations/OTP.js";
|
||||||
import "./tests/operations/PowerSet";
|
import "./tests/operations/PowerSet";
|
||||||
// import "./tests/operations/Regex.js";
|
// import "./tests/operations/Regex.js";
|
||||||
import "./tests/operations/Rotate";
|
import "./tests/operations/Rotate";
|
||||||
// import "./tests/operations/StrUtils.js";
|
// import "./tests/operations/StrUtils.js";
|
||||||
// import "./tests/operations/SeqUtils.js";
|
// import "./tests/operations/SeqUtils.js";
|
||||||
import "./tests/operations/SetDifference";
|
import "./tests/operations/SetDifference";
|
||||||
import "./tests/operations/SetIntersection";
|
import "./tests/operations/SetIntersection";
|
||||||
import "./tests/operations/SetUnion";
|
import "./tests/operations/SetUnion";
|
||||||
import "./tests/operations/SymmetricDifference";
|
import "./tests/operations/SymmetricDifference";
|
||||||
|
|
||||||
let allTestsPassing = true;
|
let allTestsPassing = true;
|
||||||
const testStatusCounts = {
|
const testStatusCounts = {
|
||||||
total: 0,
|
total: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper function to convert a status to an icon.
|
* Helper function to convert a status to an icon.
|
||||||
*
|
*
|
||||||
* @param {string} status
|
* @param {string} status
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
function statusToIcon(status) {
|
function statusToIcon(status) {
|
||||||
const icons = {
|
const icons = {
|
||||||
erroring: "🔥",
|
erroring: "🔥",
|
||||||
failing: "❌",
|
failing: "❌",
|
||||||
passing: "✔️️",
|
passing: "✔️️",
|
||||||
};
|
};
|
||||||
return icons[status] || "?";
|
return icons[status] || "?";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays a given test result in the console.
|
* Displays a given test result in the console.
|
||||||
*
|
*
|
||||||
* @param {Object} testResult
|
* @param {Object} testResult
|
||||||
*/
|
*/
|
||||||
function handleTestResult(testResult) {
|
function handleTestResult(testResult) {
|
||||||
allTestsPassing = allTestsPassing && testResult.status === "passing";
|
allTestsPassing = allTestsPassing && testResult.status === "passing";
|
||||||
const newCount = (testStatusCounts[testResult.status] || 0) + 1;
|
const newCount = (testStatusCounts[testResult.status] || 0) + 1;
|
||||||
testStatusCounts[testResult.status] = newCount;
|
testStatusCounts[testResult.status] = newCount;
|
||||||
testStatusCounts.total += 1;
|
testStatusCounts.total += 1;
|
||||||
|
|
||||||
console.log([
|
console.log([
|
||||||
statusToIcon(testResult.status),
|
statusToIcon(testResult.status),
|
||||||
testResult.test.name
|
testResult.test.name
|
||||||
].join(" "));
|
].join(" "));
|
||||||
|
|
||||||
if (testResult.output) {
|
if (testResult.output) {
|
||||||
console.log(
|
console.log(
|
||||||
testResult.output
|
testResult.output
|
||||||
.trim()
|
.trim()
|
||||||
.replace(/^/, "\t")
|
.replace(/^/, "\t")
|
||||||
.replace(/\n/g, "\n\t")
|
.replace(/\n/g, "\n\t")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fail if the process takes longer than 10 seconds.
|
* Fail if the process takes longer than 10 seconds.
|
||||||
*/
|
*/
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
console.log("Tests took longer than 10 seconds to run, returning.");
|
console.log("Tests took longer than 10 seconds to run, returning.");
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}, 10 * 1000);
|
}, 10 * 1000);
|
||||||
|
|
||||||
|
|
||||||
TestRegister.runTests()
|
TestRegister.runTests()
|
||||||
.then(function(results) {
|
.then(function(results) {
|
||||||
results.forEach(handleTestResult);
|
results.forEach(handleTestResult);
|
||||||
|
|
||||||
console.log("\n");
|
console.log("\n");
|
||||||
|
|
||||||
for (const testStatus in testStatusCounts) {
|
for (const testStatus in testStatusCounts) {
|
||||||
const count = testStatusCounts[testStatus];
|
const count = testStatusCounts[testStatus];
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
console.log(testStatus.toUpperCase(), count);
|
console.log(testStatus.toUpperCase(), count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!allTestsPassing) {
|
if (!allTestsPassing) {
|
||||||
console.log("\nNot all tests are passing");
|
console.log("\nNot all tests are passing");
|
||||||
}
|
}
|
||||||
|
|
||||||
process.exit(allTestsPassing ? 0 : 1);
|
process.exit(allTestsPassing ? 0 : 1);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue