Skip to content
This repository has been archived by the owner on Sep 20, 2021. It is now read-only.

Commit

Permalink
feat(test) Add the --atoum-configuration-file option.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hywan committed Nov 14, 2017
2 parents 29a3c41 + 29862f6 commit 3aaf68d
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 8 deletions.
34 changes: 26 additions & 8 deletions src/Bin/Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,15 @@ class Test extends Console\Dispatcher\Kit
* Options description.
*/
protected $options = [
['configuration-file', Console\GetOption::REQUIRED_ARGUMENT, 'c'],
['autoloader', Console\GetOption::REQUIRED_ARGUMENT, 'l'],
['output-directory', Console\GetOption::REQUIRED_ARGUMENT, 'o'],
['concurrent-processes', Console\GetOption::REQUIRED_ARGUMENT, 'p'],
['bypass-cache', Console\GetOption::NO_ARGUMENT, 'C'],
['verbose', Console\GetOption::NO_ARGUMENT, 'v'],
['help', Console\GetOption::NO_ARGUMENT, 'h'],
['help', Console\GetOption::NO_ARGUMENT, '?']
['configuration-file', Console\GetOption::REQUIRED_ARGUMENT, 'c'],
['autoloader', Console\GetOption::REQUIRED_ARGUMENT, 'l'],
['output-directory', Console\GetOption::REQUIRED_ARGUMENT, 'o'],
['concurrent-processes', Console\GetOption::REQUIRED_ARGUMENT, 'p'],
['bypass-cache', Console\GetOption::NO_ARGUMENT, 'C'],
['atoum-configuration-file', Console\GetOption::REQUIRED_ARGUMENT, 'a'],
['verbose', Console\GetOption::NO_ARGUMENT, 'v'],
['help', Console\GetOption::NO_ARGUMENT, 'h'],
['help', Console\GetOption::NO_ARGUMENT, '?']
];


Expand Down Expand Up @@ -128,6 +129,15 @@ public function run(): int

break;

case 'a':
if (false === file_exists($v)) {
throw new RuntimeException('Extra atoum configuration file `' . $v . '` does not exist.');
}

$configuration->atoumConfigurationFile = $v;

break;

case 'v':
$verbose = $v;

Expand Down Expand Up @@ -255,6 +265,12 @@ public function run(): int
' --directories ' .
escapeshellarg($outputDirectory);

if (!empty($configuration->atoumConfigurationFile)) {
$command .=
' --configurations ' .
escapeshellarg($configuration->atoumConfigurationFile);
}

$processus = new Processus($command, null, null, getcwd(), $_SERVER);
$processus->on(
'input',
Expand Down Expand Up @@ -300,6 +316,8 @@ public function usage()
'o' => 'Directory that will receive the generated documentation test suites.',
'p' => 'Maximum concurrent processes that can run.',
'C' => 'Bypass the cache; compile test suites like it is for the first time.',
'a' => 'atoum is used to execute the generated tests. This option adds an ' .
'extra atoum configuration file after the one embedded inside Kitab.',
'v' => 'Be verbose (add some debug information).',
'help' => 'This help.'
]);
Expand Down
11 changes: 11 additions & 0 deletions src/Compiler/Target/DocTest/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,15 @@ class Configuration extends Kitab\Configuration
public $codeBlockHandlerNames = [
CodeBlockHandler\Php::class
];

/**
* atoum configuration file.
*
* Kitab uses [atoum](http://atoum.org/) to execute tests. Kitab comes
* with a default atoum configuration file, but it is possible to add
* another one that will be executed just after with the same context
* (variables & co.). It is useful to add specific atoum extensions for
* instance.
*/
public $atoumConfigurationFile = null;
}

0 comments on commit 3aaf68d

Please sign in to comment.