Repository navigation
Show the location of every failure - #451
Merged
Merged
Conversation
samoht
force-pushed
the
junit-location
branch
2 times, most recently
from
November 2, 2026 19:06
5f3e2ce to
b93ea0b
Compare
samoht
force-pushed
the
junit-location
branch
11 times, most recently
from
November 4, 2026 15:47
b58e845 to
5a68b38
Compare
samoht
force-pushed
the
junit-location
branch
from
November 4, 2026 16:30
5a68b38 to
12becb9
Compare
samoht
marked this pull request as ready for review
November 4, 2026 20:28
samoht
force-pushed
the
junit-location
branch
3 times, most recently
from
November 4, 2026 20:46
cf6db7a to
ffc8c4e
Compare
A failed check only showed where it failed when it had a position or was not a tail call, and an uncaught exception never did, although a test ending in check is the most common shape. test_case now records its caller, and an exception reports the line in the test body that raised.
samoht
force-pushed
the
junit-location
branch
from
November 5, 2026 07:51
ffc8c4e to
3370f2b
Compare
This was referenced Nov 5, 2026
mseri
pushed a commit
to ocaml/opam-repository
that referenced
this pull request
Nov 9, 2026
example/alcotest/QCheck_alcotest_test.expected does not have the `File ..., line ...` header that alcotest now prints for each failing test. The library itself works with alcotest 1.10.0, so the bound only applies with-test. From the alcotest 1.10.0 CHANGES: Show the file and line of every failing test, not only of a failing `check` (mirage/alcotest#451)
mseri
pushed a commit
to ocaml/opam-repository
that referenced
this pull request
Nov 9, 2026
alcotest/test/alcotest_report.expected has the location of a failed check at the start of its message, which alcotest now prints in the header of the failing test instead. The library itself works with alcotest 1.10.0, so the bound only applies with-test. From the alcotest 1.10.0 CHANGES: Show the file and line of every failing test, not only of a failing `check` (mirage/alcotest#451)
samoht
added a commit
to samoht/opam-repository
that referenced
this pull request
Nov 10, 2026
CHANGES: - Experimental: with `--junit` or `ALCOTEST_JUNIT=1`, write a JUnit XML report of each run to `junit/<name>-<time>-<id>.xml` of the log directory, with the `file` and `line` of each test, or of its failure (mirage/alcotest#449, mirage/alcotest#476, fixes mirage/alcotest#130, @samoht, report by @pbiggar) - Record the source file that calls `run`, and write it as the `file` of the `<testsuite>` of the JUnit report (mirage/alcotest#449, @samoht) - `Platform.S` now requires `timestamp` and `write_file` (mirage/alcotest#449, @samoht) - Under dune, keep the output of tests in `_build/_tests` of the workspace, where dune does not delete it, rather than in `_build/default`. With mirage/alcotest#472, each `dune test` adds its runs to `_build/_tests/run/<name>/<time>-<id>`, which gives a local history of test results (mirage/alcotest#471, @samoht) - Fix `alcotest-mirage`, which failed with `Assertion failed` in every run without `--verbose` since 1.5.0 (mirage/alcotest#473, @samoht) - Keep the logs of each run in `run/<name>/<time>-<id>`, where `<name>` is the name given to `run`, so that the runs of each test executable are listed in order. `latest` still points to the last run (mirage/alcotest#472, @samoht) - Fix the link named after each test executable, which did not always point to its last run. It is replaced by the `run/<name>` folder (mirage/alcotest#472, @samoht) - Fix a crash when the name of a `suite` or `group` is longer than a file name can be (mirage/alcotest#472, @samoht) - Fix log files hidden when the name of a `suite` or `group` starts with a dot (mirage/alcotest#472, @samoht) - Custom platforms: `prepare_log_trap` takes the name given to `run` and returns the folder of the run (mirage/alcotest#472, @samoht) - Fix creating a log directory written with `/` on Windows, as in `-o a/b`, which failed with `ENOENT` (mirage/alcotest#470, @samoht) - Add `test ?tags name f` and `suite name cases`, to write `suite "a" [ test "b" f ]` instead of `("a", [ test_case "b" `Quick f ])`. `tags` defaults to `` `Always `` (mirage/alcotest#468, @samoht, combinators suggested by @yawaramin in mirage/alcotest#393) - Add `?tags` to `group`: its cases only run when these tags hold as well as their own (mirage/alcotest#468, @samoht, API from mirage/alcotest#294 by @craigfe) - Add `group name cases`, a `test_case` that nests `cases` to any depth. They run in place, are reported as `parent.name` and are selected with `test '^parent\.name'` (mirage/alcotest#453, fixes mirage/alcotest#275, @samoht, API from mirage/alcotest#294 by @craigfe, dotted names suggested by @mjambon) - Show the file and line of every failing test, not only of a failing `check`. A failure in a helper points to the line of the test that calls it. `ALCOTEST_SOURCE_CODE_POSITION` still turns this off (mirage/alcotest#451, @samoht, based on `B0_testing` by @dbuenzli and the b0 programmers) - Print the message of a failing check once: `ASSERT` now only shows the checks that passed (mirage/alcotest#465, @samoht) - Add wasm_of_ocaml support (mirage/alcotest#461, mirage/alcotest#436, mirage/alcotest#437, @hhugo, @samoht and @mefyl) - Remove code made redundant by OCaml 4.14 (mirage/alcotest#460, @samoht) - Close a failed test's log file when printing it raises, instead of leaking the file descriptor (mirage/alcotest#460, @samoht) - Remove the `alcotest-js` package, which had no code and only added dependencies. To test with js_of_ocaml, depend on `js_of_ocaml-compiler` directly (mirage/alcotest#463, @samoht) - Require OCaml 4.14 and replace `uutf` with the stdlib UTF-8 decoder. Test names with invalid UTF-8 can get a different log file name (mirage/alcotest#456, @samoht) - Print valid UTF-8 as is in `string` failures, when the output supports it (mirage/alcotest#456, fixes mirage/alcotest#408, @samoht, report by @feverdreme, suggestion by @lindig) - Add `iarray`, a testable for `Iarray.t`, available from OCaml 5.4 (mirage/alcotest#455, fixes mirage/alcotest#434, @samoht, report by @JanBeh) - Fix UTF-8 locale detection, which never matched since 1.8.0, so `Fmt.if_utf_8` printers always took the non-UTF-8 branch. `LC_ALL` now overrides `LC_CTYPE` and `LANG`, as in POSIX, and `UTF8` also counts (mirage/alcotest#457, @samoht) - Recognise `Alcotest.skip` and failed checks in `alcotest-async` tests: Async wrapped the exceptions, so a skip counted as a failure (mirage/alcotest#278, @vbmithr) - Make `alcotest-async` unavailable on Windows, so that ocaml-ci tests the other packages there (mirage/alcotest#454, @samoht, suggested by @mtelvers) - Remove stdlib-shims and ocaml-syntax-shims (mirage/alcotest#452, @copy) - Update ocamlformat to 0.29.0 (mirage/alcotest#450, @samoht) - Fix and modernise CI (mirage/alcotest#445, mirage/alcotest#446, mirage/alcotest#436, mirage/alcotest#407, @samoht, @hhugo and @MisterDA, report by @edwintorok and @ngorogiannis) - Add `uchar`, a testable for `Uchar.t` (mirage/alcotest#435, @emengd, review by @dinosaure) - Fix the `success` count in `--json` output, which included failures (mirage/alcotest#432, fixes mirage/alcotest#431, @1zumiSagiri, review by @MisterDA) - Add conditions on tests: `test_case` and test tuples accept `` `Tag ``, `` `And ``, `` `Or ``, `` `Not `` and `` `Always ``, also as `Tag` combinators, which hold in a context set by a new `--tags` option or `ALCOTEST_TAGS`, as with Go build tags. A new `tags` subcommand lists them. `speed_level` is now an alias of the new `tag` type, which breaks code matching on it exhaustively or restating it as `` [ `Quick | `Slow ] `` (mirage/alcotest#448, fixes mirage/alcotest#124, mirage/alcotest#151 and mirage/alcotest#316, @samoht, report by @hannesm and @arvidj) - Preserve absolute log directories: `mkdir_p` turned `/foo` into `//foo`, which fails with `EROFS` on Cygwin (mirage/alcotest#405, fixes mirage/alcotest#404, @bbonf, review by @MisterDA and @samoht) - Allow callers to override `and_exit` and `record_backtrace` in the `test` subcommand (mirage/alcotest#439, fixes mirage/alcotest#438, @edwintorok) - Keep `Unix.stdout` and `Unix.stderr` valid during tests on Windows (mirage/alcotest#444, fixes mirage/alcotest#443, @ngorogiannis) - Test `alcotest-async` exception handling (mirage/alcotest#279, @craigfe) - Add an `alcotest-async` example (mirage/alcotest#458, mirage/alcotest#421, @dannywillems)
This was referenced Nov 12, 2026
samoht
added a commit
that referenced
this pull request
Nov 13, 2026
Since #451, a failure is located at the outermost frame of the test body, so a check in a helper called by the test reported the line of the call to the helper. 1.9.1 reported the line of the check, and Test.check still documents that Alcotest guesses the location of the check. A failed check now takes the innermost frame before Alcotest; other exceptions keep the line of the test body. Seen in owl 1.1, whose test_rough_cdf_matches reported line 779 (the List.iter) instead of line 757 (the check).
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)
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.
A failed
checkonly shows where it failed when given a position or when it is not a tail call, and an uncaught exception never does. Every failure now starts withFile "x.ml", line N, character C:, read from the backtrace or else from thetest_caseline.This replaces
Callsite_loc. Acheckin a helper is reported at the line in the test that calls the helper, not inside the helper, and acheckunderList.iterno longer points intolist.ml.ALCOTEST_SOURCE_CODE_POSITION=falseturns locations off, except a position the user gave.