Skip to content

Commit

Permalink
up: update php run-unit command logic
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Dec 28, 2021
1 parent 1078b95 commit 0e4cf18
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
5 changes: 3 additions & 2 deletions app/Console/Controller/GitLabController.php
Original file line number Diff line number Diff line change
Expand Up @@ -613,9 +613,10 @@ public function resolveCommand(FlagsParser $fs, Output $output): void
*
* @example
* {binWithCmd} Will generate PR link for fork 'HEAD_BRANCH' to main 'HEAD_BRANCH'
* {binWithCmd} -s 4_16 -t qa Will generate PR link for main 'PREFIX_4_16' to main 'qa'
* {binWithCmd} -o @ Will open PR link for fork 'HEAD_BRANCH' to main 'HEAD_BRANCH' on browser
* {binWithCmd} -o qa Will open PR link for main 'HEAD_BRANCH' to main 'qa' on browser
* {binWithCmd} -t qa Will generate PR link for main 'HEAD_BRANCH' to main 'qa'
* {binWithCmd} -t qa --direct Will generate PR link for fork 'HEAD_BRANCH' to main 'qa'
* {binWithCmd} -t qa --direct Will generate PR link for fork 'HEAD_BRANCH' to main 'qa'
*/
public function pullRequestCommand(FlagsParser $fs, Output $output): void
{
Expand Down
18 changes: 16 additions & 2 deletions app/Console/Controller/PhpController.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ public function sql2arrCommand(FlagsParser $fs, Output $output): void
* --php-bin manual set the php bin file path.
* --phpunit manual set the phpunit(.phar) file path.
*
* @example
* Use special php and phpunit:
* {binWithCmd} --php-bin php7 --phpunit /Users/inhere/.composer/vendor/phpunit/phpunit/phpunit -f KEYWORDS ./test
*
* @param FlagsParser $fs
* @param Output $output
*/
Expand All @@ -189,16 +193,26 @@ public function runUnitCommand(FlagsParser $fs, Output $output): void

$output->info('found the phpunit config dir: ' . $runDir);

$phpBin = $fs->getOpt('php-bin');
if ($phpBin) {
$phpunit = $fs->getMustOpt('phpunit');

$cmd = Cmd::new($phpBin)->add($phpunit);
} else {
$phpunit = $fs->getOpt('phpunit', 'phpunit');

$cmd = Cmd::new($phpunit);
}

// phpunit --debug --filter KEYWORDS
$cmd = Cmd::new('phpunit')->setWorkDir($runDir);
$cmd->setWorkDir($runDir);
$cmd->addIf('--debug', !$fs->getOpt('no-debug'));

if ($filter = $fs->getOpt('filter')) {
$cmd->addArgs('--filter', $filter);
}

$cmd->runAndPrint();

$output->success('Complete');
}

Expand Down

0 comments on commit 0e4cf18

Please sign in to comment.