Forbid Path.append _ (In_build_dir _)
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
This commit is contained in:
parent
0ed758ef8a
commit
7c345b677f
|
@ -667,13 +667,14 @@ let append_local a b =
|
||||||
| External a -> external_ (External.relative a (Local.to_string b))
|
| External a -> external_ (External.relative a (Local.to_string b))
|
||||||
|
|
||||||
let append a b =
|
let append a b =
|
||||||
match kind b with
|
match b with
|
||||||
| External _ ->
|
| In_build_dir _ | External _ ->
|
||||||
Exn.code_error "Path.append called with non-local second path"
|
Exn.code_error "Path.append called with directory that's \
|
||||||
|
not in the source tree"
|
||||||
[ "a", sexp_of_t a
|
[ "a", sexp_of_t a
|
||||||
; "b", sexp_of_t b
|
; "b", sexp_of_t b
|
||||||
]
|
]
|
||||||
| Local b -> append_local a b
|
| In_source_tree b -> append_local a b
|
||||||
|
|
||||||
let basename t =
|
let basename t =
|
||||||
match kind t with
|
match kind t with
|
||||||
|
|
|
@ -243,12 +243,24 @@ Path.append Path.build_dir (Path.relative Path.root "foo")
|
||||||
|
|
||||||
Path.append Path.build_dir (Path.relative Path.build_dir "foo")
|
Path.append Path.build_dir (Path.relative Path.build_dir "foo")
|
||||||
[%%expect{|
|
[%%expect{|
|
||||||
- : Path.t = (In_build_dir "_build/foo")
|
Exception:
|
||||||
|
Code_error
|
||||||
|
(List
|
||||||
|
[Quoted_string
|
||||||
|
"Path.append called with directory that's not in the source tree";
|
||||||
|
List [Atom (A "a"); List [Atom (A "In_build_dir"); Atom (A ".")]];
|
||||||
|
List [Atom (A "b"); List [Atom (A "In_build_dir"); Atom (A "foo")]]]).
|
||||||
|}]
|
|}]
|
||||||
|
|
||||||
Path.append Path.root (Path.relative Path.build_dir "foo")
|
Path.append Path.root (Path.relative Path.build_dir "foo")
|
||||||
[%%expect{|
|
[%%expect{|
|
||||||
- : Path.t = (In_source_tree "_build/foo")
|
Exception:
|
||||||
|
Code_error
|
||||||
|
(List
|
||||||
|
[Quoted_string
|
||||||
|
"Path.append called with directory that's not in the source tree";
|
||||||
|
List [Atom (A "a"); List [Atom (A "In_source_tree"); Atom (A ".")]];
|
||||||
|
List [Atom (A "b"); List [Atom (A "In_build_dir"); Atom (A "foo")]]]).
|
||||||
|}]
|
|}]
|
||||||
|
|
||||||
Path.append Path.root (Path.relative Path.root "foo")
|
Path.append Path.root (Path.relative Path.root "foo")
|
||||||
|
@ -263,7 +275,13 @@ Path.append (Path.of_string "/root") (Path.relative Path.root "foo")
|
||||||
|
|
||||||
Path.append (Path.of_string "/root") (Path.relative Path.build_dir "foo")
|
Path.append (Path.of_string "/root") (Path.relative Path.build_dir "foo")
|
||||||
[%%expect{|
|
[%%expect{|
|
||||||
- : Path.t = (External "/root/_build/foo")
|
Exception:
|
||||||
|
Code_error
|
||||||
|
(List
|
||||||
|
[Quoted_string
|
||||||
|
"Path.append called with directory that's not in the source tree";
|
||||||
|
List [Atom (A "a"); List [Atom (A "External"); Atom (A "/root")]];
|
||||||
|
List [Atom (A "b"); List [Atom (A "In_build_dir"); Atom (A "foo")]]]).
|
||||||
|}]
|
|}]
|
||||||
|
|
||||||
Path.rm_rf (Path.of_string "/does/not/exist/foo/bar/baz")
|
Path.rm_rf (Path.of_string "/does/not/exist/foo/bar/baz")
|
||||||
|
|
Loading…
Reference in New Issue