mirror of
https://github.com/gchq/CyberChef.git
synced 2025-05-08 15:25:01 -04:00
parent
de3ef202d5
commit
c5a1b69c30
693 changed files with 26685 additions and 51240 deletions
|
@ -8,6 +8,7 @@
|
|||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Helper function to convert a status to an icon.
|
||||
*
|
||||
|
@ -15,13 +16,11 @@
|
|||
* @returns {string}
|
||||
*/
|
||||
function statusToIcon(status) {
|
||||
return (
|
||||
{
|
||||
erroring: "🔥",
|
||||
failing: "❌",
|
||||
passing: "✔️️",
|
||||
}[status] || "?"
|
||||
);
|
||||
return {
|
||||
erroring: "🔥",
|
||||
failing: "❌",
|
||||
passing: "✔️️",
|
||||
}[status] || "?";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -31,18 +30,12 @@ function statusToIcon(status) {
|
|||
* @param {Object} testResult
|
||||
*/
|
||||
function handleTestResult(testStatus, testResult) {
|
||||
testStatus.allTestsPassing =
|
||||
testStatus.allTestsPassing && testResult.status === "passing";
|
||||
testStatus.counts[testResult.status] =
|
||||
(testStatus.counts[testResult.status] || 0) + 1;
|
||||
testStatus.allTestsPassing = testStatus.allTestsPassing && testResult.status === "passing";
|
||||
testStatus.counts[testResult.status] = (testStatus.counts[testResult.status] || 0) + 1;
|
||||
testStatus.counts.total += 1;
|
||||
|
||||
if (testResult.duration > 2000) {
|
||||
console.log(
|
||||
`'${testResult.test.name}' took ${(
|
||||
testResult.duration / 1000
|
||||
).toFixed(1)}s to complete`,
|
||||
);
|
||||
console.log(`'${testResult.test.name}' took ${(testResult.duration / 1000).toFixed(1)}s to complete`);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -53,7 +46,7 @@ function handleTestResult(testStatus, testResult) {
|
|||
* @param {Object[]} results - results from TestRegister
|
||||
*/
|
||||
export function logTestReport(testStatus, results) {
|
||||
results.forEach((r) => handleTestResult(testStatus, r));
|
||||
results.forEach(r => handleTestResult(testStatus, r));
|
||||
|
||||
console.log();
|
||||
for (const testStatusCount in testStatus.counts) {
|
||||
|
@ -65,24 +58,21 @@ export function logTestReport(testStatus, results) {
|
|||
console.log();
|
||||
|
||||
// Print error messages for tests that didn't pass
|
||||
results
|
||||
.filter((res) => res.status !== "passing")
|
||||
.forEach((testResult) => {
|
||||
console.log(
|
||||
[statusToIcon(testResult.status), testResult.test.name].join(
|
||||
" ",
|
||||
),
|
||||
);
|
||||
results.filter(res => res.status !== "passing").forEach(testResult => {
|
||||
console.log([
|
||||
statusToIcon(testResult.status),
|
||||
testResult.test.name
|
||||
].join(" "));
|
||||
|
||||
if (testResult.output) {
|
||||
console.log(
|
||||
testResult.output
|
||||
.trim()
|
||||
.replace(/^/, "\t")
|
||||
.replace(/\n/g, "\n\t"),
|
||||
);
|
||||
}
|
||||
});
|
||||
if (testResult.output) {
|
||||
console.log(
|
||||
testResult.output
|
||||
.trim()
|
||||
.replace(/^/, "\t")
|
||||
.replace(/\n/g, "\n\t")
|
||||
);
|
||||
}
|
||||
});
|
||||
console.log();
|
||||
|
||||
process.exit(testStatus.allTestsPassing ? 0 : 1);
|
||||
|
@ -93,10 +83,8 @@ export function logTestReport(testStatus, results) {
|
|||
*/
|
||||
export function setLongTestFailure() {
|
||||
const timeLimit = 120;
|
||||
setTimeout(function () {
|
||||
console.log(
|
||||
`Tests took longer than ${timeLimit} seconds to run, returning.`,
|
||||
);
|
||||
setTimeout(function() {
|
||||
console.log(`Tests took longer than ${timeLimit} seconds to run, returning.`);
|
||||
process.exit(1);
|
||||
}, timeLimit * 1000);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue