2019-01-28 19:22:55 +00:00
|
|
|
/*
|
|
|
|
Checker launcher
|
|
|
|
*/
|
|
|
|
|
|
|
|
const Mocha = require("mocha");
|
|
|
|
const assignment_path = "./tests/checks.test.js";
|
|
|
|
|
|
|
|
let score = 0;
|
|
|
|
let score_total = 0;
|
|
|
|
|
|
|
|
new Mocha({
|
|
|
|
timeout: 60 * 1000,
|
|
|
|
reporter: function () {
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.addFile(assignment_path)
|
|
|
|
.run()
|
|
|
|
.on('pass', function (test) {
|
|
|
|
score += test.ctx.score;
|
|
|
|
score_total += test.ctx.score;
|
|
|
|
process.stdout.write(
|
|
|
|
`\nTest: ${test.ctx.name}
|
|
|
|
Score: ${test.ctx.score}/${test.ctx.score}
|
|
|
|
Remarks: ${test.ctx.msg_ok}\n`
|
|
|
|
);
|
|
|
|
})
|
|
|
|
.on('fail', function (test, err) {
|
|
|
|
if ((test.title !== '"after all" hook') && (test.title !== '"before all" hook')) {
|
|
|
|
score_total += test.ctx.score;
|
|
|
|
process.stdout.write(
|
|
|
|
`\nTest: ${test.ctx.name}
|
|
|
|
Score: 0/${test.ctx.score}
|
|
|
|
Remarks: ${test.ctx.msg_err}\n`);
|
|
|
|
} else {
|
|
|
|
console.error("Launcher Error: " + err);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.on('end', function (test) {
|
2019-01-29 10:56:06 +00:00
|
|
|
process.stdout.write(`Final Result: ${score}/${score_total}\n`);
|
|
|
|
});
|