Skip to content

bin/http_test_server not functional on Windows #46

Closed
@TimWolla

Description

@TimWolla

PHP version: 7.4.9

Description

For guzzle/guzzle#2741 I attempted to set up Windows CI. This did not work, because bin/http_test_server cannot be used on Windows as is.

How to reproduce

Within a Guzzle clone attempt to use vendor/bin/http_test_server.bat.

Possible Solution

The issue appears to be that vendor/bin/http_test_server is not a symlink on Windows. Instead the file looks something like this:

#!/usr/bin/env sh

dir=$(cd "${0%[/\\]*}" > /dev/null; cd "../php-http/client-integration-tests/bin" && pwd)

if [ -d /proc/cygdrive ]; then
    case $(which php) in
        $(readlink -n /proc/cygdrive)/*)
            # We are in Cygwin using Windows php, so the path must be translated
            dir=$(cygpath -m "$dir");
            ;;
    esac
fi

"${dir}/http_test_server" "$@"

As ${dir}/http_test_server is executed and not vendor/bin/http_test_server as a symlink the BASH_SOURCE in http_test_server will point to vendor/php-http/client-integration-tests/bin/http_test_server, causing the script to search the autoloader in vendor/php-http/client-integration-tests/bin/../autoload.php:

https://github.com/TimWolla/guzzle/runs/1153859444?check_suite_focus=true

Additional context

From my patched GitHub Actions CI:

++ cd ./vendor/bin
++ cd ../php-http/client-integration-tests/bin
++ pwd
+ dir=/d/a/guzzle/guzzle/vendor/php-http/client-integration-tests/bin
+ '[' -d /proc/cygdrive ']'
+ case $(which php) in
++ which php
++ readlink -n /proc/cygdrive
+ /d/a/guzzle/guzzle/vendor/php-http/client-integration-tests/bin/http_test_server
+++ dirname /d/a/guzzle/guzzle/vendor/php-http/client-integration-tests/bin/http_test_server
++ cd /d/a/guzzle/guzzle/vendor/php-http/client-integration-tests/bin
++ pwd
+ DIR=/d/a/guzzle/guzzle/vendor/php-http/client-integration-tests/bin
+ '[' -f /d/a/guzzle/guzzle/vendor/php-http/client-integration-tests/bin/../autoload.php ']'
+ '[' -f /d/a/guzzle/guzzle/vendor/php-http/client-integration-tests/bin/../vendor/autoload.php ']'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions