From 2f13de7a48ab956dde06cc6a8ad5a9f93fd84c04 Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Fri, 13 Dec 2024 10:40:22 +0100 Subject: [PATCH] test: Repro 'dune fmt' crash in presence of Nix result A 'ocamlformat' executable is added to the test to avoid depending on OCamlformat. Signed-off-by: Jules Aguillon --- .../read-only-symlink-target.t/.ocamlformat | 0 .../test-cases/read-only-symlink-target.t/dune | 2 ++ .../read-only-symlink-target.t/dune-project | 1 + .../read-only-symlink-target.t/ocamlformat.ml | 2 ++ .../test-cases/read-only-symlink-target.t/run.t | 16 ++++++++++++++++ 5 files changed, 21 insertions(+) create mode 100644 test/blackbox-tests/test-cases/read-only-symlink-target.t/.ocamlformat create mode 100644 test/blackbox-tests/test-cases/read-only-symlink-target.t/dune create mode 100644 test/blackbox-tests/test-cases/read-only-symlink-target.t/dune-project create mode 100644 test/blackbox-tests/test-cases/read-only-symlink-target.t/ocamlformat.ml create mode 100644 test/blackbox-tests/test-cases/read-only-symlink-target.t/run.t diff --git a/test/blackbox-tests/test-cases/read-only-symlink-target.t/.ocamlformat b/test/blackbox-tests/test-cases/read-only-symlink-target.t/.ocamlformat new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/blackbox-tests/test-cases/read-only-symlink-target.t/dune b/test/blackbox-tests/test-cases/read-only-symlink-target.t/dune new file mode 100644 index 00000000000..75e3ba2509e --- /dev/null +++ b/test/blackbox-tests/test-cases/read-only-symlink-target.t/dune @@ -0,0 +1,2 @@ +(executable + (name ocamlformat)) diff --git a/test/blackbox-tests/test-cases/read-only-symlink-target.t/dune-project b/test/blackbox-tests/test-cases/read-only-symlink-target.t/dune-project new file mode 100644 index 00000000000..c2e46604eed --- /dev/null +++ b/test/blackbox-tests/test-cases/read-only-symlink-target.t/dune-project @@ -0,0 +1 @@ +(lang dune 2.8) diff --git a/test/blackbox-tests/test-cases/read-only-symlink-target.t/ocamlformat.ml b/test/blackbox-tests/test-cases/read-only-symlink-target.t/ocamlformat.ml new file mode 100644 index 00000000000..4099c65085d --- /dev/null +++ b/test/blackbox-tests/test-cases/read-only-symlink-target.t/ocamlformat.ml @@ -0,0 +1,2 @@ +(* Avoid adding dependencies to this cram test *) +let () = print_endline "(* formatted *)" diff --git a/test/blackbox-tests/test-cases/read-only-symlink-target.t/run.t b/test/blackbox-tests/test-cases/read-only-symlink-target.t/run.t new file mode 100644 index 00000000000..43760753360 --- /dev/null +++ b/test/blackbox-tests/test-cases/read-only-symlink-target.t/run.t @@ -0,0 +1,16 @@ +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 a-w "$RESULT" + $ ln -s "$RESULT" result + +This command should succeed: + + $ dune fmt 2>/dev/null + [1] + +Allow Dune to remove temporary files (calling Dune crashes without this): + + $ chmod -R u+w "$RESULT"