diff --git a/test/blackbox-tests/test-cases/nix-result-in-tree.t b/test/blackbox-tests/test-cases/nix-result-in-tree.t new file mode 100644 index 000000000000..2fcacbfbac5c --- /dev/null +++ b/test/blackbox-tests/test-cases/nix-result-in-tree.t @@ -0,0 +1,58 @@ +Nix can leave a symlink to a store path in the tree, often called 'result'. +'dune fmt' crashes because of that. + + $ RESULT=`mktemp -d` + $ echo "let x = 2" > "$RESULT/foo.ml" + $ chmod -R 555 "$RESULT" + + $ ln -s "$RESULT" result + $ echo "(lang dune 2.8)" > dune-project + $ touch .ocamlformat + + $ dune fmt --auto-promote + File "result/foo.ml", line 1, characters 0-0: + Error: Files _build/default/result/foo.ml and + _build/default/result/.formatted/foo.ml differ. + Promoting _build/default/result/.formatted/foo.ml to result/foo.ml. + Internal error, please report upstream including the contents of _build/log. + Description: + ("hooks failed", + { exns = + [ { exn = "Unix.Unix_error(Unix.EACCES, \"open\", \"result/foo.ml\")" + ; backtrace = + "Raised by primitive operation at Stdune__Io.Copyfile.sendfile_with_fallback.setup_copy in file \"otherlibs/stdune/src/io.ml\", line 142, characters 18-86\n\ + Re-raised at Stdune__Exn.raise_with_backtrace in file \"otherlibs/stdune/src/exn.ml\", line 38, characters 27-56\n\ + Called from Promote__Diff_promotion.do_promote.promote_one in file \"src/promote/diff_promotion.ml\", line 150, characters 6-40\n\ + Called from Stdlib__Map.Make.iter in file \"map.ml\", line 305, characters 20-25\n\ + Called from Promote__Diff_promotion.do_promote in file \"src/promote/diff_promotion.ml\", line 159, characters 4-51\n\ + Called from Promote__Diff_promotion.finalize in file \"src/promote/diff_promotion.ml\", line 181, characters 28-51\n\ + Called from Stdune__Exn_with_backtrace.try_with in file \"otherlibs/stdune/src/exn_with_backtrace.ml\", line 9, characters 8-12\n\ + " + } + ] + }) + Raised at Stdune__Code_error.raise in file + "otherlibs/stdune/src/code_error.ml", line 10, characters 30-62 + Called from Dune__exe__Build_cmd.run_build_system.(fun) in file + "bin/build_cmd.ml", line 81, characters 6-31 + Called from Fiber__Scheduler.exec in file "vendor/fiber/src/scheduler.ml", + line 76, characters 8-11 + Re-raised at Stdune__Exn.raise_with_backtrace in file + "otherlibs/stdune/src/exn.ml", line 38, characters 27-56 + Called from Fiber__Scheduler.exec in file "vendor/fiber/src/scheduler.ml", + line 76, characters 8-11 + Re-raised at Stdune__Exn.raise_with_backtrace in file + "otherlibs/stdune/src/exn.ml", line 38, characters 27-56 + Called from Fiber__Scheduler.exec in file "vendor/fiber/src/scheduler.ml", + line 76, characters 8-11 + + I must not crash. Uncertainty is the mind-killer. Exceptions are the + little-death that brings total obliteration. I will fully express my cases. + Execution will pass over me and through me. And when it has gone past, I + will unwind the stack along its path. Where the cases are handled there will + be nothing. Only I will remain. + [1] + +Allow Dune to remove temporary files (Dune crashes without this): + + $ chmod -R u+w "$RESULT"