From 7a7519b64a2f047ecd6aa0dca3f26b79e546da37 Mon Sep 17 00:00:00 2001 From: Michele Locati Date: Sun, 18 Oct 2020 14:05:35 +0200 Subject: [PATCH] Don't force PHP as the langauge of extension tests Test: gd --- .php_cs | 1 + scripts/check-installed-extension.php | 7 +++-- scripts/tests/{gd.php => gd} | 39 ++++++++++++++++++++------- 3 files changed, 36 insertions(+), 11 deletions(-) rename scripts/tests/{gd.php => gd} (71%) mode change 100644 => 100755 diff --git a/.php_cs b/.php_cs index f6b713a..1c408b6 100644 --- a/.php_cs +++ b/.php_cs @@ -325,5 +325,6 @@ return PhpCsFixer\Config::create() ->exclude('vendor') ->in(__DIR__) ->name('.php_cs') + ->append(glob(__DIR__ . '/scripts/tests/*')) ) ; diff --git a/scripts/check-installed-extension.php b/scripts/check-installed-extension.php index 96e3444..9af280c 100644 --- a/scripts/check-installed-extension.php +++ b/scripts/check-installed-extension.php @@ -9,7 +9,10 @@ $nameMap = [ $testsDir = __DIR__ . '/tests'; function runTest($testFile) { - return include $testFile; + $rc = -1; + passthru($testFile, $rc); + + return $rc === 0; } for ($index = 1, $count = isset($argv) ? count($argv) : 0; $index < $count; $index++) { @@ -26,7 +29,7 @@ for ($index = 1, $count = isset($argv) ? count($argv) : 0; $index < $count; $ind if (!extension_loaded($extension)) { fprintf(STDERR, sprintf("Extension not loaded: %s\n", $extension)); } else { - $testFile = "{$testsDir}/{$extension}.php"; + $testFile = "{$testsDir}/{$extension}"; if (is_file($testFile)) { try { if (runTest($testFile) === true) { diff --git a/scripts/tests/gd.php b/scripts/tests/gd old mode 100644 new mode 100755 similarity index 71% rename from scripts/tests/gd.php rename to scripts/tests/gd index e9406a0..16d2d54 --- a/scripts/tests/gd.php +++ b/scripts/tests/gd @@ -1,5 +1,21 @@ +#!/usr/bin/env php getMessage()); +} catch (Throwable $x) { + $rc = 1; + fwrite(STDERR, $x->getMessage()); } finally { imagedestroy($image); if (is_resource($image2)) { @@ -69,12 +98,4 @@ try { unlink($tempFile); } } - -if (!function_exists('imagefttext')) { - throw new Exception('imagefttext() function is missing'); -} -if (!function_exists('imageantialias')) { - throw new Exception('imageantialias() function is missing'); -} - -return true; +exit($rc);