Skip to content

Commit 31de016

Browse files
committed
refactor(runtest): refine types for runtest request
Signed-off-by: Ali Caglayan <[email protected]>
1 parent b202280 commit 31de016

File tree

4 files changed

+16
-19
lines changed

4 files changed

+16
-19
lines changed

bin/build.ml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,11 @@ let poll_handling_rpc_build_requests ~(common : Common.t) ~config =
9898
match kind with
9999
| Build targets ->
100100
Target.interpret_targets (Common.root common) config setup targets
101-
| Runtest dir_or_cram_test_paths ->
102-
Runtest_common.make_request ~dir_or_cram_test_paths ~to_cwd:root.to_cwd setup
101+
| Runtest test_paths ->
102+
Runtest_common.make_request
103+
~contexts:setup.contexts
104+
~to_cwd:root.to_cwd
105+
~test_paths
103106
in
104107
run_build_system ~common ~request, outcome)
105108
;;

bin/runtest.ml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,15 @@ let runtest_info =
3636
let runtest_term =
3737
let name = Arg.info [] ~docv:"TEST" in
3838
let+ builder = Common.Builder.term
39-
and+ dir_or_cram_test_paths = Arg.(value & pos_all string [ "." ] name) in
39+
and+ test_paths = Arg.(value & pos_all string [ "." ] name) in
4040
let common, config = Common.init builder in
4141
match Dune_util.Global_lock.lock ~timeout:None with
4242
| Ok () ->
43-
Build.run_build_command
44-
~common
45-
~config
46-
~request:
47-
(Runtest_common.make_request
48-
~dir_or_cram_test_paths
49-
~to_cwd:(Common.root common).to_cwd)
43+
Build.run_build_command ~common ~config ~request:(fun setup ->
44+
Runtest_common.make_request
45+
~contexts:setup.contexts
46+
~to_cwd:(Common.root common).to_cwd
47+
~test_paths)
5048
| Error lock_held_by ->
5149
Scheduler.go_without_rpc_server ~common ~config (fun () ->
5250
let open Fiber.O in
@@ -56,7 +54,7 @@ let runtest_term =
5654
~lock_held_by
5755
builder
5856
Dune_rpc.Procedures.Public.runtest
59-
dir_or_cram_test_paths
57+
test_paths
6058
>>| Rpc.Rpc_common.wrap_build_outcome_exn ~print_on_success:true)
6159
;;
6260

bin/runtest_common.ml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,8 @@ let disambiguate_test_name path =
7575
| None -> explain_unsuccessful_search path ~parent_dir))
7676
;;
7777

78-
let make_request ~dir_or_cram_test_paths ~to_cwd (setup : Import.Main.build_system) =
79-
let contexts = setup.contexts in
80-
List.map dir_or_cram_test_paths ~f:(fun dir ->
78+
let make_request ~contexts ~to_cwd ~test_paths =
79+
List.map test_paths ~f:(fun dir ->
8180
let dir = Path.of_string dir |> Path.Expert.try_localize_external in
8281
let open Action_builder.O in
8382
let* contexts, alias_kind =

bin/runtest_common.mli

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
open Import
22

3-
(** [make_request ~dir_or_cram_test_paths ~to_cwd] returns a function suitable
4-
for passing to [Build_cmd.run_build_system] which runs the tests referred
5-
to by the elements of [dir_or_cram_test_paths]. *)
63
val make_request
7-
: dir_or_cram_test_paths:string list
4+
: contexts:Context.t list
85
-> to_cwd:string list
9-
-> Dune_rules.Main.build_system
6+
-> test_paths:string list
107
-> unit Action_builder.t

0 commit comments

Comments
 (0)