Skip to content

Commit c1f29fd

Browse files
committed
fix test directory without ending slash
1 parent b363873 commit c1f29fd

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

lib/tests/run_tests.js

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,23 @@ module.exports = {
3232
}
3333

3434
async.waterfall([
35-
function getFiles(next) {
36-
if (filePath.substr(-1) !== '/') {
37-
return fs.access(filePath, (err) => {
38-
if (err) {
39-
return next(`File "${filePath}" doesn't exist or you don't have permission to it`.red);
40-
}
41-
next(null, [filePath]);
42-
});
35+
function checkIfDir(next) {
36+
if (filePath.substr(-1) === '/') {
37+
return next(null, null);
38+
}
39+
fs.stat(filePath, (err, stats) => {
40+
if (err) {
41+
return next(`File "${filePath}" doesn't exist or you don't have permission to it`.red);
42+
}
43+
if (stats.isDirectory()) {
44+
return next(null, null);
45+
}
46+
next(null, [filePath]);
47+
});
48+
},
49+
function getFiles(files, next) {
50+
if (files) {
51+
return next(null, files);
4352
}
4453
getFilesFromDir(filePath, (err, files) => {
4554
if (err) {
@@ -56,7 +65,7 @@ module.exports = {
5665
global.assert = assert;
5766
global.config = test.config.bind(test);
5867

59-
let deprecatedWarning = function() {
68+
let deprecatedWarning = function () {
6069
console.error(__('%s are not supported anymore', 'EmbarkSpec & deployAll').red);
6170
console.info(__('You can learn about the new revamped tests here: %s', 'https://embark.status.im/docs/testing.html'.underline));
6271
process.exit();
@@ -69,7 +78,7 @@ module.exports = {
6978
// Override require to enable `require('Embark/contracts/contractName');`
7079
const Module = require('module');
7180
const originalRequire = require('module').prototype.require;
72-
Module.prototype.require = function(requireName) {
81+
Module.prototype.require = function (requireName) {
7382
if (requireName.startsWith('Embark')) {
7483
return test.require(...arguments);
7584
}
@@ -101,7 +110,7 @@ module.exports = {
101110
});
102111
});
103112

104-
mocha.run(function(fails) {
113+
mocha.run(function (fails) {
105114
failures += fails;
106115
// Mocha prints the error already
107116
eachCb();

0 commit comments

Comments
 (0)