From 7580b8e16fc2b62b7937ade22b79f07e346149d7 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Sat, 12 May 2018 08:37:34 +0700 Subject: [PATCH 01/13] Detect circular sym links Fix #764 --- src/file_tree.ml | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/file_tree.ml b/src/file_tree.ml index 58844479..eb3c8ae0 100644 --- a/src/file_tree.ml +++ b/src/file_tree.ml @@ -156,7 +156,16 @@ let ignore_file fn ~is_directory = (fn.[0] = '.' && fn.[1] = '#') let load ?(extra_ignored_subtrees=Path.Set.empty) path = - let rec walk path ~project ~ignored : Dir.t = + let rec walk seen_real_paths path ~project ~ignored : Dir.t = + let realpath = + try Path.of_string (Unix.readlink (Path.to_string path)) + with Unix.Unix_error (_, _, _) -> path + in + if List.mem realpath ~set:seen_real_paths then + die "Path %s has already been scanned. \ + Cannot scan it again through symlink %s" + (Path.to_string_maybe_quoted realpath) + (Path.to_string_maybe_quoted path); let contents = lazy ( let files, sub_dirs = Path.readdir path @@ -209,7 +218,8 @@ let load ?(extra_ignored_subtrees=Path.Set.empty) path = || String.Set.mem ignored_subdirs fn || Path.Set.mem extra_ignored_subtrees path in - String.Map.add acc fn (walk path ~project ~ignored)) + String.Map.add acc fn + (walk (realpath :: seen_real_paths) path ~project ~ignored)) in { Dir. files; sub_dirs; dune_file; project }) in @@ -218,7 +228,7 @@ let load ?(extra_ignored_subtrees=Path.Set.empty) path = ; ignored } in - let root = walk path ~ignored:false ~project:None in + let root = walk [] path ~ignored:false ~project:None in let dirs = Hashtbl.create 1024 in Hashtbl.add dirs Path.root root; { root; dirs } From c1f81bef64566ad98ee18d5d6b1e8f877a8a088e Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Sat, 12 May 2018 18:23:08 +0700 Subject: [PATCH 02/13] Add test for #764 --- test/blackbox-tests/dune.inc | 12 ++++++++++++ test/blackbox-tests/gen_tests.ml | 1 + test/blackbox-tests/test-cases/github764/run.t | 3 +++ 3 files changed, 16 insertions(+) create mode 100644 test/blackbox-tests/test-cases/github764/run.t diff --git a/test/blackbox-tests/dune.inc b/test/blackbox-tests/dune.inc index 3c9cf7b5..6863fa98 100644 --- a/test/blackbox-tests/dune.inc +++ b/test/blackbox-tests/dune.inc @@ -217,6 +217,16 @@ test-cases/github761 (progn (run ${exe:cram.exe} -test run.t) (diff? run.t run.t.corrected)))))) +(alias + ((name github764) + (deps ((package dune) (files_recursively_in test-cases/github764))) + (action + (chdir + test-cases/github764 + (progn + (run ${exe:cram.exe} -skip-platforms win -test run.t) + (diff? run.t run.t.corrected)))))) + (alias ((name ignored_subdirs) (deps ((package dune) (files_recursively_in test-cases/ignored_subdirs))) @@ -511,6 +521,7 @@ (alias github734) (alias github759) (alias github761) + (alias github764) (alias ignored_subdirs) (alias include-loop) (alias inline_tests) @@ -567,6 +578,7 @@ (alias github734) (alias github759) (alias github761) + (alias github764) (alias ignored_subdirs) (alias include-loop) (alias inline_tests) diff --git a/test/blackbox-tests/gen_tests.ml b/test/blackbox-tests/gen_tests.ml index 505bc1e0..085c22b6 100644 --- a/test/blackbox-tests/gen_tests.ml +++ b/test/blackbox-tests/gen_tests.ml @@ -104,6 +104,7 @@ let exclusions = ; make "menhir"~external_deps:true ; make "utop"~external_deps:true ; make "configurator" ~skip_platforms:[Win] + ; make "github764" ~skip_platforms:[Win] ] let all_tests = lazy ( diff --git a/test/blackbox-tests/test-cases/github764/run.t b/test/blackbox-tests/test-cases/github764/run.t new file mode 100644 index 00000000..97e12f41 --- /dev/null +++ b/test/blackbox-tests/test-cases/github764/run.t @@ -0,0 +1,3 @@ + $ ln -s . x && ln -s . y && jbuilder build + Path . has already been scanned. Cannot scan it again through symlink x + [1] From 540a22315b554de512bcb916442f0e8f65ada5dc Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Tue, 15 May 2018 13:11:41 +0700 Subject: [PATCH 03/13] Refactor symlink following Correctly resolve relative symlinks and add better error handling. Also move the logic to the path module. --- src/file_tree.ml | 5 +---- src/stdune/path.ml | 18 ++++++++++++++++++ src/stdune/path.mli | 2 ++ 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/file_tree.ml b/src/file_tree.ml index eb3c8ae0..cc993f00 100644 --- a/src/file_tree.ml +++ b/src/file_tree.ml @@ -157,10 +157,7 @@ let ignore_file fn ~is_directory = let load ?(extra_ignored_subtrees=Path.Set.empty) path = let rec walk seen_real_paths path ~project ~ignored : Dir.t = - let realpath = - try Path.of_string (Unix.readlink (Path.to_string path)) - with Unix.Unix_error (_, _, _) -> path - in + let realpath = Path.follow_symlink path in if List.mem realpath ~set:seen_real_paths then die "Path %s has already been scanned. \ Cannot scan it again through symlink %s" diff --git a/src/stdune/path.ml b/src/stdune/path.ml index ec8fd4ad..6794bb5f 100644 --- a/src/stdune/path.ml +++ b/src/stdune/path.ml @@ -521,3 +521,21 @@ let extension = Filename.extension let pp ppf t = Format.pp_print_string ppf (to_string t) +let follow_symlink p = + match ( + match Unix.readlink (to_string p) with + | p -> Some p + | exception Unix.Unix_error (Unix.EINVAL, "readlink", _) -> None + ) with + | None -> p + | Some realpath -> + if not (is_local realpath) then + of_string realpath + else + match parent p with + | Some p -> relative p realpath + | None -> + Exn.code_error "follow_symlink: p cannot be a symlink to root" + [ "p", sexp_of_t p + ; "realpath", sexp_of_t realpath ] + diff --git a/src/stdune/path.mli b/src/stdune/path.mli index 44663266..53e34816 100644 --- a/src/stdune/path.mli +++ b/src/stdune/path.mli @@ -143,3 +143,5 @@ val pp : Format.formatter -> t -> unit val build_dir_exists : unit -> bool val ensure_build_dir_exists : unit -> unit + +val follow_symlink : t -> t From c9916f4a7649e683f5ac298d1fd03ea0b677f73a Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Tue, 15 May 2018 17:21:30 +0700 Subject: [PATCH 04/13] Add some more test cases for symlinks --- test/blackbox-tests/test-cases/github764/run.t | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/blackbox-tests/test-cases/github764/run.t b/test/blackbox-tests/test-cases/github764/run.t index 97e12f41..e1573a04 100644 --- a/test/blackbox-tests/test-cases/github764/run.t +++ b/test/blackbox-tests/test-cases/github764/run.t @@ -1,3 +1,5 @@ - $ ln -s . x && ln -s . y && jbuilder build + $ mkdir -p c1 && cd c1 && ln -s . x && ln -s . y && jbuilder build Path . has already been scanned. Cannot scan it again through symlink x [1] + $ mkdir -p c2 && cd c2 && ln -s x ../../ && jbuilder build + $ mkdir -p c3 && cd c3 && ln -s x y && ln -s y x && jbuilder build From ac078fcdbbf75b013832b572c510f25ca495a41a Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Tue, 15 May 2018 19:29:20 +0700 Subject: [PATCH 05/13] add cycle and max depth to symlink following --- src/file_tree.ml | 11 ++++++++++- src/stdune/path.ml | 28 +++++++++++++++++++++------- src/stdune/path.mli | 4 +++- 3 files changed, 34 insertions(+), 9 deletions(-) diff --git a/src/file_tree.ml b/src/file_tree.ml index cc993f00..1e7455bb 100644 --- a/src/file_tree.ml +++ b/src/file_tree.ml @@ -157,7 +157,16 @@ let ignore_file fn ~is_directory = let load ?(extra_ignored_subtrees=Path.Set.empty) path = let rec walk seen_real_paths path ~project ~ignored : Dir.t = - let realpath = Path.follow_symlink path in + let realpath = + Path.follow_symlink path + |> Result.map_error ~f:(function + | `Maximum_depth_exceeded -> + die "maximum symlink depth exceeded while scanning %s" + (Path.to_string_maybe_quoted path) + | `Cycle_detected -> + die "cycle detected while scanning %s" + (Path.to_string_maybe_quoted path)) + |> Result.ok_exn in if List.mem realpath ~set:seen_real_paths then die "Path %s has already been scanned. \ Cannot scan it again through symlink %s" diff --git a/src/stdune/path.ml b/src/stdune/path.ml index 6794bb5f..cda051d2 100644 --- a/src/stdune/path.ml +++ b/src/stdune/path.ml @@ -522,13 +522,27 @@ let extension = Filename.extension let pp ppf t = Format.pp_print_string ppf (to_string t) let follow_symlink p = - match ( - match Unix.readlink (to_string p) with - | p -> Some p - | exception Unix.Unix_error (Unix.EINVAL, "readlink", _) -> None - ) with - | None -> p - | Some realpath -> + let readlink fn = + match Unix.readlink fn with + | exception Unix.Unix_error ((EINVAL | ENOENT), "readlink", _) -> None + | p -> Some p in + match readlink p with + | None -> Result.Ok p + | Some p -> + let rec follow n fn = + if n = 0 then + Result.Error `Maximum_depth_exceeded + else + match readlink fn with + | None -> Result.Ok fn + | Some p -> + if p = fn then + Result.Error `Cycle_detected + else + follow (pred n) p + in + let open Result.O in + follow 256 (to_string p) >>| fun realpath -> if not (is_local realpath) then of_string realpath else diff --git a/src/stdune/path.mli b/src/stdune/path.mli index 53e34816..a5854b9e 100644 --- a/src/stdune/path.mli +++ b/src/stdune/path.mli @@ -144,4 +144,6 @@ val build_dir_exists : unit -> bool val ensure_build_dir_exists : unit -> unit -val follow_symlink : t -> t +val follow_symlink + : t + -> (t, [ `Cycle_detected | `Maximum_depth_exceeded ]) Result.t From 241ec87a2b64aeb43c2ce1a9588f0923942bebdc Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Tue, 15 May 2018 19:42:33 +0700 Subject: [PATCH 06/13] Add test for symlinking outside workspace --- test/blackbox-tests/test-cases/github764/run.t | 1 + test/blackbox-tests/test-cases/github764/sample-exe/dune | 2 ++ test/blackbox-tests/test-cases/github764/sample-exe/foo.ml | 1 + 3 files changed, 4 insertions(+) create mode 100644 test/blackbox-tests/test-cases/github764/sample-exe/dune create mode 100644 test/blackbox-tests/test-cases/github764/sample-exe/foo.ml diff --git a/test/blackbox-tests/test-cases/github764/run.t b/test/blackbox-tests/test-cases/github764/run.t index e1573a04..ca49d8e3 100644 --- a/test/blackbox-tests/test-cases/github764/run.t +++ b/test/blackbox-tests/test-cases/github764/run.t @@ -3,3 +3,4 @@ [1] $ mkdir -p c2 && cd c2 && ln -s x ../../ && jbuilder build $ mkdir -p c3 && cd c3 && ln -s x y && ln -s y x && jbuilder build + $ cd symlink-outside-root && ln -s ../sample-exe sample && jbuilder exec --root . -- sample/foo.exe diff --git a/test/blackbox-tests/test-cases/github764/sample-exe/dune b/test/blackbox-tests/test-cases/github764/sample-exe/dune new file mode 100644 index 00000000..dab7cb21 --- /dev/null +++ b/test/blackbox-tests/test-cases/github764/sample-exe/dune @@ -0,0 +1,2 @@ +(executable + ((name foo))) diff --git a/test/blackbox-tests/test-cases/github764/sample-exe/foo.ml b/test/blackbox-tests/test-cases/github764/sample-exe/foo.ml new file mode 100644 index 00000000..d35be9f1 --- /dev/null +++ b/test/blackbox-tests/test-cases/github764/sample-exe/foo.ml @@ -0,0 +1 @@ +let () = print_endline "foo" From 2033b3498329ec02d4c9001305ead6ba30cf523f Mon Sep 17 00:00:00 2001 From: Jeremie Dimino Date: Wed, 16 May 2018 12:29:32 +0100 Subject: [PATCH 07/13] Update tests - remove tests that were creating files outside the test directory - add tests with cycles longer than 1 --- .../blackbox-tests/test-cases/github764/run.t | 30 ++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/test/blackbox-tests/test-cases/github764/run.t b/test/blackbox-tests/test-cases/github764/run.t index ca49d8e3..620f6404 100644 --- a/test/blackbox-tests/test-cases/github764/run.t +++ b/test/blackbox-tests/test-cases/github764/run.t @@ -1,6 +1,28 @@ - $ mkdir -p c1 && cd c1 && ln -s . x && ln -s . y && jbuilder build + $ rm -rf x c* symlink* + + $ mkdir -p c1 + $ cd c1 && ln -s . x + $ cd c1 && ln -s . y + $ cd c1 && dune build Path . has already been scanned. Cannot scan it again through symlink x [1] - $ mkdir -p c2 && cd c2 && ln -s x ../../ && jbuilder build - $ mkdir -p c3 && cd c3 && ln -s x y && ln -s y x && jbuilder build - $ cd symlink-outside-root && ln -s ../sample-exe sample && jbuilder exec --root . -- sample/foo.exe + + $ mkdir -p c2/{a,b} + $ cd c2 && ln -s ../b a/x + $ cd c2 && ln -s ../a b/x + $ cd c2 && dune build + Path a has already been scanned. Cannot scan it again through symlink a/x/x + [1] + + $ mkdir symlink-outside-root + $ cd symlink-outside-root && ln -s ../sample-exe sample + $ cd symlink-outside-root && jbuilder exec --root . -- sample/foo.exe + foo + + $ mkdir -p symlink-outside-root2/{root,other/{a,b}} + $ cd symlink-outside-root2 && ln -s ../b other/a/x + $ cd symlink-outside-root2 && ln -s ../a other/b/x + $ cd symlink-outside-root2 && ln -s ../other root/src + $ cd symlink-outside-root2/root && dune build + Path b has already been scanned. Cannot scan it again through symlink src/a/x/x/x + [1] From 3a2e136e5ca716fdc9c65e1f189bb41414dcb4e3 Mon Sep 17 00:00:00 2001 From: Jeremie Dimino Date: Wed, 16 May 2018 13:54:12 +0100 Subject: [PATCH 08/13] Add a more complex test --- test/blackbox-tests/test-cases/github764/run.t | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/blackbox-tests/test-cases/github764/run.t b/test/blackbox-tests/test-cases/github764/run.t index 620f6404..a70e5675 100644 --- a/test/blackbox-tests/test-cases/github764/run.t +++ b/test/blackbox-tests/test-cases/github764/run.t @@ -26,3 +26,10 @@ $ cd symlink-outside-root2/root && dune build Path b has already been scanned. Cannot scan it again through symlink src/a/x/x/x [1] + + $ mkdir -p symlink-outside-root3/{root,other} + $ cd symlink-outside-root3 && ln -s ../other root/src + $ cd symlink-outside-root3 && ln -s ../other other/foo + $ cd symlink-outside-root3/root && dune build + Path other has already been scanned. Cannot scan it again through symlink src/foo + [1] From 2192a549f4c0492055b639780584eb8ecd9ff8f5 Mon Sep 17 00:00:00 2001 From: Jeremie Dimino Date: Wed, 16 May 2018 14:12:24 +0100 Subject: [PATCH 09/13] Use dev/inode to detect loops --- src/file_tree.ml | 87 +++++++++++++------ src/stdune/path.ml | 33 ------- src/stdune/path.mli | 4 - .../blackbox-tests/test-cases/github764/run.t | 4 +- 4 files changed, 62 insertions(+), 66 deletions(-) diff --git a/src/file_tree.ml b/src/file_tree.ml index 1e7455bb..e04827f4 100644 --- a/src/file_tree.ml +++ b/src/file_tree.ml @@ -155,33 +155,46 @@ let ignore_file fn ~is_directory = (is_directory && (fn.[0] = '.' || fn.[0] = '_')) || (fn.[0] = '.' && fn.[1] = '#') +module File = struct + type t = + { ino : int + ; dev : int + } + + let compare a b = + match Int.compare a.ino b.ino with + | Eq -> Int.compare a.dev b.dev + | ne -> ne + + let dummy = { ino = 0; dev = 0 } + + let of_stats (st : Unix.stats) = + { ino = st.st_ino + ; dev = st.st_dev + } +end + +module File_map = Map.Make(File) + let load ?(extra_ignored_subtrees=Path.Set.empty) path = - let rec walk seen_real_paths path ~project ~ignored : Dir.t = - let realpath = - Path.follow_symlink path - |> Result.map_error ~f:(function - | `Maximum_depth_exceeded -> - die "maximum symlink depth exceeded while scanning %s" - (Path.to_string_maybe_quoted path) - | `Cycle_detected -> - die "cycle detected while scanning %s" - (Path.to_string_maybe_quoted path)) - |> Result.ok_exn in - if List.mem realpath ~set:seen_real_paths then - die "Path %s has already been scanned. \ - Cannot scan it again through symlink %s" - (Path.to_string_maybe_quoted realpath) - (Path.to_string_maybe_quoted path); + let rec walk path ~dirs_visited ~project ~ignored : Dir.t = let contents = lazy ( let files, sub_dirs = Path.readdir path |> List.filter_partition_map ~f:(fun fn -> let path = Path.relative path fn in - let is_directory = Path.is_directory path in + let is_directory, file = + match Unix.stat (Path.to_string path) with + | exception _ -> (false, File.dummy) + | { st_kind = S_DIR; _ } as st -> + (true, File.of_stats st) + | _ -> + (false, File.dummy) + in if ignore_file fn ~is_directory then Skip else if is_directory then - Right (fn, path) + Right (fn, path, file) else Left fn) in @@ -218,14 +231,27 @@ let load ?(extra_ignored_subtrees=Path.Set.empty) path = (dune_file, ignored_subdirs) in let sub_dirs = - List.fold_left sub_dirs ~init:String.Map.empty ~f:(fun acc (fn, path) -> - let ignored = - ignored - || String.Set.mem ignored_subdirs fn - || Path.Set.mem extra_ignored_subtrees path - in - String.Map.add acc fn - (walk (realpath :: seen_real_paths) path ~project ~ignored)) + List.fold_left sub_dirs ~init:String.Map.empty + ~f:(fun acc (fn, path, file) -> + let dirs_visited = + if Sys.win32 then + dirs_visited + else + match File_map.find dirs_visited file with + | None -> File_map.add dirs_visited file path + | Some first_path -> + die "Path %s has already been scanned. \ + Cannot scan it again through symlink %s" + (Path.to_string_maybe_quoted first_path) + (Path.to_string_maybe_quoted path) + in + let ignored = + ignored + || String.Set.mem ignored_subdirs fn + || Path.Set.mem extra_ignored_subtrees path + in + String.Map.add acc fn + (walk path ~dirs_visited ~project ~ignored)) in { Dir. files; sub_dirs; dune_file; project }) in @@ -234,7 +260,14 @@ let load ?(extra_ignored_subtrees=Path.Set.empty) path = ; ignored } in - let root = walk [] path ~ignored:false ~project:None in + let root = + walk path + ~dirs_visited:(File_map.singleton + (File.of_stats (Unix.stat (Path.to_string path))) + path) + ~ignored:false + ~project:None + in let dirs = Hashtbl.create 1024 in Hashtbl.add dirs Path.root root; { root; dirs } diff --git a/src/stdune/path.ml b/src/stdune/path.ml index cda051d2..22c8a334 100644 --- a/src/stdune/path.ml +++ b/src/stdune/path.ml @@ -520,36 +520,3 @@ let change_extension ~ext t = let extension = Filename.extension let pp ppf t = Format.pp_print_string ppf (to_string t) - -let follow_symlink p = - let readlink fn = - match Unix.readlink fn with - | exception Unix.Unix_error ((EINVAL | ENOENT), "readlink", _) -> None - | p -> Some p in - match readlink p with - | None -> Result.Ok p - | Some p -> - let rec follow n fn = - if n = 0 then - Result.Error `Maximum_depth_exceeded - else - match readlink fn with - | None -> Result.Ok fn - | Some p -> - if p = fn then - Result.Error `Cycle_detected - else - follow (pred n) p - in - let open Result.O in - follow 256 (to_string p) >>| fun realpath -> - if not (is_local realpath) then - of_string realpath - else - match parent p with - | Some p -> relative p realpath - | None -> - Exn.code_error "follow_symlink: p cannot be a symlink to root" - [ "p", sexp_of_t p - ; "realpath", sexp_of_t realpath ] - diff --git a/src/stdune/path.mli b/src/stdune/path.mli index a5854b9e..44663266 100644 --- a/src/stdune/path.mli +++ b/src/stdune/path.mli @@ -143,7 +143,3 @@ val pp : Format.formatter -> t -> unit val build_dir_exists : unit -> bool val ensure_build_dir_exists : unit -> unit - -val follow_symlink - : t - -> (t, [ `Cycle_detected | `Maximum_depth_exceeded ]) Result.t diff --git a/test/blackbox-tests/test-cases/github764/run.t b/test/blackbox-tests/test-cases/github764/run.t index a70e5675..3995e6c4 100644 --- a/test/blackbox-tests/test-cases/github764/run.t +++ b/test/blackbox-tests/test-cases/github764/run.t @@ -24,12 +24,12 @@ $ cd symlink-outside-root2 && ln -s ../a other/b/x $ cd symlink-outside-root2 && ln -s ../other root/src $ cd symlink-outside-root2/root && dune build - Path b has already been scanned. Cannot scan it again through symlink src/a/x/x/x + Path src/a has already been scanned. Cannot scan it again through symlink src/a/x/x [1] $ mkdir -p symlink-outside-root3/{root,other} $ cd symlink-outside-root3 && ln -s ../other root/src $ cd symlink-outside-root3 && ln -s ../other other/foo $ cd symlink-outside-root3/root && dune build - Path other has already been scanned. Cannot scan it again through symlink src/foo + Path src has already been scanned. Cannot scan it again through symlink src/foo [1] From 46479fd0836ba1d83a3605e6624c2381462250cd Mon Sep 17 00:00:00 2001 From: Jeremie Dimino Date: Wed, 16 May 2018 14:40:21 +0100 Subject: [PATCH 10/13] Try to make tests pass in Travis --- test/blackbox-tests/test-cases/github764/run.t | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/blackbox-tests/test-cases/github764/run.t b/test/blackbox-tests/test-cases/github764/run.t index 3995e6c4..4c11f7bf 100644 --- a/test/blackbox-tests/test-cases/github764/run.t +++ b/test/blackbox-tests/test-cases/github764/run.t @@ -8,8 +8,8 @@ [1] $ mkdir -p c2/{a,b} - $ cd c2 && ln -s ../b a/x - $ cd c2 && ln -s ../a b/x + $ cd c2/a && ln -s ../b x + $ cd c2/b && ln -s ../a x $ cd c2 && dune build Path a has already been scanned. Cannot scan it again through symlink a/x/x [1] @@ -20,16 +20,16 @@ foo $ mkdir -p symlink-outside-root2/{root,other/{a,b}} - $ cd symlink-outside-root2 && ln -s ../b other/a/x - $ cd symlink-outside-root2 && ln -s ../a other/b/x - $ cd symlink-outside-root2 && ln -s ../other root/src + $ cd symlink-outside-root2/other/a && ln -s ../b x + $ cd symlink-outside-root2/other/b && ln -s ../a x + $ cd symlink-outside-root2/root && ln -s ../other src $ cd symlink-outside-root2/root && dune build Path src/a has already been scanned. Cannot scan it again through symlink src/a/x/x [1] $ mkdir -p symlink-outside-root3/{root,other} - $ cd symlink-outside-root3 && ln -s ../other root/src - $ cd symlink-outside-root3 && ln -s ../other other/foo + $ cd symlink-outside-root3/root && ln -s ../other src + $ cd symlink-outside-root3/other && ln -s ../other foo $ cd symlink-outside-root3/root && dune build Path src has already been scanned. Cannot scan it again through symlink src/foo [1] From 2cf1631730cecf64f22f69e439fefb0ab7a29194 Mon Sep 17 00:00:00 2001 From: Jeremie Dimino Date: Wed, 16 May 2018 15:15:45 +0100 Subject: [PATCH 11/13] Try again --- test/blackbox-tests/test-cases/github764/run.t | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/blackbox-tests/test-cases/github764/run.t b/test/blackbox-tests/test-cases/github764/run.t index 4c11f7bf..057246f7 100644 --- a/test/blackbox-tests/test-cases/github764/run.t +++ b/test/blackbox-tests/test-cases/github764/run.t @@ -7,7 +7,7 @@ Path . has already been scanned. Cannot scan it again through symlink x [1] - $ mkdir -p c2/{a,b} + $ mkdir -p c2/a c2/b $ cd c2/a && ln -s ../b x $ cd c2/b && ln -s ../a x $ cd c2 && dune build @@ -19,7 +19,9 @@ $ cd symlink-outside-root && jbuilder exec --root . -- sample/foo.exe foo - $ mkdir -p symlink-outside-root2/{root,other/{a,b}} + $ mkdir -p symlink-outside-root2/root + $ mkdir -p symlink-outside-root2/root/other/a + $ mkdir -p symlink-outside-root2/root/other/b $ cd symlink-outside-root2/other/a && ln -s ../b x $ cd symlink-outside-root2/other/b && ln -s ../a x $ cd symlink-outside-root2/root && ln -s ../other src @@ -27,7 +29,8 @@ Path src/a has already been scanned. Cannot scan it again through symlink src/a/x/x [1] - $ mkdir -p symlink-outside-root3/{root,other} + $ mkdir -p symlink-outside-root3/root + $ mkdir -p symlink-outside-root3/other $ cd symlink-outside-root3/root && ln -s ../other src $ cd symlink-outside-root3/other && ln -s ../other foo $ cd symlink-outside-root3/root && dune build From 62997d6676fafe0c365abb0e5846f5b40f7a56fe Mon Sep 17 00:00:00 2001 From: Jeremie Dimino Date: Wed, 16 May 2018 15:18:36 +0100 Subject: [PATCH 12/13] fix --- test/blackbox-tests/test-cases/github764/run.t | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/blackbox-tests/test-cases/github764/run.t b/test/blackbox-tests/test-cases/github764/run.t index 057246f7..33e92b24 100644 --- a/test/blackbox-tests/test-cases/github764/run.t +++ b/test/blackbox-tests/test-cases/github764/run.t @@ -20,8 +20,8 @@ foo $ mkdir -p symlink-outside-root2/root - $ mkdir -p symlink-outside-root2/root/other/a - $ mkdir -p symlink-outside-root2/root/other/b + $ mkdir -p symlink-outside-root2/other/a + $ mkdir -p symlink-outside-root2/other/b $ cd symlink-outside-root2/other/a && ln -s ../b x $ cd symlink-outside-root2/other/b && ln -s ../a x $ cd symlink-outside-root2/root && ln -s ../other src From 58de56ad0d0db7544dabda3be5f84ace69625e67 Mon Sep 17 00:00:00 2001 From: Jeremie Dimino Date: Wed, 16 May 2018 15:19:04 +0100 Subject: [PATCH 13/13] Remove useless call --- test/blackbox-tests/test-cases/github764/run.t | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/blackbox-tests/test-cases/github764/run.t b/test/blackbox-tests/test-cases/github764/run.t index 33e92b24..2f04e5c7 100644 --- a/test/blackbox-tests/test-cases/github764/run.t +++ b/test/blackbox-tests/test-cases/github764/run.t @@ -1,5 +1,3 @@ - $ rm -rf x c* symlink* - $ mkdir -p c1 $ cd c1 && ln -s . x $ cd c1 && ln -s . y