Skip to content

Commit

Permalink
Merge pull request #361 from eliashaeussler/task/windows-tests
Browse files Browse the repository at this point in the history
[TASK] Run tests for Windows and macOS as well
  • Loading branch information
eliashaeussler authored Jun 21, 2024
2 parents ce0e2bd + 88258ad commit e505421
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 21 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,21 @@ on:

jobs:
tests:
name: Tests (PHP ${{ matrix.php-version }} & ${{ matrix.dependencies }} dependencies)
runs-on: ubuntu-latest
name: Tests (PHP ${{ matrix.php-version }}, ${{ matrix.os }} & ${{ matrix.dependencies }} dependencies)
runs-on: ${{ matrix.os }}-latest
strategy:
fail-fast: false
matrix:
php-version: ["8.1", "8.2", "8.3"]
dependencies: ["locked", "highest", "lowest"]
os: ["Ubuntu"]
include:
- php-version: "8.3"
dependencies: "highest"
os: "macOS"
- php-version: "8.3"
dependencies: "highest"
os: "Windows"
steps:
- uses: actions/checkout@v4
with:
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/Crawler/OutputtingCrawlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@ public function crawlWritesCrawlingStateAsProgressBarToOutput(): void
$output = $this->output->fetch();

self::assertNotEmpty($output);
self::assertMatchesRegularExpression('#^\s*1/2 \S+\s+\d+% -- no failures$#m', $output);
self::assertMatchesRegularExpression('#^\s*2/2 \S+\s+\d+% -- 1 failure$#m', $output);
self::assertMatchesRegularExpression('#^\s*1/2 \S+\s+\d+% -- no failures#m', $output);
self::assertMatchesRegularExpression('#^\s*2/2 \S+\s+\d+% -- 1 failure#m', $output);
}

#[Framework\Attributes\Test]
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/Helper/FilesystemHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function resolveRelativePathPrependsProjectRootPath(): void
{
$currentWorkingDirectory = getcwd();
$projectRootPath = __DIR__.'/..';
$expected = dirname(__DIR__).'/foo/baz';
$expected = Src\Helper\FilesystemHelper::joinPathSegments(dirname(__DIR__).'/foo/baz');

self::assertNotFalse($currentWorkingDirectory, 'Unable to get current working directory.');

Expand Down
12 changes: 6 additions & 6 deletions tests/unit/Http/Message/Handler/CompactProgressHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function startProgressBarStartsProgressBar(): void
$output = $this->output->fetch();

self::assertNotEmpty($output);
self::assertMatchesRegularExpression('#^\s*0/10 \S+\s+0% -- no failures$#m', $output);
self::assertMatchesRegularExpression('#^\s*0/10 \S+\s+0% -- no failures#m', $output);
}

#[Framework\Attributes\Test]
Expand All @@ -67,8 +67,8 @@ public function finishProgressBarFinishesProgressBar(): void
$output = $this->output->fetch();

self::assertNotEmpty($output);
self::assertMatchesRegularExpression('#^\s*0/10 \S+\s+0% -- no failures$#m', $output);
self::assertMatchesRegularExpression('#^\s*10/10 \S+\s+100% -- no failures$#m', $output);
self::assertMatchesRegularExpression('#^\s*0/10 \S+\s+0% -- no failures#m', $output);
self::assertMatchesRegularExpression('#^\s*10/10 \S+\s+100% -- no failures#m', $output);
}

#[Framework\Attributes\Test]
Expand All @@ -83,7 +83,7 @@ public function onSuccessPrintsSuccessfulUrlAndAdvancesProgressBarByOneStep(): v
$output = $this->output->fetch();

self::assertNotEmpty($output);
self::assertMatchesRegularExpression('#^\s*1/10 \S+\s+10% -- no failures$#m', $output);
self::assertMatchesRegularExpression('#^\s*1/10 \S+\s+10% -- no failures#m', $output);
}

#[Framework\Attributes\Test]
Expand All @@ -99,7 +99,7 @@ public function onFailurePrintsFailedUrlAndAdvancesProgressBarByOneStep(): void
$output = $this->output->fetch();

self::assertNotEmpty($output);
self::assertMatchesRegularExpression('#^\s*1/10 \S+\s+10% -- 1 failure$#m', $output);
self::assertMatchesRegularExpression('#^\s*2/10 \S+\s+20% -- 2 failures$#m', $output);
self::assertMatchesRegularExpression('#^\s*1/10 \S+\s+10% -- 1 failure#m', $output);
self::assertMatchesRegularExpression('#^\s*2/10 \S+\s+20% -- 2 failures#m', $output);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function startProgressBarStartsProgressBar(): void
$output = $this->output->fetch();

self::assertNotEmpty($output);
self::assertMatchesRegularExpression('#^\s*0/10 \S+\s+0%$#m', $output);
self::assertMatchesRegularExpression('#^\s*0/10 \S+\s+0%#m', $output);
}

#[Framework\Attributes\Test]
Expand All @@ -67,7 +67,7 @@ public function finishProgressBarFinishesProgressBar(): void
$output = $this->output->fetch();

self::assertNotEmpty($output);
self::assertMatchesRegularExpression('#^\s*10/10 \S+\s+100%$#m', $output);
self::assertMatchesRegularExpression('#^\s*10/10 \S+\s+100%#m', $output);
}

#[Framework\Attributes\Test]
Expand All @@ -83,7 +83,7 @@ public function onSuccessPrintsSuccessfulUrlAndAdvancesProgressBarByOneStep(): v

self::assertNotEmpty($output);
self::assertStringContainsString(' DONE '.$uri, $output);
self::assertMatchesRegularExpression('#^\s*1/10 \S+\s+10%$#m', $output);
self::assertMatchesRegularExpression('#^\s*1/10 \S+\s+10%#m', $output);
}

#[Framework\Attributes\Test]
Expand All @@ -99,6 +99,6 @@ public function onFailurePrintsFailedUrlAndAdvancesProgressBarByOneStep(): void

self::assertNotEmpty($output);
self::assertStringContainsString(' FAIL '.$uri, $output);
self::assertMatchesRegularExpression('#^\s*1/10 \S+\s+10%$#m', $output);
self::assertMatchesRegularExpression('#^\s*1/10 \S+\s+10%#m', $output);
}
}
12 changes: 6 additions & 6 deletions tests/unit/Log/FileLoggerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,10 @@
use EliasHaeussler\CacheWarmup as Src;
use PHPUnit\Framework;
use Psr\Log;
use Symfony\Component\Filesystem;

use function dirname;
use function file_exists;
use function file_get_contents;
use function rmdir;
use function sys_get_temp_dir;
use function uniqid;
use function unlink;
Expand Down Expand Up @@ -86,9 +85,10 @@ public function logLogsFormattedMessageToLogFile(): void

protected function tearDown(): void
{
if (file_exists($this->logFile)) {
unlink($this->logFile);
rmdir(dirname($this->logFile));
}
// Run subject destruction to close log file stream
unset($this->subject);

$filesystem = new Filesystem\Filesystem();
$filesystem->remove(dirname($this->logFile));
}
}

0 comments on commit e505421

Please sign in to comment.