From 45d49f5dcc16c016bdf1cb481dfe985662d1f672 Mon Sep 17 00:00:00 2001 From: craff Date: Tue, 6 Dec 2022 18:18:39 -1000 Subject: [PATCH] progress on test ... --- examples/dune | 22 +++++++++++++++++++--- examples/run_test.sh | 13 +------------ examples/test_output.txt.expected | 26 -------------------------- src/domains/dune | 2 +- tests/dune | 28 +++++++++++++++++++++++++--- tests/echo1.expect | 2 +- tests/echo1.sh | 2 +- tests/sse_count.sh | 2 +- 8 files changed, 49 insertions(+), 48 deletions(-) diff --git a/examples/dune b/examples/dune index 790f07e6..db8d0451 100644 --- a/examples/dune +++ b/examples/dune @@ -7,7 +7,7 @@ (executable (name sse_server_domains) (modules sse_server_domains) - (enabled_if (>= %{ocaml_version} 5.00.0)) + (enabled_if (>= %{ocaml_version} 5.0.0)) (libraries tiny_httpd tiny_httpd_domains unix ptime ptime.clock.os)) (executable @@ -24,7 +24,7 @@ (executable (name echo_domains) (flags :standard -warn-error -a+8) - (enabled_if (>= %{ocaml_version} 5.00.0)) + (enabled_if (>= %{ocaml_version} 5.0.0)) (modules echo_domains vfs_domains) (libraries tiny_httpd tiny_httpd_camlzip tiny_httpd_domains)) @@ -34,7 +34,15 @@ (enabled_if (= %{system} "linux")) (package tiny_httpd) (action - (with-stdout-to %{targets} (run %{script})))) + (with-stdout-to %{targets} (run %{script} 8082)))) + +(rule + (targets test_output_domains.txt) + (deps (:script ./run_test.sh) ./sse_client.exe ./sse_server_domains.exe) + (enabled_if (and (= %{system} "linux") (>= %{ocaml_version} 5.0.0))) + (package tiny_httpd) + (action + (with-stdout-to %{targets} (run %{script} 8083)))) (rule (alias runtest) @@ -44,6 +52,14 @@ (action (diff test_output.txt.expected test_output.txt))) +(rule + (alias runtest) + (package tiny_httpd_domains) + (enabled_if (and (= %{system} "linux") (>= %{ocaml_version} 5.0.0))) + (deps test_output_domains.txt) + (action + (diff test_output_domains.txt.expected test_output_domains.txt))) + ; produce an embedded FS (rule (targets vfs.ml) diff --git a/examples/run_test.sh b/examples/run_test.sh index 1e4568f6..f4d81dfa 100755 --- a/examples/run_test.sh +++ b/examples/run_test.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -PORT=8082 +PORT=$1 ./sse_server.exe -p $PORT & PID=$! @@ -10,14 +10,3 @@ sleep 0.1 kill $PID echo "success" - -if [ -f ./sse_server_domains.exe ]; then - ./sse_server_domains.exe -p $PORT & - PID=$! - - sleep 0.1 - ./sse_client.exe -p $PORT --alarm=1 /count | tr -d '\r' || true - - kill $PID - echo "success with domains" -fi diff --git a/examples/test_output.txt.expected b/examples/test_output.txt.expected index 4a5d16f8..5adb0103 100644 --- a/examples/test_output.txt.expected +++ b/examples/test_output.txt.expected @@ -24,29 +24,3 @@ data: 8 data: 9 success -listening on http://localhost:8082/ -connect to 127.0.0.1:8082 -HTTP/1.1 200 OK -content-type: text/event-stream - -data: 0 - -data: 1 - -data: 2 - -data: 3 - -data: 4 - -data: 5 - -data: 6 - -data: 7 - -data: 8 - -data: 9 - -success with domains diff --git a/src/domains/dune b/src/domains/dune index 573cfd33..a69b9937 100644 --- a/src/domains/dune +++ b/src/domains/dune @@ -2,7 +2,7 @@ (library (name tiny_httpd_domains) (public_name tiny_httpd_domains) - (enabled_if (>= %{ocaml_version} 5.00.0)) + (enabled_if (>= %{ocaml_version} 5.0.0)) (synopsis "Allowing to use ocaml domains instead of theads") (flags :standard -safe-string -warn-error -a+8) (libraries tiny_httpd domainslib)) diff --git a/tests/dune b/tests/dune index 53bf6ea5..005f360b 100644 --- a/tests/dune +++ b/tests/dune @@ -5,7 +5,15 @@ (locks /port) (enabled_if (= %{system} "linux")) (package tiny_httpd_camlzip) - (action (with-stdout-to %{targets} (run ./echo1.sh %{bin})))) + (action (with-stdout-to %{targets} (run ./echo1.sh %{bin} 8085)))) + +(rule + (targets echo1_domains.out) + (deps (:bin ../examples/echo_domains.exe)) + (locks /port) + (enabled_if (and (= %{system} "linux") (>= %{ocaml_version} 5.0.0))) + (package tiny_httpd_domains) + (action (with-stdout-to %{targets} (run ./echo1.sh %{bin} 8095)))) (rule (alias runtest) @@ -13,19 +21,33 @@ (enabled_if (= %{system} "linux")) (action (diff echo1.expect echo1.out))) +(rule + (alias runtest) + (package tiny_httpd_camlzip) + (enabled_if (and (= %{system} "linux") (>= %{ocaml_version} 5.0.0))) + (action (diff echo1_domains.expect echo1_domains.out))) + (rule (targets sse_count.out) (deps (:bin ../examples/sse_server.exe)) (locks /port) (enabled_if (= %{system} "linux")) (package tiny_httpd) - (action (with-stdout-to %{targets} (run ./sse_count.sh %{bin})))) + (action (with-stdout-to %{targets} (run ./sse_count.sh %{bin} 8086)))) + +(rule + (targets sse_count_domains.out) + (deps (:bin ../examples/sse_server_domains.exe)) + (locks /port) + (enabled_if (and (= %{system} "linux") (>= %{ocaml_version} 5.0.0))) + (package tiny_httpd_domains) + (action (with-stdout-to %{targets} (run ./sse_count.sh %{bin} 8096)))) (rule (alias runtest) (package tiny_httpd) (enabled_if (= %{system} "linux")) - (action (diff sse_count.expect sse_count.out))) + (action (diff sse_count_domains.expect sse_count_domains.out))) (rule (targets upload-out) diff --git a/tests/echo1.expect b/tests/echo1.expect index 7473433c..56575a10 100644 --- a/tests/echo1.expect +++ b/tests/echo1.expect @@ -43,7 +43,7 @@ sub test_out.txt - (431b) + (209b) diff --git a/tests/echo1.sh b/tests/echo1.sh index b77cca57..c1e0dbcb 100755 --- a/tests/echo1.sh +++ b/tests/echo1.sh @@ -1,7 +1,7 @@ #!/usr/bin/env sh ECHO=$1 -PORT=8085 +PORT=$2 "$ECHO" -p $PORT & PID=$! diff --git a/tests/sse_count.sh b/tests/sse_count.sh index aebd6aea..fdca1325 100755 --- a/tests/sse_count.sh +++ b/tests/sse_count.sh @@ -1,7 +1,7 @@ #!/usr/bin/env sh SSE_SERVER=$1 -PORT=8086 +PORT=$2 "$SSE_SERVER" -p $PORT & PID=$!