mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 15:57:21 +01:00
Merge pull request #757 from pestphp/feat/skip-on-windows
[2.x] Adds `skipOnWindows()`, `skipOnMac()`, and `skipOnLinux()`
This commit is contained in:
@ -172,6 +172,40 @@ final class TestCall
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Skips the current test if the given test is running on Windows.
|
||||
*/
|
||||
public function skipOnWindows(): self
|
||||
{
|
||||
return $this->skipOn('Windows', 'This test is skipped on [Windows].');
|
||||
}
|
||||
|
||||
/**
|
||||
* Skips the current test if the given test is running on Mac OS.
|
||||
*/
|
||||
public function skipOnMac(): self
|
||||
{
|
||||
return $this->skipOn('Darwin', 'This test is skipped on [Mac].');
|
||||
}
|
||||
|
||||
/**
|
||||
* Skips the current test if the given test is running on Linux.
|
||||
*/
|
||||
public function skipOnLinux(): self
|
||||
{
|
||||
return $this->skipOn('Linux', 'This test is skipped on [Linux].');
|
||||
}
|
||||
|
||||
/**
|
||||
* Skips the current test if the given test is running on the given operating systems.
|
||||
*/
|
||||
private function skipOn(string $osFamily, string $message): self
|
||||
{
|
||||
return PHP_OS_FAMILY === $osFamily
|
||||
? $this->skip($message)
|
||||
: $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the test as "todo".
|
||||
*/
|
||||
|
||||
@ -39,4 +39,4 @@ test('collision', function (array $arguments) {
|
||||
})->with([
|
||||
[['']],
|
||||
[['--parallel']],
|
||||
])->skip(PHP_OS_FAMILY === 'Windows');
|
||||
])->skipOnWindows();
|
||||
|
||||
@ -18,4 +18,4 @@ test('visual snapshot of help command output', function () {
|
||||
}
|
||||
|
||||
expect($output())->toContain(file_get_contents($snapshot));
|
||||
})->skip(PHP_OS_FAMILY === 'Windows');
|
||||
})->skipOnWindows();
|
||||
|
||||
@ -20,7 +20,7 @@ test('parallel', function () use ($run) {
|
||||
expect($run('--exclude-group=integration'))
|
||||
->toContain('Tests: 2 deprecated, 3 warnings, 4 incomplete, 1 notice, 4 todos, 11 skipped, 697 passed (1696 assertions)')
|
||||
->toContain('Parallel: 3 processes');
|
||||
})->skip(PHP_OS_FAMILY === 'Windows');
|
||||
})->skipOnWindows();
|
||||
|
||||
test('a parallel test can extend another test with same name', function () use ($run) {
|
||||
expect($run('tests/Fixtures/Inheritance'))->toContain('Tests: 1 skipped, 2 passed (2 assertions)');
|
||||
|
||||
@ -24,11 +24,11 @@ $snapshot = function ($name) {
|
||||
|
||||
test('allows to run a single test', function () use ($run, $snapshot) {
|
||||
expect($run('tests/Fixtures/DirectoryWithTests/ExampleTest.php'))->toContain($snapshot('allows-to-run-a-single-test'));
|
||||
})->skip(PHP_OS_FAMILY === 'Windows');
|
||||
})->skipOnWindows();
|
||||
|
||||
test('allows to run a directory', function () use ($run, $snapshot) {
|
||||
expect($run('tests/Fixtures'))->toContain($snapshot('allows-to-run-a-directory'));
|
||||
})->skip(PHP_OS_FAMILY === 'Windows');
|
||||
})->skipOnWindows();
|
||||
|
||||
it('disable decorating printer when colors is set to never', function () use ($snapshot) {
|
||||
$process = new Process([
|
||||
@ -40,4 +40,4 @@ it('disable decorating printer when colors is set to never', function () use ($s
|
||||
$process->run();
|
||||
$output = $process->getOutput();
|
||||
expect($output)->toContain($snapshot('disable-decorating-printer'));
|
||||
})->skip(PHP_OS_FAMILY === 'Windows');
|
||||
})->skipOnWindows();
|
||||
|
||||
@ -41,4 +41,4 @@ test('visual snapshot of test suite on success', function () {
|
||||
expect(implode("\n", $output))->toContain(file_get_contents($snapshot));
|
||||
}
|
||||
})->skip(! getenv('REBUILD_SNAPSHOTS') && getenv('EXCLUDE'))
|
||||
->skip(PHP_OS_FAMILY === 'Windows');
|
||||
->skipOnWindows();
|
||||
|
||||
@ -26,8 +26,8 @@ $snapshot = function ($name) {
|
||||
|
||||
test('todo', function () use ($run, $snapshot) {
|
||||
expect($run('--todos', false))->toContain($snapshot('todo'));
|
||||
})->skip(PHP_OS_FAMILY === 'Windows');
|
||||
})->skipOnWindows();
|
||||
|
||||
test('todo in parallel', function () use ($run, $snapshot) {
|
||||
expect($run('--todos', true))->toContain($snapshot('todo'));
|
||||
})->skip(PHP_OS_FAMILY === 'Windows');
|
||||
})->skipOnWindows();
|
||||
|
||||
@ -18,4 +18,4 @@ test('visual snapshot of help command output', function () {
|
||||
}
|
||||
|
||||
expect($output())->toContain(file_get_contents($snapshot));
|
||||
})->skip(PHP_OS_FAMILY === 'Windows');
|
||||
})->skipOnWindows();
|
||||
|
||||
Reference in New Issue
Block a user