Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shorter path for inline-tests #11307

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions doc/changes/11307.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Use shorter path for inline-tests artifacts.
(@hhugo, #11307)
12 changes: 7 additions & 5 deletions src/dune_rules/dir_status.ml
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,15 @@ let directory_targets_of_library
| false -> Path.Build.Map.empty
| true ->
let dir_target =
let lib_name = Lib_name.Local.to_string (snd name) in
let name = sprintf "inline_test_runner_%s" lib_name in
let lib_name = snd name in
let inline_test_dir =
let inline_test_name = sprintf "%s.inline-tests" lib_name in
Path.Build.relative dir ("." ^ inline_test_name)
Path.Build.relative
dir
(Inline_tests_info.inline_test_dirname lib_name)
in
Path.Build.relative inline_test_dir (name ^ Js_of_ocaml.Ext.wasm_dir)
Path.Build.relative
inline_test_dir
(Inline_tests_info.inline_test_runner ^ Js_of_ocaml.Ext.wasm_dir)
in
Path.Build.Map.singleton dir_target loc)
>>= when_enabled ~dir ~enabled_if
Expand Down
21 changes: 10 additions & 11 deletions src/dune_rules/inline_tests.ml
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,13 @@ include Sub_system.Register_end_point (struct
in
let loc = lib.buildable.loc in
let lib_name = snd lib.name in
let inline_test_name =
sprintf "%s.inline-tests" (Lib_name.Local.to_string lib_name)
in
let inline_test_dir = Path.Build.relative dir ("." ^ inline_test_name) in
let obj_dir = Obj_dir.make_exe ~dir:inline_test_dir ~name:inline_test_name in
let name =
sprintf "inline_test_runner_%s" (Lib_name.Local.to_string (snd lib.name))
let inline_test_dir =
Path.Build.relative dir (Inline_tests_info.inline_test_dirname lib_name)
in
let runner_name = Inline_tests_info.inline_test_runner in
let obj_dir = Obj_dir.make_exe ~dir:inline_test_dir ~name:"t" in
let main_module =
let name = Module_name.of_string name in
let name = Module_name.of_string "main" in
Module.generated ~kind:Impl ~src_dir:inline_test_dir [ name ]
in
let modules = Modules.With_vlib.singleton_exe main_module in
Expand Down Expand Up @@ -214,7 +211,7 @@ include Sub_system.Register_end_point (struct
in
Exe.build_and_link
cctx
~program:{ name; main_module_name = Module.name main_module; loc }
~program:{ name = runner_name; main_module_name = Module.name main_module; loc }
~linkages
~link_args
~promote:None
Expand Down Expand Up @@ -271,7 +268,7 @@ include Sub_system.Register_end_point (struct
| Native | Best | Byte -> None
| Jsoo _ -> Some Jsoo_rules.runner
in
let exe = Path.build (Path.Build.relative inline_test_dir (name ^ ext)) in
let exe = Path.build (Path.Build.relative inline_test_dir (runner_name ^ ext)) in
let open Action_builder.O in
let+ action =
match custom_runner with
Expand Down Expand Up @@ -303,7 +300,9 @@ include Sub_system.Register_end_point (struct
| Jsoo Wasm ->
Action_builder.path
(Path.build
(Path.Build.relative inline_test_dir (name ^ Js_of_ocaml.Ext.wasm_dir)))
(Path.Build.relative
inline_test_dir
(runner_name ^ Js_of_ocaml.Ext.wasm_dir)))
in
Action.chdir (Path.build dir) action
in
Expand Down
6 changes: 6 additions & 0 deletions src/dune_rules/inline_tests_info.ml
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,9 @@ module Tests = struct
purposes *)
let encode _t = assert false
end

let inline_test_dirname lib_name =
sprintf ".%s.inline-tests" (Lib_name.Local.to_string lib_name)
;;

let inline_test_runner = "inline-test-runner"
3 changes: 3 additions & 0 deletions src/dune_rules/inline_tests_info.mli
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,6 @@ module Tests : sig

include Sub_system_info.S with type t := t
end

val inline_test_dirname : Lib_name.Local.t -> string
val inline_test_runner : string
8 changes: 4 additions & 4 deletions test/blackbox-tests/test-cases/inline_tests/parallel.t/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ First, build silently to avoid some noise
See that `test1/runtest`, which uses `fake_backend_1, only runs one inline test runner

$ dune build --display short @test1/runtest 2>&1 | grep alias
inline_test_runner_test_lib1 alias test1/runtest
inline-test-runner alias test1/runtest

See that `test2/runtest`, which uses `fake_backend_2`, runs one inline test runner per partition

$ dune build --display short @test2/runtest 2>&1 | grep alias
inline_test_runner_test_lib2 alias test2/runtest
inline_test_runner_test_lib2 alias test2/runtest
inline_test_runner_test_lib2 alias test2/runtest
inline-test-runner alias test2/runtest
inline-test-runner alias test2/runtest
inline-test-runner alias test2/runtest

See that we indeed have 3 partitions

Expand Down
4 changes: 2 additions & 2 deletions test/blackbox-tests/test-cases/inline_tests/simple.t
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
File "dune", line 9, characters 1-40:
9 | (inline_tests (backend backend_simple)))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Fatal error: exception File ".foo_simple.inline-tests/inline_test_runner_foo_simple.ml-gen", line 1, characters 40-46: Assertion failed
Fatal error: exception File ".foo_simple.inline-tests/main.ml-gen", line 1, characters 40-46: Assertion failed
[1]

The expected behavior for the following three tests is to output nothing: the tests are disabled or ignored.
Expand All @@ -41,5 +41,5 @@ The expected behavior for the following three tests is to output nothing: the te
File "dune", line 9, characters 1-40:
9 | (inline_tests (backend backend_simple)))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Fatal error: exception File ".foo_simple.inline-tests/inline_test_runner_foo_simple.ml-gen", line 1, characters 40-46: Assertion failed
Fatal error: exception File ".foo_simple.inline-tests/main.ml-gen", line 1, characters 40-46: Assertion failed
[1]
Loading