From 25824056ee3d4225af8bc6cd349a43108141a469 Mon Sep 17 00:00:00 2001 From: Kieran Date: Thu, 15 Sep 2022 04:55:41 +0100 Subject: [PATCH] Run CSSTidy tests on CI (#338) * Run CSSTidy tests on CI * update dirname * use compopser instead of git clone * use composer * use test-settings.sample.php * enable ext-intl * disable Net_IDNA2 --- .github/workflows/ci.yml | 9 ++-- composer.json | 15 ++++++- smoketests/common.php | 2 + smoketests/extractStyleBlocks.php | 17 -------- test-settings.sample.php | 19 +------- test-settings.travis.php | 72 ------------------------------- tests/common.php | 18 +------- tests/test_files.php | 4 +- 8 files changed, 26 insertions(+), 130 deletions(-) delete mode 100644 test-settings.travis.php diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b51d7a95..f0048048 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,12 +22,15 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} + tools: composer:v2 + ini-values: error_reporting=E_ALL + extensions: iconv, bcmath, tidy, mbstring, intl - - name: Clone simpletest - run: git clone --depth=50 https://github.com/ezyang/simpletest.git + - name: Install dependencies + run: composer install - name: Configure simpletest - run: cp test-settings.travis.php test-settings.php + run: cp test-settings.sample.php test-settings.php - name: Execute Unit tests run: php tests/index.php diff --git a/composer.json b/composer.json index afce4f8c..d7558295 100644 --- a/composer.json +++ b/composer.json @@ -15,6 +15,10 @@ "require": { "php": "~5.6.0 || ~7.0.0 || ~7.1.0 || ~7.2.0 || ~7.3.0 || ~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0" }, + "require-dev": { + "cerdic/css-tidy": "^1.7 || ^2.0", + "simpletest/simpletest": "dev-master" + }, "autoload": { "psr-0": { "HTMLPurifier": "library/" }, "files": ["library/HTMLPurifier.composer.php"], @@ -27,5 +31,14 @@ "ext-iconv": "Converts text to and from non-UTF-8 encodings", "ext-bcmath": "Used for unit conversion and imagecrash protection", "ext-tidy": "Used for pretty-printing HTML" - } + }, + "config": { + "sort-packages": true + }, + "repositories": [ + { + "type": "vcs", + "url": "https://github.com/ezyang/simpletest.git" + } + ] } diff --git a/smoketests/common.php b/smoketests/common.php index b2c2b4bb..eb99ad5e 100644 --- a/smoketests/common.php +++ b/smoketests/common.php @@ -2,6 +2,8 @@ header('Content-type: text/html; charset=UTF-8'); +require_once __DIR__.'/../vendor/autoload.php'; + if (!isset($_GET['standalone'])) { require_once '../library/HTMLPurifier.auto.php'; } else { diff --git a/smoketests/extractStyleBlocks.php b/smoketests/extractStyleBlocks.php index bb330b5f..0dff9837 100644 --- a/smoketests/extractStyleBlocks.php +++ b/smoketests/extractStyleBlocks.php @@ -3,23 +3,6 @@ require_once 'common.php'; require_once 'HTMLPurifier/Filter/ExtractStyleBlocks.php'; -// need CSSTidy location -$csstidy_location = false; -if (file_exists('../conf/test-settings.php')) include '../conf/test-settings.php'; -if (file_exists('../test-settings.php')) include '../test-settings.php'; - -if (!$csstidy_location) { -?> -Error: CSSTidy library not -found, please install and configure test-settings.php -accordingly. - true, )); diff --git a/test-settings.sample.php b/test-settings.sample.php index 480b6627..5acc7842 100644 --- a/test-settings.sample.php +++ b/test-settings.sample.php @@ -17,20 +17,6 @@ if ($data !== false && $data !== '') { exit; } -// ----------------------------------------------------------------------------- -// REQUIRED SETTINGS - -// Note on running SimpleTest: -// You want the Git copy of SimpleTest, found here: -// https://github.com/simpletest/simpletest/ -// -// If SimpleTest is borked with HTML Purifier, please contact me or -// the SimpleTest devs; I am a developer for SimpleTest so I should be -// able to quickly assess a fix. SimpleTest's problem is my problem! - -// Where is SimpleTest located? Remember to include a trailing slash! -$simpletest_location = '/path/to/simpletest/'; - // ----------------------------------------------------------------------------- // OPTIONAL SETTINGS @@ -50,9 +36,6 @@ $GLOBALS['HTMLPurifierTest']['PHPT'] = false; // If PHPT isn't in your Path via PEAR, set that here: // set_include_path('/path/to/phpt/Core/src' . PATH_SEPARATOR . get_include_path()); -// Where is CSSTidy located? (Include trailing slash. Leave false to disable.) -$csstidy_location = false; - // For tests/multitest.php, which versions to test? $versions_to_test = array(); @@ -69,6 +52,6 @@ $GLOBALS['HTMLPurifierTest']['PEAR'] = false; // If PEAR is enabled, what PEAR tests should be run? (Note: you will // need to ensure these libraries are installed) -$GLOBALS['HTMLPurifierTest']['Net_IDNA2'] = true; +$GLOBALS['HTMLPurifierTest']['Net_IDNA2'] = false; // vim: et sw=4 sts=4 diff --git a/test-settings.travis.php b/test-settings.travis.php deleted file mode 100644 index b1edce4a..00000000 --- a/test-settings.travis.php +++ /dev/null @@ -1,72 +0,0 @@ -=')) {