dune/test/unit-tests/action.mlt

44 lines
1.1 KiB
Plaintext
Raw Normal View History

2017-05-28 01:46:07 +00:00
(* -*- tuareg -*- *)
#warnings "-40";;
open Dune;;
2017-05-28 01:46:07 +00:00
open Import;;
open Action.Infer.Outcome;;
Stdune.Path.set_build_dir (Path.Kind.of_string "_build");;
2017-05-28 01:46:07 +00:00
let p = Path.of_string;;
2017-05-31 09:25:19 +00:00
let infer (a : Action.t) =
2017-05-28 01:46:07 +00:00
let x = Action.Infer.infer a in
(List.map (Path.Set.to_list x.deps) ~f:Path.to_string,
List.map (Path.Set.to_list x.targets) ~f:Path.to_string)
2017-05-28 01:46:07 +00:00
[%%expect{|
- : unit = ()
val p : ?error_loc:Usexp.Loc.t -> string -> Path.t = <fun>
val infer : Action.t -> string list * string list = <fun>
2017-05-28 01:46:07 +00:00
|}]
infer (Copy (p "a", p "b"));;
[%%expect{|
- : string list * string list = (["a"], ["b"])
|}]
infer (Progn
[ Copy (p "a", p "b")
; Copy (p "b", p "c")
]);;
[%%expect{|
- : string list * string list = (["a"], ["b"; "c"])
|}]
2017-05-31 09:20:33 +00:00
(* CR-someday jdimino: ideally "b" should be treated as a non-buildable targets. As long
as [rename] is not available in the DSL given to user, we don't need to care about this
too much. *)
2017-05-28 01:46:07 +00:00
infer (Progn
[ Copy (p "a", p "b")
; Rename (p "b", p "c")
]);;
[%%expect{|
2017-05-31 09:20:33 +00:00
- : string list * string list = (["a"], ["b"; "c"])
2017-05-28 01:46:07 +00:00
|}]