File tree Expand file tree Collapse file tree 3 files changed +26
-16
lines changed
test/blackbox-tests/test-cases/subst Expand file tree Collapse file tree 3 files changed +26
-16
lines changed Original file line number Diff line number Diff line change @@ -120,15 +120,27 @@ let subst_string s path ~map =
120120;;
121121
122122let subst_file path ~map =
123- let s = Io. read_file path in
124- let s =
125- if Path. is_root (Path. parent_exn path) && Package. is_opam_file path
126- then " version: \" %%" ^ " VERSION_NUM" ^ " %%\"\n " ^ s
127- else s
128- in
129- match subst_string s ~map path with
130- | None -> ()
131- | Some s -> Io. write_file path s
123+ match Io. with_file_in path ~f: Io. read_all_unless_large with
124+ | Error () ->
125+ let hints =
126+ if Sys. word_size = 32
127+ then
128+ [ Pp. textf
129+ " Dune has been built as a 32-bit binary so the maximum size \" dune subst\" \
130+ can operate on is 16MiB."
131+ ]
132+ else []
133+ in
134+ User_warning. emit ~hints [ Pp. textf " Ignoring large file: %s" (Path. to_string path) ]
135+ | Ok s ->
136+ let s =
137+ if Path. is_root (Path. parent_exn path) && Package. is_opam_file path
138+ then " version: \" %%" ^ " VERSION_NUM" ^ " %%\"\n " ^ s
139+ else s
140+ in
141+ (match subst_string s ~map path with
142+ | None -> ()
143+ | Some s -> Io. write_file path s)
132144;;
133145
134146(* Extending the Dune_project APIs, but adding capability to modify *)
Original file line number Diff line number Diff line change 1+ - subst: do not fail on 32-bit systems when large files are encountered. Just log a warning in this case. (#9811 , fixes #9538 , @emillon )
Original file line number Diff line number Diff line change @@ -26,10 +26,7 @@ This test uses subst, which needs a git repository:
2626 create mode 100644 dune-project
2727 create mode 100644 large. dat
2828
29- $ dune subst 2 > &1 | head -n 6
30- Error: exception Invalid_argument(" Bytes.create" )
31- Raised by primitive operation at Stdune__Io. Make. eagerly_input_string in file
32- " otherlibs/stdune/src/io.ml" , line 273 , characters 14 -30
33- Called from Stdune__Io. Make. read_all. (fun) in file
34- " otherlibs/stdune/src/io.ml" , line 308 , characters 16 -40
35- Called from Stdune__Exn. protectx in file " otherlibs/stdune/src/exn.ml" , line
29+ $ dune subst
30+ Warning: Ignoring large file: large. dat
31+ Hint: Dune has been built as a 32 -bit binary so the maximum size " dune subst"
32+ can operate on is 16 MiB.
You can’t perform that action at this time.
0 commit comments