Skip to content
This repository has been archived by the owner on Mar 24, 2020. It is now read-only.

Fix format option and add bootstrap option. #64

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 0 additions & 2 deletions src/PHPSpec2/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
6 changes: 5 additions & 1 deletion src/PHPSpec2/Console/Command/RunCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
));
}

Expand All @@ -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());
Expand All @@ -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));
}
Expand Down
7 changes: 7 additions & 0 deletions src/PHPSpec2/Runner/Runner.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')) {
Expand Down