diff --git a/.github/workflows/hooks-test.yml b/.github/workflows/hooks-test.yml index a6a63f1..8582a10 100644 --- a/.github/workflows/hooks-test.yml +++ b/.github/workflows/hooks-test.yml @@ -1,6 +1,7 @@ name: Test Plugin on: + workflow_dispatch: pull_request: push: branches: [main] @@ -25,3 +26,5 @@ jobs: run: go run github.com/yuin/gopher-lua/cmd/glua@v1.1.1 tests/windows_test.lua - name: Test macOS OpenSSL selection run: bash tests/openssl_test.sh + - name: Test optional dependency diagnostics + run: bash tests/configure_options_test.sh diff --git a/bin/install b/bin/install index 84b400b..6d76372 100755 --- a/bin/install +++ b/bin/install @@ -233,13 +233,13 @@ os_based_configure_options() { if [ -n "$gmp_path" ]; then configure_options="--with-gmp=$gmp_path" else - echo "gmp not found, not including in installation" + echo "gmp not found, not including in installation" >&2 fi if [ -n "$sodium_path" ]; then configure_options="$configure_options --with-sodium=$sodium_path" else - echo "sodium not found, not including in installation" + echo "sodium not found, not including in installation" >&2 fi if [ -n "$freetype_path" ]; then diff --git a/tests/configure_options_test.sh b/tests/configure_options_test.sh new file mode 100644 index 0000000..061d0d5 --- /dev/null +++ b/tests/configure_options_test.sh @@ -0,0 +1,42 @@ +#!/usr/bin/env bash +set -euo pipefail +source bin/install + +# Optional dependency diagnostics must not become ./configure arguments. +uname() { echo Darwin; } +exit_if_homebrew_not_installed() { :; } +homebrew_package_path() { + case "$1" in + gmp) [[ "$with_gmp" == yes ]] && echo /fake/gmp ;; + libsodium) [[ "$with_sodium" == yes ]] && echo /fake/libsodium ;; + *) echo "/fake/$1" ;; + esac + return 0 +} +PHP_VERSION=8.4.10 +PHP_CONFIGURE_OPTIONS= +diagnostics=$(mktemp) +trap 'rm -f "$diagnostics"' EXIT +for with_gmp in yes no; do + for with_sodium in yes no; do + options=$(construct_configure_options /fake/php 2>"$diagnostics") + [[ "$options" != *'not found'* ]] || { + echo 'Dependency diagnostics leaked into configure arguments' >&2 + exit 1 + } + [[ "$options" == *'--prefix=/fake/php'* ]] + if [[ "$with_gmp" == yes ]]; then + [[ "$options" == *'--with-gmp=/fake/gmp'* ]] + else + [[ "$options" != *'--with-gmp='* ]] + grep -q 'gmp not found' "$diagnostics" + fi + if [[ "$with_sodium" == yes ]]; then + [[ "$options" == *'--with-sodium=/fake/libsodium'* ]] + else + [[ "$options" != *'--with-sodium='* ]] + grep -q 'sodium not found' "$diagnostics" + fi + done +done +echo 'Optional dependency diagnostics and configure arguments passed'