From 089a1bec16f8f3c5679e81b09cade2b60850bf5d Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Fri, 31 Jul 2020 14:48:16 -0400 Subject: [PATCH] try to fix tests that fail on mac OS --- dune | 2 +- src/mdx_runner.ml | 13 ++++++++++--- src/threads/CCPool.ml | 5 +++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/dune b/dune index 1d313390..f8d56234 100644 --- a/dune +++ b/dune @@ -1,6 +1,6 @@ (rule (targets README.md.corrected) - (deps (package containers) (package containers-data) ./src/mdx_runner.exe) + (deps (package containers-data) ./src/mdx_runner.exe) (action (run ./src/mdx_runner.exe))) (alias diff --git a/src/mdx_runner.ml b/src/mdx_runner.ml index e098f034..e485d0ca 100644 --- a/src/mdx_runner.ml +++ b/src/mdx_runner.ml @@ -2,9 +2,16 @@ open Printf let just_copy () = - CCIO.with_out "README.md.corrected" (fun oc -> - CCIO.with_in "README.md" (fun ic -> - CCIO.copy_into ic oc)) + let ic = open_in "README.md" in + let len = in_channel_length ic in + let buf = Bytes.create len in + really_input ic buf 0 len; + close_in_noerr ic; + + let oc = open_out "README.md.corrected" in + output oc buf 0 len; + flush oc; + close_out_noerr oc let () = try diff --git a/src/threads/CCPool.ml b/src/threads/CCPool.ml index b1726f2d..4bc1816d 100644 --- a/src/threads/CCPool.ml +++ b/src/threads/CCPool.ml @@ -526,7 +526,8 @@ module Make(P : PARAM) = struct let sequence_l l = match l with | [] -> return [] | _ :: _ -> - sequence_ (L_ l) (fun () -> List.map get_nolock_ l) + let l = List.rev l in + sequence_ (L_ l) (fun () -> List.rev_map get_nolock_ l) (* reverse twice *) let map_l f l = @@ -557,7 +558,7 @@ module Make(P : PARAM) = struct (*$R let l = CCList.(1 -- 100_000) in let l' = l - |> List.map + |> CCList.map (fun x -> Fut.make (fun () -> 1)) |> Fut.sequence_l |> Fut.map (List.fold_left (+) 0)