diff --git a/doc/changes/11307.md b/doc/changes/11307.md new file mode 100644 index 00000000000..e70ce55c132 --- /dev/null +++ b/doc/changes/11307.md @@ -0,0 +1,2 @@ +- Use shorter path for inline-tests artifacts. + (@hhugo, #11307) \ No newline at end of file diff --git a/src/dune_rules/dir_status.ml b/src/dune_rules/dir_status.ml index de7f19f1303..e627bc02ab6 100644 --- a/src/dune_rules/dir_status.ml +++ b/src/dune_rules/dir_status.ml @@ -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 diff --git a/src/dune_rules/inline_tests.ml b/src/dune_rules/inline_tests.ml index cb56097c2c7..947a35d4d23 100644 --- a/src/dune_rules/inline_tests.ml +++ b/src/dune_rules/inline_tests.ml @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/src/dune_rules/inline_tests_info.ml b/src/dune_rules/inline_tests_info.ml index 47e247aa7ba..3ba8e4bf738 100644 --- a/src/dune_rules/inline_tests_info.ml +++ b/src/dune_rules/inline_tests_info.ml @@ -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" diff --git a/src/dune_rules/inline_tests_info.mli b/src/dune_rules/inline_tests_info.mli index 2135df4aa88..b7747aac756 100644 --- a/src/dune_rules/inline_tests_info.mli +++ b/src/dune_rules/inline_tests_info.mli @@ -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 diff --git a/test/blackbox-tests/test-cases/inline_tests/parallel.t/run.t b/test/blackbox-tests/test-cases/inline_tests/parallel.t/run.t index 9333dbaf2c0..1db1f9b6326 100644 --- a/test/blackbox-tests/test-cases/inline_tests/parallel.t/run.t +++ b/test/blackbox-tests/test-cases/inline_tests/parallel.t/run.t @@ -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 diff --git a/test/blackbox-tests/test-cases/inline_tests/simple.t b/test/blackbox-tests/test-cases/inline_tests/simple.t index 33cafda4230..a9ae3faa78a 100644 --- a/test/blackbox-tests/test-cases/inline_tests/simple.t +++ b/test/blackbox-tests/test-cases/inline_tests/simple.t @@ -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. @@ -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]