Skip to content
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
1 change: 1 addition & 0 deletions otherlibs/stdune/src/path.ml
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,7 @@ let is_descendant t ~of_ =
match t, of_ with
| In_source_tree t, In_source_tree of_ -> Source0.is_descendant t ~of_
| In_build_dir t, In_build_dir of_ -> Build.is_descendant t ~of_
| External t, External of_ -> External.is_descendant t ~of_
| _ -> false
;;

Expand Down
2 changes: 1 addition & 1 deletion otherlibs/stdune/src/path_external.ml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ include (
let to_string_maybe_quoted t = String.maybe_quoted (to_string t)

let is_descendant b ~of_:a =
is_root a || String.starts_with ~prefix:(to_string a ^ "/") (to_string b)
is_root a || equal a b || String.starts_with ~prefix:(to_string a ^ "/") (to_string b)
;;

module Map = String.Map
Expand Down
20 changes: 4 additions & 16 deletions otherlibs/stdune/test/path_tests.ml
Original file line number Diff line number Diff line change
Expand Up @@ -129,18 +129,12 @@ true

let%expect_test _ =
is_descendant (e "/foo/bar") ~of_:(e "/foo");
[%expect
{|
false
|}]
[%expect {| true |}]
;;

let%expect_test _ =
is_descendant (e "/foo/bar") ~of_:(e "/foo/bar");
[%expect
{|
false
|}]
[%expect {| true |}]
;;

let%expect_test _ =
Expand All @@ -153,18 +147,12 @@ false

let%expect_test _ =
is_descendant (e "/foo/bar/") ~of_:(e "/foo/bar");
[%expect
{|
false
|}]
[%expect {| true |}]
;;

let%expect_test _ =
is_descendant (e "/foo/bar") ~of_:(e "/");
[%expect
{|
false
|}]
[%expect {| true |}]
;;

let%expect_test _ =
Expand Down
Loading