diff --git a/test/fetchzip.sh b/test/fetchzip.sh index 89686f1..ecfedae 100755 --- a/test/fetchzip.sh +++ b/test/fetchzip.sh @@ -5,7 +5,7 @@ PORT=$(($$ + 1024)) # PID + 1024 -rm -rf "$HOME"/.dub/packages/gitcompatibledubpackage-* +dub remove gitcompatibledubpackage --non-interactive --version=* 2>/dev/null || true "$DUB" build --single "$DIR"/test_registry.d "$DIR"/test_registry --folder="$DIR/issue1336-registry" --port=$PORT & @@ -14,15 +14,20 @@ trap 'kill $PID 2>/dev/null || true' exit echo "Trying to download gitcompatibledubpackage (1.0.4)" -timeout 1s "$DUB" -v fetch gitcompatibledubpackage --version=1.0.4 --skip-registry=all --registry=http://localhost:$PORT +timeout 1s "$DUB" fetch gitcompatibledubpackage --version=1.0.4 --skip-registry=all --registry=http://localhost:$PORT if [ $? -eq 124 ]; then die 'Fetching from responsive registry should not time-out.' fi +dub remove gitcompatibledubpackage --non-interactive --version=1.0.4 echo "Trying to download gitcompatibledubpackage (1.0.3) from a broken registry" -zipCount=$(! "$DUB" -v fetch gitcompatibledubpackage --version=1.0.3 --skip-registry=all --registry=http://localhost:$PORT 2>&1| grep -c 'Failed to extract zip archive') -if [ "$zipCount" -le 3 ] ; then +zipCount=$(! timeout 1s "$DUB" fetch gitcompatibledubpackage --version=1.0.3 --skip-registry=all --registry=http://localhost:$PORT 2>&1| grep -Fc 'Failed to extract zip archive') +rc=$? +if [ "$zipCount" -le 3 ] ; then die 'DUB should have tried to download the zip archive multiple times.' -elif [ $? -eq 124 ]; then +elif [ $rc -eq 124 ]; then die 'DUB timed out unexpectedly.' fi +if dub remove gitcompatibledubpackage --non-interactive --version=* 2>/dev/null; then + die 'DUB should not have installed a broken package.' +fi diff --git a/test/test_registry.d b/test/test_registry.d index 233da44..c736845 100644 --- a/test/test_registry.d +++ b/test/test_registry.d @@ -6,10 +6,8 @@ void main(string[] args) { import std.conv, vibe.d; - string folder; - uint port = 12345; - readOption("folder", &folder, "Folder to service files from."); - readOption("port", &port, "Port to use"); + immutable folder = readRequiredOption!string("folder", "Folder to service files from."); + immutable port = readRequiredOption!uint("port", "Port to use"); auto router = new URLRouter; router.get("stop", (HTTPServerRequest req, HTTPServerResponse res){ res.writeVoidBody;