Server behaviour tests, running on every platform (incl. Windows)#305
Draft
hhugo wants to merge 9 commits into
Draft
Server behaviour tests, running on every platform (incl. Windows)#305hhugo wants to merge 9 commits into
hhugo wants to merge 9 commits into
Conversation
8e4e356 to
33bd231
Compare
Cryptokit.Random.device_rng "/dev/urandom" fails at startup on Windows, which has no /dev/urandom. Use Cryptokit.Random.secure_rng, the platform's own CSPRNG. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
ocamlfind output carries a trailing CR on Windows, so package names did not match and base64 was reported as 'already loaded'. Trim each line. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Some signals (e.g. SIGPIPE) do not exist on Windows, where Sys.set_signal raises Invalid_argument. Wrap it so the server still starts there. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Lwt_io.length seeks the channel, which fails on Windows ('Lwt_io.length: seek failed'). Use Lwt_unix.LargeFile.stat for the Content-Length instead.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
0a163d9 to
0b3c816
Compare
When resolving a directory request whose filename ends with the platform separator (from Filename.concat dir ""): the trailing '\\' was not recognised, causing a spurious redirect; and check_symlinks_parent_directories walked up with Filename.dirname stopping only at '/', '.', or no_check_for, so on Windows it skipped no_check_for and looped forever at a drive root like 'D:\\' (where Filename.dirname is a fixed point), wedging the Lwt main thread. Accept the platform separator and stop at a dirname fixed point. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Serve mode needs a way to stop a running server gracefully -- on Windows killing the background process is unreliable. Keep the Unix command pipe (a FIFO), and on Windows (where mkfifo is unavailable) use an ordinary file that the server polls for commands; stop polling once a shutdown is requested. Add a client side: 'ocsigenserver --command CMD --command-pipe NAME' writes CMD to the pipe (FIFO) or appends it to the polled file, so a server can be controlled without a signal. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
0b3c816 to
f1b53e2
Compare
28ff5b5 to
e3363f7
Compare
conduit-lwt-unix sets SO_REUSEADDR on every listening socket, including AF_UNIX ones. That is a harmless no-op on Unix, but on Windows it makes the following bind fail with EOPNOTSUPP, so a server on a Unix-domain socket cannot start. Pin (via pin-depends) a conduit fork that skips SO_REUSEADDR for ADDR_UNIX, until the fix is released upstream. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add cram tests for core HTTP semantics, static-file and range-request serving, and several extensions (accesscontrol, authbasic, cors, outputfilter, redirectmod, rewritemod), plus serve-mode tests. The shared cram harness starts the server detached with logs to a file and stops it gracefully through its command pipe ('ocsigenserver --command shutdown'), so the server exits on its own -- this lets the tests run on every platform, including Windows, without leaving a process for dune's cram cleanup to hang on. The per-test servers are built by the project and passed to the cram tests as dependencies, so the test directories need no nested dune-project.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Run 'dune runtest' (with a timeout) on every job so the new tests are exercised on all platforms. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
e3363f7 to
dba829b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a suite of behaviour tests for the server and makes the whole suite — including the serve-mode HTTP tests — pass on every platform, including Windows in bytecode. Builds on the Windows-CI work in #253.
Tests
Ocsigen_rangeused to be inocsigen_cohttp.ml)Harness / CI
dune runtestis now wired into CI (it was never run before)server-test-helpers.shrewritten in POSIX sh (was bash-only, failed under dash); server logs go to a file to avoid non-deterministic interleavingocsigenserver --command shutdown) so they exit on their own — nothing is left for dune's cram cleanup to hang on, which lets the serve-mode tests run on Windows too(enabled_if (<> %{os_type} Win32))deflatemodtest.ml used pre-modernisation module names;serve.thad a spurious(no-eol)Windows portability fixes (needed to run the suite there)
Cryptokit.Random.secure_rng) instead of opening/dev/urandomSIGPIPE) that don't exist on WindowsContent-Lengthfromstatinstead ofLwt_io.length, which seeks and fails on Windowslocal_files: fix aFilename.dirnameinfinite loop at drive roots (e.g.D:\) that wedged the Lwt main thread on directory requests — this was the real cause of the directory-listing hangocamlfindoutput when computing builtin packagesCommand channel
--command CMD --command-pipe NAMEclient mode lets a running server be controlled (notably stopped) without a signalmkfifois unavailable), so graceful shutdown works everywhere with no platform-specific C codeA named-pipe variant of the command channel (plus a couple of changes that turned out unnecessary) is preserved on the
windows-serve-supportbranch.🤖 Generated with Claude Code