mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 07:47:22 +01:00
Adjusts tests to new printer
This commit is contained in:
@ -19,6 +19,6 @@ final class InvalidPestCommand extends InvalidArgumentException implements Excep
|
|||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__construct('Please run `./vendor/bin/pest` instead of `/vendor/bin/phpunit`.');
|
parent::__construct('Please run [./vendor/bin/pest] instead.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -113,6 +113,9 @@ final class Coverage implements AddsOutput, HandlesArguments
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$this->output->writeln(['']);
|
||||||
|
|
||||||
return $exitCode;
|
return $exitCode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,6 +11,8 @@ use SebastianBergmann\CodeCoverage\Node\File;
|
|||||||
use SebastianBergmann\Environment\Runtime;
|
use SebastianBergmann\Environment\Runtime;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
use Symfony\Component\Console\Terminal;
|
use Symfony\Component\Console\Terminal;
|
||||||
|
use function Termwind\render;
|
||||||
|
use function Termwind\renderUsing;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
@ -73,15 +75,6 @@ final class Coverage
|
|||||||
|
|
||||||
$totalCoverage = $codeCoverage->getReport()->percentageOfExecutedLines();
|
$totalCoverage = $codeCoverage->getReport()->percentageOfExecutedLines();
|
||||||
|
|
||||||
$output->writeln(
|
|
||||||
sprintf(
|
|
||||||
' <fg=white;options=bold>Cov: </><fg=default>%s</>',
|
|
||||||
$totalCoverage->asString()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
$output->writeln('');
|
|
||||||
|
|
||||||
/** @var Directory<File|Directory> $report */
|
/** @var Directory<File|Directory> $report */
|
||||||
$report = $codeCoverage->getReport();
|
$report = $codeCoverage->getReport();
|
||||||
|
|
||||||
@ -112,7 +105,7 @@ final class Coverage
|
|||||||
? '100.0'
|
? '100.0'
|
||||||
: number_format($file->percentageOfExecutedLines()->asFloat(), 1, '.', '');
|
: number_format($file->percentageOfExecutedLines()->asFloat(), 1, '.', '');
|
||||||
|
|
||||||
$takenSize = strlen($rawName . $percentage) + 4 + $linesExecutedTakenSize; // adding 3 space and percent sign
|
$takenSize = strlen($rawName . $percentage) + 2 + $linesExecutedTakenSize; // adding 3 space and percent sign
|
||||||
|
|
||||||
$percentage = sprintf(
|
$percentage = sprintf(
|
||||||
'<fg=%s>%s</>',
|
'<fg=%s>%s</>',
|
||||||
@ -121,13 +114,28 @@ final class Coverage
|
|||||||
);
|
);
|
||||||
|
|
||||||
$output->writeln(sprintf(
|
$output->writeln(sprintf(
|
||||||
' %s %s %s %%',
|
' %s <fg=gray>%s</> %s <fg=gray>%%</>',
|
||||||
$name,
|
$name,
|
||||||
str_repeat('.', max($dottedLineLength - $takenSize, 1)),
|
str_repeat('.', max($dottedLineLength - $takenSize, 1)),
|
||||||
$percentage
|
$percentage
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$totalCoverageAsString = $totalCoverage->asFloat() === 0.0
|
||||||
|
? '0.0'
|
||||||
|
: number_format($totalCoverage->asFloat(), 1, '.', '');
|
||||||
|
|
||||||
|
renderUsing($output);
|
||||||
|
render(<<<HTML
|
||||||
|
<div class="mx-2">
|
||||||
|
<hr class="text-gray" />
|
||||||
|
<div class="w-full text-right">
|
||||||
|
<span class="ml-1 font-bold">Total: {$totalCoverageAsString} %</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
HTML);
|
||||||
|
|
||||||
return $totalCoverage->asFloat();
|
return $totalCoverage->asFloat();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -4,4 +4,4 @@
|
|||||||
PASS Tests\Fixtures\ExampleTest
|
PASS Tests\Fixtures\ExampleTest
|
||||||
✓ it example 2
|
✓ it example 2
|
||||||
|
|
||||||
Tests: 2 passed
|
Tests: 2 passed (2 assertions)
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
PASS Tests\Fixtures\DirectoryWithTests\ExampleTest
|
PASS Tests\Fixtures\DirectoryWithTests\ExampleTest
|
||||||
✓ it example 1
|
✓ it example 1
|
||||||
|
|
||||||
Tests: 1 passed
|
Tests: 1 passed (1 assertions)
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
PASS Tests\Fixtures\DirectoryWithTests\ExampleTest
|
PASS Tests\Fixtures\DirectoryWithTests\ExampleTest
|
||||||
✓ [2mit example 1[22m
|
✓ it example 1
|
||||||
|
|
||||||
Tests: 1 passed
|
Tests: 1 passed (1 assertions)
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
|
|
||||||
[30;42;1m PASS [39;49;22m[39m Tests\Fixtures\DirectoryWithTests\ExampleTest[39m
|
[30;42;1m PASS [39;49;22m[39m Tests\Fixtures\DirectoryWithTests\ExampleTest[39m
|
||||||
[32;1m✓[39;22m[39m [2mit example 1[22m[39m
|
[32;1m✓[39;22m[38;5;103m [39m[38;5;103mit example 1[39m
|
||||||
|
|
||||||
[37;1mTests: [39;22m[32;1m1 passed[39;22m
|
[90;1mTests:[39;22m [32;1m1 passed[39;22m[90m (1 assertions)[39m
|
||||||
|
|||||||
@ -770,5 +770,4 @@
|
|||||||
WARN Tests\Visual\TeamCity
|
WARN Tests\Visual\TeamCity
|
||||||
- it is can successfully call all public methods → Not supported yet.
|
- it is can successfully call all public methods → Not supported yet.
|
||||||
|
|
||||||
Tests: 4 incompleted, 18 skipped, 515 passed
|
Tests: 4 incompleted, 18 skipped, 515 passed (1299 assertions)
|
||||||
|
|
||||||
|
|||||||
@ -16,7 +16,7 @@ test('visual snapshot of help command output', function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$output = function () {
|
$output = function () {
|
||||||
$process = (new Symfony\Component\Process\Process(['php', 'bin/pest', '--help']));
|
$process = (new Symfony\Component\Process\Process(['php', 'bin/pest', '--help'], null, ['COLLISION_PRINTER' => 'DefaultPrinter', 'COLLISION_IGNORE_DURATION' => 'true']));
|
||||||
|
|
||||||
$process->run();
|
$process->run();
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,9 @@
|
|||||||
use Symfony\Component\Process\Process;
|
use Symfony\Component\Process\Process;
|
||||||
|
|
||||||
$run = function (string $target, $decorated = false) {
|
$run = function (string $target, $decorated = false) {
|
||||||
$process = new Process(['php', 'bin/pest', $target, '--colors=always'], dirname(__DIR__, 2));
|
$process = new Process(['php', 'bin/pest', $target, '--colors=always'], dirname(__DIR__, 2),
|
||||||
|
['COLLISION_PRINTER' => 'DefaultPrinter', 'COLLISION_IGNORE_DURATION' => 'true'],
|
||||||
|
);
|
||||||
|
|
||||||
$process->run();
|
$process->run();
|
||||||
|
|
||||||
@ -29,6 +31,7 @@ test('allows to run a directory', function () use ($run, $snapshot) {
|
|||||||
})->skip(PHP_OS_FAMILY === 'Windows');
|
})->skip(PHP_OS_FAMILY === 'Windows');
|
||||||
|
|
||||||
it('has ascii chars', function () use ($run, $snapshot) {
|
it('has ascii chars', function () use ($run, $snapshot) {
|
||||||
|
file_put_contents(__DIR__.'/output.txt', $run('tests/Fixtures/DirectoryWithTests/ExampleTest.php', true));
|
||||||
expect($run('tests/Fixtures/DirectoryWithTests/ExampleTest.php', true))->toContain($snapshot('has-ascii-chars'));
|
expect($run('tests/Fixtures/DirectoryWithTests/ExampleTest.php', true))->toContain($snapshot('has-ascii-chars'));
|
||||||
})->skip(PHP_OS_FAMILY === 'Windows');
|
})->skip(PHP_OS_FAMILY === 'Windows');
|
||||||
|
|
||||||
@ -38,7 +41,7 @@ it('disable decorating printer when colors is set to never', function () use ($s
|
|||||||
'./bin/pest',
|
'./bin/pest',
|
||||||
'--colors=never',
|
'--colors=never',
|
||||||
'tests/Fixtures/DirectoryWithTests/ExampleTest.php',
|
'tests/Fixtures/DirectoryWithTests/ExampleTest.php',
|
||||||
], dirname(__DIR__, 2));
|
], dirname(__DIR__, 2), ['COLLISION_PRINTER' => 'DefaultPrinter', 'COLLISION_IGNORE_DURATION' => 'true']);
|
||||||
$process->run();
|
$process->run();
|
||||||
$output = $process->getOutput();
|
$output = $process->getOutput();
|
||||||
expect($output)->toContain($snapshot('disable-decorating-printer'));
|
expect($output)->toContain($snapshot('disable-decorating-printer'));
|
||||||
|
|||||||
@ -12,7 +12,7 @@ test('visual snapshot of test suite on success', function () {
|
|||||||
$process = (new Symfony\Component\Process\Process(
|
$process = (new Symfony\Component\Process\Process(
|
||||||
['php', 'bin/pest'],
|
['php', 'bin/pest'],
|
||||||
dirname($testsPath),
|
dirname($testsPath),
|
||||||
['EXCLUDE' => 'integration', 'REBUILD_SNAPSHOTS' => false, 'PARATEST' => 0, 'COLLISION_PRINTER' => 'DefaultPrinter'],
|
['EXCLUDE' => 'integration', 'REBUILD_SNAPSHOTS' => false, 'PARATEST' => 0, 'COLLISION_PRINTER' => 'DefaultPrinter', 'COLLISION_IGNORE_DURATION' => 'true'],
|
||||||
));
|
));
|
||||||
|
|
||||||
$process->run();
|
$process->run();
|
||||||
|
|||||||
Reference in New Issue
Block a user