-
Notifications
You must be signed in to change notification settings - Fork 409
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rely on #use_command rather than installing a dune.top file
Signed-off-by: Jeremie Dimino <[email protected]>
- Loading branch information
1 parent
3527f53
commit 622ae66
Showing
4 changed files
with
32 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
test/blackbox-tests/test-cases/toplevel-integration/use_output_compat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
(* -*- tuareg -*- *) | ||
|
||
let try_finally ~always f = | ||
match f () with | ||
| x -> | ||
always (); | ||
x | ||
| exception e -> | ||
always (); | ||
raise e | ||
|
||
let use_output command = | ||
let fn = Filename.temp_file "ocaml" "_toploop.ml" in | ||
try_finally | ||
~always:(fun () -> try Sys.remove fn with Sys_error _ -> ()) | ||
(fun () -> | ||
match | ||
Printf.ksprintf Sys.command "%s > %s" command (Filename.quote fn) | ||
with | ||
| 0 -> ignore (Toploop.use_file Format.std_formatter fn : bool) | ||
| n -> Format.printf "Command exited with code %d.@." n) | ||
|
||
let () = | ||
let name = "use_output" in | ||
if not (Hashtbl.mem Toploop.directive_table name) then | ||
Hashtbl.add Toploop.directive_table name | ||
(Toploop.Directive_string use_output) |