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
10 changes: 10 additions & 0 deletions otherlibs/stdune/src/fpath.ml
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ let traverse
?(on_symlink = `Resolve)
?(enter_dir = fun ~dir:_ _fname -> true)
?(on_error = `Raise)
?(sort_entries = false)
()
=
let on_other =
Expand Down Expand Up @@ -300,6 +301,15 @@ let traverse
let acc = on_error ~dir e acc in
loop root dirs acc
| Ok entries ->
let entries =
if sort_entries
then
List.sort
~compare:(fun (name1, _kind1) (name2, _kind2) ->
String.compare name2 name1)
entries
else entries
in
let stack, acc =
List.fold_left entries ~init:(dirs, acc) ~f:(fun (stack, acc) (fname, kind) ->
match (kind : Unix.file_kind) with
Expand Down
1 change: 1 addition & 0 deletions otherlibs/stdune/src/fpath.mli
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ val traverse
-> ?enter_dir:(dir:string -> Filename.t -> bool)
-> ?on_error:
[ `Ignore | `Raise | `Call of dir:string -> Unix_error.Detailed.t -> 'acc -> 'acc ]
-> ?sort_entries:bool
-> unit
-> 'acc

Expand Down
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_
Comment thread
ElectreAAS marked this conversation as resolved.
| _ -> 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 || 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
19 changes: 19 additions & 0 deletions src/dune_pkg/dune
Original file line number Diff line number Diff line change
@@ -1,9 +1,28 @@
; OxCaml's ppx_expect v0.18 rejects [let%test_module] in favour of
; [module%test], but upstream ppx_expect has not released v0.18 yet.
; Until it does we must support both: pass the compatibility flag on
; OxCaml and nothing otherwise.

(rule
(enabled_if %{ocaml-config:ox})
(action
(write-file ppx-extra-flags "-inline-test-allow-let-test-module")))

(rule
(enabled_if
(not %{ocaml-config:ox}))
(action
(write-file ppx-extra-flags "")))

(library
(name dune_pkg)
(synopsis "[Internal] Dune's packaging support")
(foreign_stubs
(names md5_stubs)
(language c))
(inline_tests)
(preprocess
(pps ppx_expect -- %{read-lines:ppx-extra-flags}))
(libraries
stdune
lmdb
Expand Down
Loading
Loading