File tree 3 files changed +26
-3
lines changed
test/blackbox-tests/test-cases/subdir-stanza.t
3 files changed +26
-3
lines changed Original file line number Diff line number Diff line change @@ -94,6 +94,8 @@ Unreleased
94
94
95
95
- Add support for sandboxing using hard links (#4360 , @snowleopard )
96
96
97
+ - Fix dune crash when ` subdir ` is an absolute path (#4366 , @anmonteiro )
98
+
97
99
2.8.2 (21/01/2021)
98
100
------------------
99
101
Original file line number Diff line number Diff line change @@ -188,9 +188,14 @@ module Dir_map = struct
188
188
let merge_all = List. fold_left ~f: merge ~init: empty
189
189
end
190
190
191
- let descedant_path =
191
+ let descendant_path =
192
192
Dune_lang.Decoder. plain_string (fun ~loc fn ->
193
- Path.Local. parse_string_exn ~loc fn |> Path.Local. explode)
193
+ if Filename. is_relative fn then
194
+ Path.Local. parse_string_exn ~loc fn |> Path.Local. explode
195
+ else
196
+ let msg = [ Pp. textf " invalid sub-directory path %S" fn ] in
197
+ let hints = [ Pp. textf " sub-directory path must be relative" ] in
198
+ User_error. raise ~loc ~hints msg)
194
199
195
200
let strict_subdir field_name =
196
201
let open Dune_lang.Decoder in
@@ -263,7 +268,7 @@ let decode =
263
268
in
264
269
let rec subdir () =
265
270
let * () = Dune_lang.Syntax. since Stanza. syntax (2 , 5 ) in
266
- let * subdir = descedant_path in
271
+ let * subdir = descendant_path in
267
272
let + node = fields (decode ~allow_ignored_subdirs: false ) in
268
273
Dir_map. make_at_path subdir node
269
274
and decode ~allow_ignored_subdirs =
Original file line number Diff line number Diff line change @@ -118,3 +118,19 @@ Include stanzas within subdir stanzas
118
118
$ dune build --root . a /hello .txt
119
119
$ cat _build /default /a /hello .txt
120
120
Hello !
121
+
122
+
123
+ $ echo "(lang dune 2.5 )" > dune-project
124
+ $ cat >dune <<EOF
125
+ > (rule (with-stdout-to foo. txt (echo " bar" )))
126
+ > (subdir / absolute/ path/ to / bar
127
+ > (rule (with-stdout-to foo. txt (echo " bar" ))))
128
+ > EOF
129
+ $ dune build ./foo .txt ./bar /foo .txt
130
+ File "dune ", line 2 , characters 8-29 :
131
+ 2 | (subdir / absolute/ path/ to / bar
132
+ ^^^^^^^^^^^^^^^^^^^^ ^
133
+ Error: invalid sub-directory path " /absolute/path/to/bar"
134
+ Hint: sub-directory path must be relative
135
+ [1 ]
136
+
You can’t perform that action at this time.
0 commit comments