Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 20 additions & 11 deletions lib/tests/run_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,23 @@ module.exports = {
}

async.waterfall([
function getFiles(next) {
if (filePath.substr(-1) !== '/') {
return fs.access(filePath, (err) => {
if (err) {
return next(`File "${filePath}" doesn't exist or you don't have permission to it`.red);
}
next(null, [filePath]);
});
function checkIfDir(next) {
if (filePath.substr(-1) === '/') {
return next(null, null);
}
fs.stat(filePath, (err, stats) => {
if (err) {
return next(`File "${filePath}" doesn't exist or you don't have permission to it`.red);
}
if (stats.isDirectory()) {
return next(null, null);
}
next(null, [filePath]);
});
},
function getFiles(files, next) {
if (files) {
return next(null, files);
}
getFilesFromDir(filePath, (err, files) => {
if (err) {
Expand All @@ -56,7 +65,7 @@ module.exports = {
global.assert = assert;
global.config = test.config.bind(test);

let deprecatedWarning = function() {
let deprecatedWarning = function () {
console.error(__('%s are not supported anymore', 'EmbarkSpec & deployAll').red);
console.info(__('You can learn about the new revamped tests here: %s', 'https://embark.status.im/docs/testing.html'.underline));
process.exit();
Expand All @@ -69,7 +78,7 @@ module.exports = {
// Override require to enable `require('Embark/contracts/contractName');`
const Module = require('module');
const originalRequire = require('module').prototype.require;
Module.prototype.require = function(requireName) {
Module.prototype.require = function (requireName) {
if (requireName.startsWith('Embark')) {
return test.require(...arguments);
}
Expand Down Expand Up @@ -101,7 +110,7 @@ module.exports = {
});
});

mocha.run(function(fails) {
mocha.run(function (fails) {
failures += fails;
// Mocha prints the error already
eachCb();
Expand Down