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

Display a warning for failed patterns #603

Merged
merged 1 commit into from Jun 14, 2016
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Display a warning for failed patterns

  • Loading branch information
geek committed Jun 14, 2016
commit 1a2cd97bc9bd19dedb43c3a4ca3d5b3f5d89d66b
@@ -102,33 +102,36 @@ internals.traverse = function (paths, options) {
testFiles = testFiles.concat(traverse(path));
});

if (options.pattern && !testFiles.length) {
options.output.write('The pattern provided (-P or --pattern) didn\'t match any files.');
process.exit(0);
}

testFiles = testFiles.map((path) => {

return Path.resolve(path);
});

const scripts = [];
if (testFiles.length) {
testFiles.forEach((file) => {
testFiles.forEach((file) => {

global._labScriptRun = false;
file = Path.resolve(file);
const pkg = require(file);
if (pkg.lab &&
pkg.lab._root) {
global._labScriptRun = false;
file = Path.resolve(file);
const pkg = require(file);
if (pkg.lab &&
pkg.lab._root) {

scripts.push(pkg.lab);
scripts.push(pkg.lab);

if (pkg.lab._cli) {
Utils.applyOptions(options, pkg.lab._cli);
}
if (pkg.lab._cli) {
Utils.applyOptions(options, pkg.lab._cli);
}
else if (global._labScriptRun) {
options.output.write('The file: ' + file + ' includes a lab script that is not exported via exports.lab');
return process.exit(1);
}
});
}
}
else if (global._labScriptRun) {
options.output.write('The file: ' + file + ' includes a lab script that is not exported via exports.lab');
return process.exit(1);
}
});

return scripts;
};
@@ -810,6 +810,21 @@ describe('CLI', () => {
});
});

it('reports a warning when no files matching the pattern are found', (done) => {

RunCli(['test/cli_pattern', '-m', '2000', '-a', 'code', '-P', 'nofiles'], (error, result) => {

if (error) {
done(error);
}

expect(result.errorOutput).to.equal('');
expect(result.code).to.equal(0);
expect(result.output).to.contain('The pattern provided (-P or --pattern) didn\'t match any files.');
done();
});
});

it('only loads files matching pattern when pattern at beginning of name (-P)', (done) => {

RunCli(['test/cli_pattern', '-m', '2000', '-a', 'code', '-P', 'file'], (error, result) => {
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.