Skip to content

Test suite, step 1: unit tests for parameters and URLs, tests in CI - #911

Merged
balat merged 4 commits into
masterfrom
testsuite
Sep 27, 2026
Merged

balat merged 4 commits into
masterfrom
testsuite

Conversation

@balat

@balat balat commented Sep 27, 2026 •

Copy link
Copy Markdown
Member

First step of a test suite for Eliom, which only had two cram tests of the server ppx.

Content

  • test/unit: an Alcotest suite for pure functions (no site, no request, no server), run by dune runtest.
    • test_parameter: encoding of typed parameters into HTTP parameters and URL suffixes; decoding back (round trips, typing and wrong-parameter errors, optional values, sets, lists, sums, suffixes and their version without suffix); names used in forms; non-localized parameters. Decoding goes through Parameter_base.reconstruct_params_, since Parameter.reconstruct_params needs a request.
    • test_uri: relative paths, make_actual_path, assembly of URL components, protocol prefixes, and URLs of external services (parameters, suffixes, fragments, preapplied and non-localized parameters).
  • Test dependencies: alcotest, and ocsipersist-sqlite because a program linking eliom.server needs an ocsipersist backend.
  • CI: pins ocsipersist 3.1.2 (3.1.1 and 3.1.2 fix the lwt and OCaml bounds of ocsipersist-lib) and ocsipersist-sqlite 3.1.2, installs with --with-test, runs dune runtest -p eliom,eliom-compat. The ppx cram tests are attached to the eliom package so that they run with -p.

Each test was checked to fail when the code it covers is broken, by temporarily mutating parameter_base.shared.ml and eliom_uri.shared.ml.

Next steps (separate PRs)

  1. Remaining pure unit tests (cookies, wrapping, content, scopes, configuration, registration output), then tests with a site but no request.
  2. A harness that runs a test server on a Unix socket, driven by an OCaml client with one cookie jar per simulated browser.
  3. State: isolation between sessions, closing sessions, session groups, timeouts.
  4. Comet, Bus and React, through a native comet client.
  5. Other server features, ppx tests, client tests under node, then end-to-end tests in a browser.

3.1.1 and 3.1.2 fix the bounds of ocsipersist-lib on lwt (>= 5.7.0) and
OCaml (>= 4.14).
Alcotest suite in test/unit, run by dune runtest, covering the encoding of
typed parameters into HTTP parameters and URL suffixes, decoding back
(round trips, typing and wrong-parameter errors, optional values, sets,
lists, sums, suffixes and their version without suffix), the names used in
forms and non-localized parameters.

The tests use Parameter_base, whose types are concrete, since decoding
through Parameter needs a request. The test executable needs an
ocsipersist backend: ocsipersist-sqlite is added as a test dependency.
Cover what does not depend on a site or a request: relative paths,
make_actual_path, assembly of URL components, protocol prefixes, and URLs
of external services with parameters, suffixes, fragments, preapplied
parameters and non-localized parameters.
Install the test dependencies, pinning ocsipersist-sqlite 3.1.0 like
ocsipersist, and run dune runtest. The ppx cram tests are attached to the
eliom package so that they run with -p.
@balat
balat marked this pull request as ready for review September 27, 2026 11:27
@balat
balat merged commit b404aee into master Sep 27, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant