Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions bin/runtest.ml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ let runtest_term =
let+ res = Action_builder.of_memo (disambiguate_test_name dir) in
[ context ], res
| In_source_dir dir ->
(* We need to adjust the path here to make up for the current working directory. *)
let { Workspace_root.to_cwd; _ } = Common.root common in
let dir =
Path.Source.L.relative Path.Source.root (to_cwd @ Path.Source.explode dir)
in
let+ res = Action_builder.of_memo (disambiguate_test_name dir) in
contexts, res
| In_private_context _ | In_install_dir _ ->
Expand Down
2 changes: 2 additions & 0 deletions doc/changes/12251.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Fix the interpretation of paths in `dune runtest` when running from within a
subdirectory. (#12251, fixes #12250, @Alizter)
35 changes: 35 additions & 0 deletions test/blackbox-tests/test-cases/runtest-cmd-subdir.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
Reproduction case for https://github.com/ocaml/dune/issues/12250

$ cat > dune-workspace <<EOF
> (lang dune 3.19)
> EOF

$ cat > dune-project <<EOF
> (lang dune 3.19)
> EOF

$ mkdir -p somelib/my/path
$ cat > somelib/my/path/test.t <<EOF
> $ echo hi
> EOF

$ dune runtest somelib/my/path/
File "somelib/my/path/test.t", line 1, characters 0-0:
Error: Files _build/default/somelib/my/path/test.t and
_build/default/somelib/my/path/test.t.corrected differ.
[1]

dune runtest should be able to run in a subdirectory and the arguments passed
to it should be adjusted accordingly.

This is currently not the case:

$ (cd somelib && unset INSIDE_DUNE; dune runtest --diff-command=- my/path/)
Entering directory '$TESTCASE_ROOT'
File "somelib/my/path/test.t", line 1, characters 0-0:
Error: Files _build/default/somelib/my/path/test.t and
_build/default/somelib/my/path/test.t.corrected differ.
Leaving directory '$TESTCASE_ROOT'
[1]


Loading