Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for recursive search for tests #265

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
33 changes: 31 additions & 2 deletions bin/nodeunit
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,42 @@ var args = (process.ARGV || process.argv).slice(2);

var files = [];

/**
* Method responsible for recursive search for test files passed
* in arguments
*/
var parsePath = function (dir, files) {

var stat = fs.statSync(dir);
if (!stat || !stat.isDirectory()) {
files.push(dir);
return files;
}

fs.readdirSync(dir).forEach(function (file) {

file = dir + '/' + file;

var stat = fs.statSync(file);

if (stat && stat.isDirectory()) {
parsePath(file, files);
} else {
files.push(file);
}

});

return files;
};

var testrunner,
config_file,
config_param_found = false,
output_param_found = false,
reporter_file = 'default',
reporter_param_found = false,
testspec_param_found = false;
testspec_param_found = false,
testFullSpec_param_found = false;

var usage = "Usage: nodeunit [options] testmodule1.js testfolder [...] \n" +
Expand Down Expand Up @@ -97,7 +126,7 @@ args.forEach(function (arg) {
console.log(usage);
process.exit(0);
} else {
files.push(arg);
files = parsePath(arg, files);
}
});

Expand Down