diff --git a/src/PHPSpec2/Console/Application.php b/src/PHPSpec2/Console/Application.php index 6d4c390..a1431dc 100644 --- a/src/PHPSpec2/Console/Application.php +++ b/src/PHPSpec2/Console/Application.php @@ -37,8 +37,6 @@ public function __construct($version) $this->container = $c = new ServiceContainer; - $c->set('format', 'progress'); - $c->set('console.commands', array()); $c->set('io', $c->share(function($c) { return new Console\IO( diff --git a/src/PHPSpec2/Console/Command/RunCommand.php b/src/PHPSpec2/Console/Command/RunCommand.php index f1b2ac6..eca26eb 100644 --- a/src/PHPSpec2/Console/Command/RunCommand.php +++ b/src/PHPSpec2/Console/Command/RunCommand.php @@ -24,7 +24,8 @@ public function __construct() $this->setDefinition(array( new InputArgument('spec', InputArgument::OPTIONAL, 'Specs to run', 'spec'), - new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Formatter', 'progress'), + new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Formatter {pretty|progress}', 'progress'), + new InputOption('bootstrap', 'b', InputOption::VALUE_OPTIONAL, 'Path to bootstrap file'), )); } @@ -33,9 +34,11 @@ public function __construct() */ protected function execute(InputInterface $input, OutputInterface $output) { + //$output->setBootstrapper(new Console\Formatter($output->isDecorated())); $output->setFormatter(new Console\Formatter($output->isDecorated())); $c = $this->getApplication()->getContainer(); + $c->set('format', $input->getOption('format')); $c->set('console.input', $input); $c->set('console.output', $output); $c->set('console.helpers', $this->getHelperSet()); @@ -45,6 +48,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $result = 0; $startTime = microtime(true); + $c('runner')->runBootstrap($input->getOption('bootstrap')); foreach ($specs as $spec) { $result = max($result, $c('runner')->runSpecification($spec)); } diff --git a/src/PHPSpec2/Runner/Runner.php b/src/PHPSpec2/Runner/Runner.php index 6774f6f..120d34e 100644 --- a/src/PHPSpec2/Runner/Runner.php +++ b/src/PHPSpec2/Runner/Runner.php @@ -97,6 +97,13 @@ public function getEventDispatcher() return $this->eventDispatcher; } + public function runBootstrap($path) + { + if (is_file($path) || is_file($path = $path.'.php')) { + require_once($path); + } + } + public function runSpecification(Node\Specification $specification) { if (defined('PHPSPEC_ERROR_REPORTING')) {