diff --git a/master_changes.md b/master_changes.md index 2aeb2d1122d..0ab90edb83a 100644 --- a/master_changes.md +++ b/master_changes.md @@ -108,6 +108,7 @@ users) * Add several checksum & cache validation checks for archive, extra-source section, and extra-file field [#5560 @rjbou] * Move local-cache into archive-field-checks test [#5560 @rjbou] * Admin: add `admin add-extrafiles` test cases [#5647 @rjbou] + * Add download test, to check `OPAMCURL/OPAMFETCH` handling [#5607 @rjbou] ### Engine * With real path resolved for all opam temp dir, remove `/private` from mac temp dir regexp [#5654 @rjbou] diff --git a/tests/reftests/download.test b/tests/reftests/download.test new file mode 100644 index 00000000000..1155197fd34 --- /dev/null +++ b/tests/reftests/download.test @@ -0,0 +1,150 @@ +N0REP0 +### :::::::::::::::::::::::::::::::::: +### :I: OPAMFETCH & OPAMCURL variables +### :::::::::::::::::::::::::::::::::: +### OPAMVERBOSE=2 +### opam --version >$ OPAMVERSION +### +opam-version: "2.0" +url { + src: "https://github.com/UnixJunkie/get_line/archive/v1.0.0.tar.gz" + checksum: "md5=c9c157af4229fbb45d3f59f0d6d75dbe" +} +### opam switch create download --empty +### opam install foo --download-only | grep -v "^+-" | ".*\(curl\|wget\).* \"--\"" -> 'curl-or-wget --' | sed-cmd tar +The following actions will be performed: +=== install 1 package + - install foo 1 + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +Processing 1/1: [foo.1: http] +curl-or-wget -- "https://github.com/UnixJunkie/get_line/archive/v1.0.0.tar.gz" +Processing 1/1: ++ tar "xfz" "${OPAMTMP}/v1.0.0.tar.gz" "-C" "${OPAMTMP}" +Done. +### opam clean -c +Clearing cache of downloaded files +### :I:a: FETCH wget +### OPAMFETCH=wget +### opam install foo --download-only | grep -v "^+-" | sed-cmd wget | sed-cmd tar | "${OPAMVERSION}" -> "current" +The following actions will be performed: +=== install 1 package + - install foo 1 + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +Processing 1/1: [foo.1: http] ++ wget "--content-disposition" "-t" "3" "-O" "${BASEDIR}/OPAM/download/.opam-switch/sources/foo.1/v1.0.0.tar.gz.part" "-U" "opam/current" "--" "https://github.com/UnixJunkie/get_line/archive/v1.0.0.tar.gz" +Processing 1/1: ++ tar "xfz" "${OPAMTMP}/v1.0.0.tar.gz" "-C" "${OPAMTMP}" +Done. +### opam clean -c +Clearing cache of downloaded files +### :I:b: FETCH curl +### OPAMFETCH=curl +### opam install foo --download-only | grep -v "^+-" | sed-cmd curl | sed-cmd tar | "${OPAMVERSION}" -> "current" +The following actions will be performed: +=== install 1 package + - install foo 1 + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +Processing 1/1: [foo.1: http] ++ curl "--write-out" "%{http_code}\n" "--retry" "3" "--retry-delay" "2" "--user-agent" "opam/current" "-L" "-o" "${BASEDIR}/OPAM/download/.opam-switch/sources/foo.1/v1.0.0.tar.gz.part" "--" "https://github.com/UnixJunkie/get_line/archive/v1.0.0.tar.gz" +Processing 1/1: ++ tar "xfz" "${OPAMTMP}/v1.0.0.tar.gz" "-C" "${OPAMTMP}" +Done. +### opam clean -c +Clearing cache of downloaded files +### :I:c: FETCH curl with args +### OPAMFETCH="curl --another-args %{retry}%" +### opam install foo --download-only | grep -v "^+-" | sed-cmd curl +The following actions will be performed: +=== install 1 package + - install foo 1 + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +Processing 1/1: [foo.1: http] ++ curl "--another-args" "3" +[ERROR] Failed to get sources of foo.1: Curl failed + +OpamSolution.Fetch_fail("https://github.com/UnixJunkie/get_line/archive/v1.0.0.tar.gz (Curl failed: \"curl --another-args 3\" exited with code 2)") + + +<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> +'${OPAM} install foo --download-only' failed. +# Return code 40 # +### opam clean -c +Clearing cache of downloaded files +### +#!/usr/bin/env bash +echo "***The curl is a lie*** [args: $@]" +### chmod +x bin/curl +### :I:d: local curl +### OPAMCURL=$BASEDIR/bin/curl +### opam install foo --download-only | grep -v "^+-" | sed-cmd curl +The following actions will be performed: +=== install 1 package + - install foo 1 + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +Processing 1/1: [foo.1: http] ++ curl "--another-args" "3" +[ERROR] Failed to get sources of foo.1: Curl failed + +OpamSolution.Fetch_fail("https://github.com/UnixJunkie/get_line/archive/v1.0.0.tar.gz (Curl failed: \"curl --another-args 3\" exited with code 2)") + + +<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> +'${OPAM} install foo --download-only' failed. +# Return code 40 # +### opam clean -c +Clearing cache of downloaded files +### :I:e: FETCH curl & local curl +### OPAMFETCH=curl OPAMCURL=$BASEDIR/bin/curl +### opam install foo --download-only | grep -v "^+-" | sed-cmd curl | sed-cmd tar | "${OPAMVERSION}" -> "current" +The following actions will be performed: +=== install 1 package + - install foo 1 + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +Processing 1/1: [foo.1: http] ++ curl "--write-out" "%{http_code}\n" "--retry" "3" "--retry-delay" "2" "--user-agent" "opam/current" "-L" "-o" "${BASEDIR}/OPAM/download/.opam-switch/sources/foo.1/v1.0.0.tar.gz.part" "--" "https://github.com/UnixJunkie/get_line/archive/v1.0.0.tar.gz" +Processing 1/1: ++ tar "xfz" "${OPAMTMP}/v1.0.0.tar.gz" "-C" "${OPAMTMP}" +Done. +### opam clean -c +Clearing cache of downloaded files +### :I:f: FETCH curl with args & local curl +### OPAMFETCH="curl --another-args %{retry}%" OPAMCURL=$BASEDIR/bin/curl +### opam install foo --download-only | grep -v "^+-" | sed-cmd curl +The following actions will be performed: +=== install 1 package + - install foo 1 + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +Processing 1/1: [foo.1: http] ++ curl "--another-args" "3" +[ERROR] Failed to get sources of foo.1: Curl failed + +OpamSolution.Fetch_fail("https://github.com/UnixJunkie/get_line/archive/v1.0.0.tar.gz (Curl failed: \"curl --another-args 3\" exited with code 2)") + + +<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> +'${OPAM} install foo --download-only' failed. +# Return code 40 # +### opam clean -c +Clearing cache of downloaded files +### :I:g: FETCH wget & local curl +### OPAMFETCH=wget OPAMCURL=$BASEDIR/bin/curl +### opam install foo --download-only | grep -v "^+-" | sed-cmd wget | sed-cmd tar | "${OPAMVERSION}" -> "current" +The following actions will be performed: +=== install 1 package + - install foo 1 + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +Processing 1/1: [foo.1: http] ++ wget "--content-disposition" "-t" "3" "-O" "${BASEDIR}/OPAM/download/.opam-switch/sources/foo.1/v1.0.0.tar.gz.part" "-U" "opam/current" "--" "https://github.com/UnixJunkie/get_line/archive/v1.0.0.tar.gz" +Processing 1/1: ++ tar "xfz" "${OPAMTMP}/v1.0.0.tar.gz" "-C" "${OPAMTMP}" +Done. +### opam clean -c +Clearing cache of downloaded files diff --git a/tests/reftests/dune.inc b/tests/reftests/dune.inc index f2d47a3e02a..1261dcb4f7c 100644 --- a/tests/reftests/dune.inc +++ b/tests/reftests/dune.inc @@ -359,6 +359,24 @@ %{targets} (run ./run.exe %{exe:../../src/client/opamMain.exe.exe} %{dep:dot-install.test} %{read-lines:testing-env})))) +(rule + (alias reftest-download) + (action + (diff download.test download.out))) + +(alias + (name reftest) + (deps (alias reftest-download))) + +(rule + (targets download.out) + (deps root-N0REP0) + (package opam) + (action + (with-stdout-to + %{targets} + (run ./run.exe %{exe:../../src/client/opamMain.exe.exe} %{dep:download.test} %{read-lines:testing-env})))) + (rule (alias reftest-empty-conflicts-001) (action