more progress

This commit is contained in:
Andre Medeiros 2019-07-22 13:36:19 -04:00
parent 4783524a8c
commit 4062873502
2 changed files with 16 additions and 41 deletions

View File

@ -56,7 +56,6 @@ class TestRunner {
const testPath = options.file || "test"; const testPath = options.file || "test";
async.waterfall([ async.waterfall([
(next) => { // list files in path (next) => { // list files in path
console.log("Getting files from dir", testPath);
self.getFilesFromDir(testPath, next); self.getFilesFromDir(testPath, next);
}, },
(files, next) => { // group files by types (files, next) => { // group files by types
@ -72,9 +71,9 @@ class TestRunner {
let fns = []; let fns = [];
if (!options.solc && groups.jsFiles.length > 0) { if (!options.solc && groups.jsFiles.length > 0) {
fns.push((cb) => self.runJSTests(groups.jsFiles, options, cb)) fns.push((cb) => self.runJSTests(groups.jsFiles, options, cb));
} else if (options.solc && groups.solidityFiles.length > 0) { } else if (options.solc && groups.solidityFiles.length > 0) {
fns.push((cb) => self.runJSTests(groups.solidityFiles, options, cb)) fns.push((cb) => self.runJSTests(groups.solidityFiles, options, cb));
} }
if (fns.length === 0) { if (fns.length === 0) {
@ -117,27 +116,20 @@ class TestRunner {
}); });
}, },
(results, next) => { // show report (results, next) => { // show report
const totalFailures = results.reduce((acc, result) => acc + result.failures, 0); const totalFailures = results.reduce((acc, result) => acc + result, 0);
next(totalFailures, totalFailures ? (totalFailures == 0)
` > Total number of failures: ${totalFailures}`.red.bold : ? next(null, ' > All tests passed'.green.bold)
' > All tests passed'.green.bold); : next(totalFailures, ` > Total number of failures: ${totalFailures}`.red.bold);
}, (err, msg) => {
console.log("Got to the last next");
console.log("ERROR:", err);
if (err) {
self.logger.error(msg);
} else {
self.logger.info(msg);
} }
], (err, msg) => {
process.stdout.write(msg + "\n");
self.fs.remove('.embark/contracts'); self.fs.remove('.embark/contracts');
self.fs.remove('.embark/remix_tests.sol'); self.fs.remove('.embark/remix_tests.sol');
return cb(err); return cb(err);
} });
]);
// ------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------
/* /*
@ -251,20 +243,15 @@ class TestRunner {
} }
runJSTests(files, options, cb) { runJSTests(files, options, cb) {
const self = this;
console.log("runJSTests");
async.waterfall([ async.waterfall([
(next) => { // setup global namespace (next) => { // setup global namespace
global.assert = assert; global.assert = assert;
next(); next();
}, },
(next) => { // override require (next) => { // override require
console.log("overriding require");
next(); next();
}, },
(next) => { // initialize Mocha (next) => { // initialize Mocha
console.log("setting up mocha");
const mocha = new Mocha(); const mocha = new Mocha();
mocha.delay(); // stops test execution from automatically starting mocha.delay(); // stops test execution from automatically starting
@ -273,24 +260,14 @@ class TestRunner {
next(null, mocha); next(null, mocha);
}, },
(mocha, next) => { // register test files (mocha, next) => { // register test files
console.log("registering files in mocha"); files.forEach(file => mocha.addFile(file));
files.forEach((file) => {
console.log("adding file to mocha", file);
mocha.addFile(file);
});
next(null, mocha); next(null, mocha);
}, },
(mocha, next) => { (mocha, next) => {
console.log("running mocha");
mocha.options.delay = false; mocha.options.delay = false;
mocha.run((failures) => { mocha.run(failures => next(null, failures));
console.log("finished run", failures);
next(null, failures);
});
} }
], (err, failures) => { ], (err, failures) => {
console.log("FINISHED RUNNING TESTS");
cb(err, failures); cb(err, failures);
}); });
} }

View File

@ -675,11 +675,9 @@ class EmbarkController {
next(); next();
}, },
function runTests(next) { function runTests(next) {
console.log("RUNNING TESTS");
engine.events.request('tests:run', options, next); engine.events.request('tests:run', options, next);
} }
], function (err) { ], function (err) {
console.dir(err);
if (err) { if (err) {
engine.logger.error(err.message || err); engine.logger.error(err.message || err);
} }