mirror of
https://github.com/nvm-sh/nvm.git
synced 2025-09-09 20:09:09 +00:00
[New] Dynamically detect if curl supports --compressed
This commit is contained in:
39
test/fast/Unit tests/nvm_curl_libz_support
Executable file
39
test/fast/Unit tests/nvm_curl_libz_support
Executable file
@@ -0,0 +1,39 @@
|
||||
#!/bin/sh
|
||||
|
||||
cleanup() {
|
||||
unset -f curl
|
||||
}
|
||||
|
||||
die() { cleanup; echo "$@" ; exit 1; }
|
||||
|
||||
\. ../../../nvm.sh
|
||||
|
||||
curl() {
|
||||
# curl with libz feature
|
||||
if [ $# -ne 1 ] || [ "$1" != "-V" ]; then
|
||||
die "This fake curl only takes one parameter -V"
|
||||
fi
|
||||
echo "
|
||||
curl 7.47.0 (x86_64-pc-linux-gnu) libcurl/7.47.0 GnuTLS/3.4.10 zlib/1.2.8 libidn/1.32 librtmp/2.3
|
||||
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp smb smbs smtp smtps telnet tftp
|
||||
Features: AsynchDNS IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz TLS-SRP UnixSockets"
|
||||
}
|
||||
|
||||
nvm_curl_libz_support || die "nvm_curl_libz_support should return 0"
|
||||
|
||||
unset -f curl
|
||||
|
||||
curl() {
|
||||
# curl without libz feature
|
||||
if [ "$#" -ne 1 ] || [ "$1" != "-V" ]; then
|
||||
die "This fake curl only takes one parameter -V"
|
||||
fi
|
||||
echo "
|
||||
curl 7.47.0 (x86_64-pc-linux-gnu) libcurl/7.47.0 GnuTLS/3.4.10 zlib/1.2.8 libidn/1.32 librtmp/2.32
|
||||
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp smb smbs smtp smtps telnet tftp
|
||||
Features: AsynchDNS IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL TLS-SRP UnixSockets"
|
||||
}
|
||||
|
||||
! nvm_curl_libz_support || die "nvm_curl_libz_support should return 1"
|
||||
|
||||
unset -f curl
|
@@ -14,7 +14,12 @@ EXPECTED_CURL_ARGS="--compressed -q -w %{url_effective}\n -L -s -S http://latest
|
||||
EXPECTED_WGET_ARGS="http://latest.nvm.sh --server-response -O /dev/null"
|
||||
|
||||
curl() {
|
||||
if [ "_$*" != "_$EXPECTED_CURL_ARGS" ]; then
|
||||
if [ $# -eq 1 ] && [ "$1" = "-V" ]; then
|
||||
echo "
|
||||
curl 7.47.0 (x86_64-pc-linux-gnu) libcurl/7.47.0 GnuTLS/3.4.10 zlib/1.2.8 libidn/1.32 librtmp/2.3
|
||||
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp smb smbs smtp smtps telnet tftp
|
||||
Features: AsynchDNS IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz TLS-SRP UnixSockets"
|
||||
elif [ "_$*" != "_$EXPECTED_CURL_ARGS" ]; then
|
||||
echo >&2 "expected args ($EXPECTED_CURL_ARGS), got ($*)"
|
||||
return 1
|
||||
else
|
||||
|
Reference in New Issue
Block a user