Skip to content

Keep the logs in the build directory, not the source tree - #480

Merged
samoht merged 2 commits into
mirage:mainfrom
samoht:fix-log-root
Nov 12, 2026
Merged

samoht merged 2 commits into
mirage:mainfrom
samoht:fix-log-root

Conversation

@samoht

@samoht samoht commented Nov 10, 2026

Copy link
Copy Markdown
Member

The default log directory was $DUNE_SOURCEROOT/_build/_tests, which is in the source tree even when the build directory is elsewhere. With DUNE_BUILD_DIR and a read-only source tree, every test died with Unix_error (EACCES, "mkdir", ".../_build"), and a DUNE_SOURCEROOT left in the environment by dune exec -- sh sent the logs of unrelated runs there, or crashed:

Fatal error: exception Unix.Unix_error(Unix.EPERM, "mkdir", "/nonexistent")

Cram tests, which dune also runs with DUNE_SOURCEROOT, wrote their logs outside their sandbox.

Dune sets INSIDE_DUNE to the build context, as in _build/default. A test running in that context now logs to _tests next to it: _build/_tests by default, and the moved build directory otherwise. Elsewhere, as in a cram test, the logs go to _build/_tests of the current directory, as in 1.9.1.

@samoht
samoht force-pushed the fix-log-root branch 5 times, most recently from e6c273b to 8ef4360 Compare November 12, 2026 11:25
The default log directory was DUNE_SOURCEROOT/_build/_tests, which is
in the source tree even when the build directory is elsewhere. With
DUNE_BUILD_DIR and a read-only source tree, every test died with
Unix_error (EACCES, "mkdir", ".../_build"), and a DUNE_SOURCEROOT left
in the environment by `dune exec -- sh` sent the logs of unrelated runs
there, or crashed with EPERM. Cram tests, which dune also runs with
DUNE_SOURCEROOT, wrote their logs outside their sandbox.

Dune sets INSIDE_DUNE to the build context, as in _build/default. A
test running in that context now logs to _tests next to it:
_build/_tests by default, and the moved build directory otherwise.
Elsewhere, as in a cram test, the logs go to _build/_tests of the
current directory, as in 1.9.1. On Windows, INSIDE_DUNE mixes both
separators and getcwd uses only backslashes, so the two are compared
with one separator, ignoring case.
@samoht
samoht merged commit 44fa93b into mirage:main Nov 12, 2026
7 checks passed
@samoht
samoht deleted the fix-log-root branch November 12, 2026 12:44
jmid pushed a commit to ocaml/opam-repository that referenced this pull request Nov 17, 2026
CHANGES:

- Fix parallel test runs failing with `Failed 6 times to create symlink`, and
  a dangling `latest` link (mirage/alcotest#479, @samoht, fixes mirage/alcotest#471 and mirage/alcotest#472 in 1.10.0)
- Fix tests failing with `EACCES` on a read-only source tree or with
  `DUNE_BUILD_DIR` (mirage/alcotest#480, @samoht, fixes mirage/alcotest#471 in 1.10.0)
- Honour `ALCOTEST_SOURCE_CODE_POSITION` when set by the program before `run`
  (mirage/alcotest#481, @samoht, fixes mirage/alcotest#451 in 1.10.0)
- Fix slow runs of suites with many cases of the same name (mirage/alcotest#482, @samoht,
  fixes mirage/alcotest#451 in 1.10.0)
- Under Eio, point the failure locations added in 1.10.0 (mirage/alcotest#451) at the test,
  not at the scheduler (mirage/alcotest#484, fixes mirage/alcotest#478, @samoht, report by @talex5)
- Point a failed `check` in a helper at the `check`, as in 1.9.1, not at the
  test that calls the helper (mirage/alcotest#488, @samoht, fixes mirage/alcotest#451 in 1.10.0)
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