Skip to content

Commit

Permalink
Update TestifyCommand.php
Browse files Browse the repository at this point in the history
Signed-off-by: Nathanael Esayeas <nathanael.esayeas@protonmail.com>
  • Loading branch information
ghostwriter committed Jan 23, 2024
1 parent 7312f7f commit 04dad75
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/Command/TestifyCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,19 @@ public function __construct(
$this->setDescription('Generate missing Tests.');
$this->setVersion(InstalledVersions::getPrettyVersion('ghostwriter/testify') ?? 'UNKNOWN');
$this->addArgument('source', InputArgument::OPTIONAL, 'The path to search for missing tests.', 'src');
$this->addArgument('tests', InputArgument::OPTIONAL, 'The path used to create tests.', 'tests/Unit');
$this->addOption('dry-run', 'd', InputOption::VALUE_NONE, 'Do not write any files.');
}

#[Override]
protected function execute(InputInterface $input, OutputInterface $output): int
{
$output->writeln(sprintf(
'%s by %s and Contributors. <%s>' . PHP_EOL,
'<info>%s</info> by <info>%s</info> (<comment>%s</comment>) and contributors. %s' . PHP_EOL,
'Testify',
'Nathanael Esayeas',
'#BlackLivesMatter'
'https://ghostwriter.github.io',
'<error>#BlackLivesMatter</error>'
));

/** @var bool $dryRun */
Expand All @@ -81,11 +83,18 @@ protected function execute(InputInterface $input, OutputInterface $output): int
if ($dryRun || $this->filesystem->missing($testFile)) {
++$count;

$memoryUsage = memory_get_usage(true);
$output->writeln([
PHP_EOL ,
'Generating ' . $testFile,
'from ' . $file,
(memory_get_usage(true) / 10000) . ' bytes used',
match(true){
$memoryUsage < 1024 => sprintf('%s bytes used', $memoryUsage),
$memoryUsage < 1048576 => sprintf('%s KiB used', round($memoryUsage / 1024, 2)),
$memoryUsage < 1073741824 => sprintf('%s MiB used', round($memoryUsage / 1048576, 2)),
$memoryUsage < 1099511627776 => sprintf('%s GiB used', round($memoryUsage / 1073741824, 2)),
$memoryUsage < 1125899906842624 => sprintf('%s TiB used', round($memoryUsage / 1099511627776, 2)),
},
gc_collect_cycles() . ' garbage collections',

Check failure on line 98 in src/Command/TestifyCommand.php

View workflow job for this annotation

GitHub Actions / automation / Psalm on ubuntu with PHP 8.3 and Composer locked

InvalidOperand

src/Command/TestifyCommand.php:98:21: InvalidOperand: Cannot concatenate with a int (see https://psalm.dev/058)

Check failure on line 98 in src/Command/TestifyCommand.php

View workflow job for this annotation

GitHub Actions / automation / Psalm on ubuntu with PHP 8.3 and Composer locked

InvalidOperand

src/Command/TestifyCommand.php:98:21: InvalidOperand: Cannot concatenate with a int (see https://psalm.dev/058)
PHP_EOL,
]);
Expand Down

0 comments on commit 04dad75

Please sign in to comment.