From ea9435a68946fbc5d9fe835c782333df91ee7f06 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Sun, 26 Sep 2021 12:41:05 -0600 Subject: [PATCH 1/2] Reproduce gh4907 Signed-off-by: Rudi Grinberg --- .../run.t => subdir-stanza/basic.t} | 0 .../test-cases/subdir-stanza/gh4907.t | 74 +++++++++++++++++++ 2 files changed, 74 insertions(+) rename test/blackbox-tests/test-cases/{subdir-stanza.t/run.t => subdir-stanza/basic.t} (100%) create mode 100644 test/blackbox-tests/test-cases/subdir-stanza/gh4907.t diff --git a/test/blackbox-tests/test-cases/subdir-stanza.t/run.t b/test/blackbox-tests/test-cases/subdir-stanza/basic.t similarity index 100% rename from test/blackbox-tests/test-cases/subdir-stanza.t/run.t rename to test/blackbox-tests/test-cases/subdir-stanza/basic.t diff --git a/test/blackbox-tests/test-cases/subdir-stanza/gh4907.t b/test/blackbox-tests/test-cases/subdir-stanza/gh4907.t new file mode 100644 index 00000000000..2a3998957b8 --- /dev/null +++ b/test/blackbox-tests/test-cases/subdir-stanza/gh4907.t @@ -0,0 +1,74 @@ + + $ cat <dune-project + > (lang dune 3.0) + > EOF + $ cat <dune + > (subdir "foo bar" (rule with-stout-to (echo foo) ./foo)) + > EOF + $ dune build + Internal error, please report upstream including the contents of _build/log. + Description: + ("Dune_lang.Atom.of_string got invalid atom", { atom = "foo bar" }) + Raised at Stdune__Code_error.raise in file + "otherlibs/stdune-unstable/code_error.ml", line 11, characters 30-62 + Called from Dune_engine__Sub_dirs.decode_includes.subdir.(fun) in file + "src/dune_engine/sub_dirs.ml", line 316, characters 22-48 + Called from Dune_lang__Decoder.next in file "src/dune_lang/decoder.ml" + (inlined), line 282, characters 22-28 + Called from Dune_lang__Decoder.plain_string in file + "src/dune_lang/decoder.ml", line 339, characters 2-208 + Called from Dune_lang__Decoder.(>>=) in file "src/dune_lang/decoder.ml", line + 137, characters 17-28 + Called from Dune_lang__Decoder.multi_field.loop in file + "src/dune_lang/decoder.ml", line 666, characters 25-39 + Called from Dune_lang__Decoder.multi_field in file + "src/dune_lang/decoder.ml", line 669, characters 12-55 + Called from Dune_lang__Decoder.and+ in file "src/dune_lang/decoder.ml", line + 153, characters 17-28 + Called from Dune_lang__Decoder.(>>|) in file "src/dune_lang/decoder.ml", line + 141, characters 17-28 + Called from Dune_lang__Decoder.fields in file "src/dune_lang/decoder.ml", + line 674, characters 21-53 + Called from Dune_lang__Decoder.enter.(fun) in file + "src/dune_lang/decoder.ml", line 368, characters 19-28 + Called from Dune_lang__Decoder.next_with_user_context in file + "src/dune_lang/decoder.ml" (inlined), line 288, characters 22-51 + Called from Dune_lang__Decoder.enter in file "src/dune_lang/decoder.ml", line + 364, characters 2-242 + Called from Dune_lang__Decoder.(>>=) in file "src/dune_lang/decoder.ml", line + 137, characters 17-28 + Called from Dune_lang__Decoder.parse in file "src/dune_lang/decoder.ml", line + 255, characters 13-29 + Called from Dune_engine__Source_tree.Dune_file.load_plain in file + "src/dune_engine/source_tree.ml", line 89, characters 8-103 + Called from Dune_engine__Source_tree.Dune_file.load.(fun) in file + "src/dune_engine/source_tree.ml", line 111, characters 22-66 + Called from Stdune__Exn.protectx in file "otherlibs/stdune-unstable/exn.ml", + line 12, characters 8-11 + Re-raised at Stdune__Exn.protectx in file "otherlibs/stdune-unstable/exn.ml", + line 18, characters 4-11 + Called from Fiber.O.(>>|).(fun) in file "src/fiber/fiber.ml", line 288, + characters 36-41 + Called from Fiber.Execution_context.apply in file "src/fiber/fiber.ml", line + 182, characters 9-14 + Re-raised at Stdune__Exn.raise_with_backtrace in file + "otherlibs/stdune-unstable/exn.ml", line 36, characters 27-56 + Called from Fiber.Execution_context.run_jobs in file "src/fiber/fiber.ml", + line 204, characters 8-13 + Re-raised at Stdune__Exn.raise_with_backtrace in file + "otherlibs/stdune-unstable/exn.ml", line 36, characters 27-56 + Called from Fiber.Execution_context.run_jobs in file "src/fiber/fiber.ml", + line 204, characters 8-13 + Re-raised at Stdune__Exn.raise_with_backtrace in file + "otherlibs/stdune-unstable/exn.ml", line 36, characters 27-56 + Called from Fiber.Execution_context.run_jobs in file "src/fiber/fiber.ml", + line 204, characters 8-13 + -> required by ("find-dir-raw", ".") + -> required by ("", ()) + + 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] From 69c9dc1f39e374058a5026fbcf1561d8ebd6d804 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Sun, 26 Sep 2021 12:44:44 -0600 Subject: [PATCH 2/2] Fix 4907 Allow quoted strings as the directory argument Signed-off-by: Rudi Grinberg --- CHANGES.md | 3 + src/dune_engine/sub_dirs.ml | 2 +- .../test-cases/subdir-stanza/gh4907.t | 68 +------------------ 3 files changed, 5 insertions(+), 68 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 77ff99b078f..1431f0c2101 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,9 @@ Unreleased ---------- +- Allow spaces in the directory argument of the `subdir` stanza (#4943, fixes + #4907, @rgrinberg) + - Add a `%{toolchain}` expansion variable (#4899, fixes #3949, @rgrinberg) - Include dependencies of executables when creating toplevels (either `dune diff --git a/src/dune_engine/sub_dirs.ml b/src/dune_engine/sub_dirs.ml index 0cfdecf211f..ec9f9efde9b 100644 --- a/src/dune_engine/sub_dirs.ml +++ b/src/dune_engine/sub_dirs.ml @@ -313,7 +313,7 @@ let decode_includes ~context = let* loc = loc in let* name, path = plain_string (fun ~loc s -> - (Atom (loc, Dune_lang.Atom.of_string s), s :: path)) + (Dune_lang.Ast.atom_or_quoted_string loc s, s :: path)) in let+ nodes = fields (decode ~context ~path ~inside_include) in let required_version = (2, 7) in diff --git a/test/blackbox-tests/test-cases/subdir-stanza/gh4907.t b/test/blackbox-tests/test-cases/subdir-stanza/gh4907.t index 2a3998957b8..8b3618a882c 100644 --- a/test/blackbox-tests/test-cases/subdir-stanza/gh4907.t +++ b/test/blackbox-tests/test-cases/subdir-stanza/gh4907.t @@ -3,72 +3,6 @@ > (lang dune 3.0) > EOF $ cat <dune - > (subdir "foo bar" (rule with-stout-to (echo foo) ./foo)) + > (subdir "foo bar" (rule (with-stdout-to foo (echo foo)))) > EOF $ dune build - Internal error, please report upstream including the contents of _build/log. - Description: - ("Dune_lang.Atom.of_string got invalid atom", { atom = "foo bar" }) - Raised at Stdune__Code_error.raise in file - "otherlibs/stdune-unstable/code_error.ml", line 11, characters 30-62 - Called from Dune_engine__Sub_dirs.decode_includes.subdir.(fun) in file - "src/dune_engine/sub_dirs.ml", line 316, characters 22-48 - Called from Dune_lang__Decoder.next in file "src/dune_lang/decoder.ml" - (inlined), line 282, characters 22-28 - Called from Dune_lang__Decoder.plain_string in file - "src/dune_lang/decoder.ml", line 339, characters 2-208 - Called from Dune_lang__Decoder.(>>=) in file "src/dune_lang/decoder.ml", line - 137, characters 17-28 - Called from Dune_lang__Decoder.multi_field.loop in file - "src/dune_lang/decoder.ml", line 666, characters 25-39 - Called from Dune_lang__Decoder.multi_field in file - "src/dune_lang/decoder.ml", line 669, characters 12-55 - Called from Dune_lang__Decoder.and+ in file "src/dune_lang/decoder.ml", line - 153, characters 17-28 - Called from Dune_lang__Decoder.(>>|) in file "src/dune_lang/decoder.ml", line - 141, characters 17-28 - Called from Dune_lang__Decoder.fields in file "src/dune_lang/decoder.ml", - line 674, characters 21-53 - Called from Dune_lang__Decoder.enter.(fun) in file - "src/dune_lang/decoder.ml", line 368, characters 19-28 - Called from Dune_lang__Decoder.next_with_user_context in file - "src/dune_lang/decoder.ml" (inlined), line 288, characters 22-51 - Called from Dune_lang__Decoder.enter in file "src/dune_lang/decoder.ml", line - 364, characters 2-242 - Called from Dune_lang__Decoder.(>>=) in file "src/dune_lang/decoder.ml", line - 137, characters 17-28 - Called from Dune_lang__Decoder.parse in file "src/dune_lang/decoder.ml", line - 255, characters 13-29 - Called from Dune_engine__Source_tree.Dune_file.load_plain in file - "src/dune_engine/source_tree.ml", line 89, characters 8-103 - Called from Dune_engine__Source_tree.Dune_file.load.(fun) in file - "src/dune_engine/source_tree.ml", line 111, characters 22-66 - Called from Stdune__Exn.protectx in file "otherlibs/stdune-unstable/exn.ml", - line 12, characters 8-11 - Re-raised at Stdune__Exn.protectx in file "otherlibs/stdune-unstable/exn.ml", - line 18, characters 4-11 - Called from Fiber.O.(>>|).(fun) in file "src/fiber/fiber.ml", line 288, - characters 36-41 - Called from Fiber.Execution_context.apply in file "src/fiber/fiber.ml", line - 182, characters 9-14 - Re-raised at Stdune__Exn.raise_with_backtrace in file - "otherlibs/stdune-unstable/exn.ml", line 36, characters 27-56 - Called from Fiber.Execution_context.run_jobs in file "src/fiber/fiber.ml", - line 204, characters 8-13 - Re-raised at Stdune__Exn.raise_with_backtrace in file - "otherlibs/stdune-unstable/exn.ml", line 36, characters 27-56 - Called from Fiber.Execution_context.run_jobs in file "src/fiber/fiber.ml", - line 204, characters 8-13 - Re-raised at Stdune__Exn.raise_with_backtrace in file - "otherlibs/stdune-unstable/exn.ml", line 36, characters 27-56 - Called from Fiber.Execution_context.run_jobs in file "src/fiber/fiber.ml", - line 204, characters 8-13 - -> required by ("find-dir-raw", ".") - -> required by ("", ()) - - 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]