mirror of
https://github.com/roundcube/roundcubemail.git
synced 2026-02-20 01:21:20 +01:00
Run unit tests in CI on Windows too (#9251)
* Run unit tests in CI on Windows too * Install::test_check_mime_extensions() has no mime.types on Windows * Fix sqlite test DB path and unlink for Windows * Fix rcube::exec() testing for Windows * Prevent git EOL conversion for tests/ * Fix test_rtf2text test for text with CRLF * run E2E tests on one php version only
This commit is contained in:
2
.github/config-test.inc.php
vendored
2
.github/config-test.inc.php
vendored
@@ -3,7 +3,7 @@
|
||||
$config = [];
|
||||
|
||||
// Database configuration
|
||||
$config['db_dsnw'] = 'sqlite:////tmp/sqlite.db?mode=0646';
|
||||
$config['db_dsnw'] = 'sqlite:///' . sys_get_temp_dir() . '/roundcube-test-sqlite.db?mode=0646';
|
||||
|
||||
// Test user credentials
|
||||
$config['tests_username'] = 'test';
|
||||
|
||||
8
.github/workflows/browser_tests.yml
vendored
8
.github/workflows/browser_tests.yml
vendored
@@ -1,4 +1,4 @@
|
||||
name: browser_tests
|
||||
name: E2E
|
||||
|
||||
on:
|
||||
push:
|
||||
@@ -14,8 +14,10 @@ jobs:
|
||||
|
||||
strategy:
|
||||
fail-fast: true
|
||||
matrix:
|
||||
php: ["8.1"]
|
||||
|
||||
name: Browser Tests
|
||||
name: Linux / PHP ${{ matrix.php }}
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
@@ -24,7 +26,7 @@ jobs:
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: '8.1'
|
||||
php-version: ${{ matrix.php }}
|
||||
extensions: dom, curl, fileinfo, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, gd, ldap, intl, pspell
|
||||
tools: composer:v2
|
||||
coverage: none
|
||||
|
||||
48
.github/workflows/tests.yml
vendored
48
.github/workflows/tests.yml
vendored
@@ -1,4 +1,4 @@
|
||||
name: tests
|
||||
name: Unit
|
||||
|
||||
on:
|
||||
push:
|
||||
@@ -8,7 +8,7 @@ permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
linux_tests:
|
||||
tests_linux:
|
||||
runs-on: ubuntu-latest
|
||||
if: "!contains(github.event.head_commit.message, '[skip ci]') && !contains(github.event.head_commit.message, '[ci skip]')"
|
||||
|
||||
@@ -17,7 +17,7 @@ jobs:
|
||||
matrix:
|
||||
php: ["7.3", "7.4", "8.0", "8.1", "8.2", "8.3"]
|
||||
|
||||
name: PHP ${{ matrix.php }}/Linux
|
||||
name: Linux / PHP ${{ matrix.php }}
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
@@ -43,10 +43,6 @@ jobs:
|
||||
cp composer.json-dist composer.json
|
||||
composer require "kolab/net_ldap3:~1.1.1" --no-update
|
||||
|
||||
- name: Fix PHPUnit for PHP 8.2
|
||||
run: composer config platform.php 8.1
|
||||
if: matrix.php >= 8.2
|
||||
|
||||
- name: Install dependencies
|
||||
run: composer install --prefer-dist --no-interaction --no-progress
|
||||
|
||||
@@ -62,3 +58,41 @@ jobs:
|
||||
with:
|
||||
name: Logs
|
||||
path: logs/errors.log
|
||||
|
||||
tests_windows:
|
||||
runs-on: windows-latest
|
||||
if: "!contains(github.event.head_commit.message, '[skip ci]') && !contains(github.event.head_commit.message, '[ci skip]')"
|
||||
|
||||
strategy:
|
||||
fail-fast: true
|
||||
matrix:
|
||||
php: ["7.3", "7.4", "8.0", "8.1", "8.2", "8.3"]
|
||||
|
||||
name: Windows / PHP ${{ matrix.php }}
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ matrix.php }}
|
||||
extensions: dom, curl, fileinfo, libxml, mbstring, zip, pdo, sqlite, pdo_sqlite, gd, ldap, intl
|
||||
tools: composer:v2
|
||||
coverage: none
|
||||
ini-values: error_reporting=E_ALL
|
||||
|
||||
- name: Setup composer
|
||||
run: |
|
||||
cp composer.json-dist composer.json
|
||||
composer require "kolab/net_ldap3:~1.1.1" --no-update
|
||||
|
||||
- name: Install dependencies
|
||||
run: composer install --prefer-dist --no-interaction --no-progress
|
||||
|
||||
- name: Roundcube configuration
|
||||
run: cp .github/config-test.inc.php config/config-test.inc.php
|
||||
|
||||
- name: Execute tests
|
||||
run: vendor/bin/phpunit -c tests/phpunit.xml
|
||||
|
||||
5
tests/.gitattributes
vendored
Normal file
5
tests/.gitattributes
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
# prevent git EOL conversion
|
||||
/src/sql/*.sql -text
|
||||
/src/format-flowed.txt -text
|
||||
/src/format-flowed-unfolded.txt -text
|
||||
*.php eol=lf
|
||||
@@ -113,8 +113,9 @@ class ActionTestCase extends PHPUnit\Framework\TestCase
|
||||
}
|
||||
else if ($dsn['phptype'] == 'sqlite') {
|
||||
$db->closeConnection();
|
||||
|
||||
// delete database file
|
||||
system(sprintf('rm -f %s', escapeshellarg($dsn['database'])));
|
||||
unlink($dsn['database']);
|
||||
|
||||
// load sample test data
|
||||
self::loadSQLScript($db, 'init');
|
||||
|
||||
@@ -69,6 +69,13 @@ class Framework_Rcube extends PHPUnit\Framework\TestCase
|
||||
*/
|
||||
function test_exec()
|
||||
{
|
||||
if (PHP_OS_FAMILY === 'Windows') {
|
||||
$this->assertSame('', rcube::exec('where.exe unknown-command-123 2> nul'));
|
||||
$this->assertSame('12', rcube::exec('set /a 10 + {v}', ['v' => '2']));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->assertSame('', rcube::exec('which unknown-command-123'));
|
||||
$this->assertSame("2038\n", rcube::exec('date --date={date} +%Y', ['date' => '@2147483647']));
|
||||
// TODO: More cases
|
||||
|
||||
@@ -57,7 +57,7 @@ class Framework_TnefDecoder extends PHPUnit\Framework\TestCase
|
||||
$body = file_get_contents(TESTS_DIR . 'src/sample.rtf');
|
||||
$text = rcube_tnef_decoder::rtf2text($body);
|
||||
|
||||
$this->assertMatchesRegularExpression('/^[a-zA-Z1-6!&<,> \n\.]+$/', $text);
|
||||
$this->assertMatchesRegularExpression('/^[a-zA-Z1-6!&<,> \n\r\.]+$/', $text);
|
||||
$this->assertTrue(strpos($text, 'Alex Skolnick') !== false);
|
||||
$this->assertTrue(strpos($text, 'Heading 1') !== false);
|
||||
$this->assertTrue(strpos($text, 'Heading 2') !== false);
|
||||
|
||||
@@ -74,6 +74,10 @@ class Rcmail_RcmailInstall extends ActionTestCase
|
||||
|
||||
/**
|
||||
* Test check_mime_extensions() method
|
||||
*
|
||||
* Windows feature request: https://github.com/php/php-src/issues/12918
|
||||
*
|
||||
* @requires OSFAMILY Linux
|
||||
*/
|
||||
function test_check_mime_extensions()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user