-
Notifications
You must be signed in to change notification settings - Fork 27
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
Tighten up CLI parsing #171
Comments
You can always point to the directory when running peridot:
Or the configuration file can configure the default directory like this Then you would just have to specify the path to the config file. Does this help? |
Yes, thanks! That is exactly what I was looking for :)
|
Ah yeah, one little side question: $config->setGrep('*.feature.php'); Can I define multiple greps? I want to test bigger parts using the example DSL, and general stuff using regular statements. So I kinda need to have both, |
Weird. I actually run into troubble. <?php
$autoloadPath = "php_modules/autoload.php";
$rootPath = __DIR__;
while(!file_exists("$rootPath/$autoloadPath")) {
$rootPath = realpath("$rootPath/..");
}
require_once "$rootPath/$autoloadPath";
use Peridot\Console\Environment;
use expect\peridot\ExpectPlugin;
return function($emitter) {
$eventEmitter->on('peridot.start', function (Environment $environment) {
$p = __DIR__."/tests";
$environment
->getDefinition()
->getArgument('path')
->setDefault($p);
});
# Plugins
ExpectPlugin::create()->registerTo($emitter);
$emitter->on('peridot.configure', function($config) {
$config->setDsl(__DIR__.'/Dsl/feature.dsl.php');
$config->setGrep('*.test.php');
$config->setReporter("feature");
});
$emitter->on('peridot.reporters', function($input, $reporters) {
$reporters->register('feature', 'A feature reporter', 'BIRD3\Test\Php\Dsl\FeatureReporter');
});
}; Peridot is executed through an NPM script, and output looks like so:
Why is it trying to load a test suite that I didn't even specify...? |
Oh, looky look. Actually the
|
Nevermind. I found the problem and its rather stupid, but something you should be aware of. When opening Peridot's help:
It tells me to use an equal ( I have no idea why this is a thing, but its important to let you know. |
Ah. Thanks for finding this! A PR to address the help screen would definitely be welcome. I did not realize an = sign broke things. It might also be an issue with how peridot parses the confit switch. Peridot uses the Symfony console library for most of the CLI, but it parses the configuration option separately to load the confit before the Symfony app is created |
I highly suggest using a library for parsing commandline switches. That ensures that specific behaviour is granted. As far as I know, Symfony does even have such functions, without having to bootstrap a Console app first. When I find some time I will see if I can fix the current method with a PR. |
Just looked at https://github.com/peridot-php/peridot/blob/master/src/Console/CliOptionParser.php The way you are parsing arguments would've to be overwritten entirely in order to make = work. Basically:
|
Peridot does a small amount of manual parsing of CLI options to allow the plugin system to register additional command line switches and options. However, the manual parsing allows for some error as pointed out by @IngwiePhoenix. Following Ingwie's suggestions with regards to how we parse the --config switch would make this more solid :). I've switched the title of this issue and flagged it as a bug. |
Released in 1.19.0 🎉 |
I have a multi-language project, so I want to organize my tests inside a main
test
folder.I know that I can use
--configuration=test/php/peridot.php
to tell it where to look for the config. But how do I configure the folder containing tests?The text was updated successfully, but these errors were encountered: