From b468854626f53bfe1704cd491676bb18c2e71cf8 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Sat, 11 Dec 2021 16:25:34 -0500 Subject: [PATCH] test: use different ports for each test, run some targets only on linux --- .github/workflows/main.yml | 2 +- tests/dl-out.expect | 2 +- tests/download_chunked.sh | 5 +++-- tests/dune | 4 ++++ tests/echo1.expect | 6 +++--- tests/echo1.sh | 5 +++-- tests/sse_count.expect | 2 +- tests/sse_count.sh | 5 +++-- tests/upload-out.expect | 2 +- tests/upload_chunked.sh | 6 ++++-- 10 files changed, 24 insertions(+), 15 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6a1cdf9e..bdbe0ab7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,6 +16,6 @@ jobs: - run: opam pin -n . - run: opam depext -yt tiny_httpd tiny_httpd_camlzip - run: opam install -t . --deps-only - - run: opam exec -- dune build + - run: opam exec -- dune build @install - run: opam exec -- dune runtest if: ${{ matrix.operating-system == 'unbuntu-latest' }} diff --git a/tests/dl-out.expect b/tests/dl-out.expect index 221be93f..d0e79081 100644 --- a/tests/dl-out.expect +++ b/tests/dl-out.expect @@ -1,2 +1,2 @@ -serve directory . on http://127.0.0.1:8083 +serve directory . on http://127.0.0.1:8084 0 0 52428800 data2 diff --git a/tests/download_chunked.sh b/tests/download_chunked.sh index f28d8234..6d8cbde6 100755 --- a/tests/download_chunked.sh +++ b/tests/download_chunked.sh @@ -1,11 +1,12 @@ #!/usr/bin/env sh SERVER=$1 -"$SERVER" . -p 8083 & +PORT=8084 +"$SERVER" . -p $PORT & sleep 0.1 -curl -N 'http://localhost:8083/foo_50' -o data2 \ +curl -N "http://localhost:${PORT}/foo_50" -o data2 \ -H 'Tranfer-encoding: chunked' kill %1 diff --git a/tests/dune b/tests/dune index 48277535..363933bf 100644 --- a/tests/dune +++ b/tests/dune @@ -3,6 +3,7 @@ (targets echo1.out) (deps (:bin ../examples/echo.exe)) (locks /port) + (enabled_if (= %{system} "linux")) (action (with-stdout-to %{targets} (run ./echo1.sh %{bin})))) (rule @@ -13,6 +14,7 @@ (targets sse_count.out) (deps (:bin ../examples/sse_server.exe)) (locks /port) + (enabled_if (= %{system} "linux")) (action (with-stdout-to %{targets} (run ./sse_count.sh %{bin})))) (rule @@ -23,6 +25,7 @@ (targets upload-out) (deps (:bin ../src/bin/http_of_dir.exe) foo_50) (locks /port) + (enabled_if (= %{system} "linux")) (action (with-stdout-to %{targets} (run ./upload_chunked.sh %{bin})))) @@ -34,6 +37,7 @@ (targets dl-out) (deps (:bin ../src/bin/http_of_dir.exe) foo_50) (locks /port) + (enabled_if (= %{system} "linux")) (action (with-stdout-to %{targets} (run ./download_chunked.sh %{bin})))) diff --git a/tests/echo1.expect b/tests/echo1.expect index 7579fba1..541334f7 100644 --- a/tests/echo1.expect +++ b/tests/echo1.expect @@ -1,9 +1,9 @@ -listening on http://127.0.0.1:8083 +listening on http://127.0.0.1:8085 echo: -{meth=GET; host=localhost:8083; +{meth=GET; host=localhost:8085; headers=[user-agent: test accept: */* - host: localhost:8083]; + host: localhost:8085]; path="/echo/?a=b&c=d"; body=""; path_components=["echo"]; query=["c","d";"a","b"]} (query: "c" = "d";"a" = "b") diff --git a/tests/echo1.sh b/tests/echo1.sh index e5a20500..5cad7b60 100755 --- a/tests/echo1.sh +++ b/tests/echo1.sh @@ -1,8 +1,9 @@ #!/usr/bin/env sh ECHO=$1 +PORT=8085 -"$ECHO" -p 8083 & +"$ECHO" -p $PORT & sleep 0.1 -curl -N 'http://localhost:8083/echo/?a=b&c=d' -H user-agent:test +curl -N "http://localhost:${PORT}/echo/?a=b&c=d" -H user-agent:test kill %1 diff --git a/tests/sse_count.expect b/tests/sse_count.expect index 19e6a28d..193cc0b9 100644 --- a/tests/sse_count.expect +++ b/tests/sse_count.expect @@ -1,4 +1,4 @@ -listening on http://localhost:8083/ +listening on http://localhost:8086/ data: 0 data: 1 diff --git a/tests/sse_count.sh b/tests/sse_count.sh index 89e0aa0b..6010ed37 100755 --- a/tests/sse_count.sh +++ b/tests/sse_count.sh @@ -1,9 +1,10 @@ #!/usr/bin/env sh SSE_SERVER=$1 +PORT=8086 -"$SSE_SERVER" -p 8083 & +"$SSE_SERVER" -p $PORT & sleep 0.1 -curl -N 'http://localhost:8083/count/10' -H user-agent:test +curl -N "http://localhost:${PORT}/count/10" -H user-agent:test kill %1 diff --git a/tests/upload-out.expect b/tests/upload-out.expect index 0ef0335f..7c5ca0cc 100644 --- a/tests/upload-out.expect +++ b/tests/upload-out.expect @@ -1,2 +1,2 @@ -serve directory . on http://127.0.0.1:8083 +serve directory . on http://127.0.0.1:8087 upload successful 0 0 52428800 data diff --git a/tests/upload_chunked.sh b/tests/upload_chunked.sh index a3d42563..ca64ac8a 100755 --- a/tests/upload_chunked.sh +++ b/tests/upload_chunked.sh @@ -3,11 +3,13 @@ rm data SERVER=$1 -"$SERVER" . -p 8083 --upload --max-upload 100000000000 & +PORT=8087 + +"$SERVER" . -p $PORT --upload --max-upload 100000000000 & sleep 0.1 -cat foo_50 | curl -N -X PUT http://localhost:8083/data --data-binary @- -H 'Transfer-Encoding: chunked' +cat foo_50 | curl -N -X PUT http://localhost:$PORT/data --data-binary @- -H 'Transfer-Encoding: chunked' kill %1 wc data