• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

MinaProtocol / mina / 411

24 Jul 2025 03:14PM UTC coverage: 33.188% (-27.7%) from 60.871%
411

push

buildkite

web-flow
Merge pull request #17541 from MinaProtocol/brian/merge-compatible-into-develop

Merge compatible into develop

164 of 702 new or added lines in 96 files covered. (23.36%)

18243 existing lines in 393 files now uncovered.

23983 of 72264 relevant lines covered (33.19%)

24667.26 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

25.86
/src/lib/testing/integration_test_lib/util.ml
1
open Core
2✔
2
open Async
3
module Timeout = Timeout_lib.Core_time
4

5
let create_process_exn dir prog args ?env () =
6
  let envs =
58✔
7
    match env with
8
    | Some (`Extend list) ->
1✔
9
        List.map list ~f:(fun (key, value) -> `String (key ^ "=" ^ value))
1✔
10
    | _ ->
57✔
11
        []
12
  in
13
  [%log' spam (Logger.create ())]
58✔
14
    "Running command (from %s): $command" dir
15
    ~metadata:
16
      [ ("command", `String (String.concat (prog :: args) ~sep:" "))
58✔
17
      ; ("envs", `List envs)
18
      ] ;
19
  Process.create_exn ~working_dir:dir ~prog ~args ?env ()
58✔
20

21
let run_cmd dir prog args ?env () =
22
  create_process_exn dir prog args ?env () >>= Process.collect_output_and_wait
9✔
23

24
let check_cmd_output ~prog ~args output =
25
  let open Process.Output in
57✔
26
  let print_output () =
27
    let indent str =
×
28
      String.split str ~on:'\n'
×
29
      |> List.map ~f:(fun s -> "    " ^ s)
×
30
      |> String.concat ~sep:"\n"
31
    in
32
    print_endline "=== COMMAND ===" ;
33
    print_endline
×
34
      (indent
×
35
         ( prog ^ " "
36
         ^ String.concat ~sep:" "
×
37
             (List.map args ~f:(fun arg -> "\"" ^ arg ^ "\"")) ) ) ;
×
38
    print_endline "=== STDOUT ===" ;
×
39
    print_endline (indent output.stdout) ;
×
40
    print_endline "=== STDERR ===" ;
×
41
    print_endline (indent output.stderr) ;
×
42
    Writer.(flushed (Lazy.force stdout))
×
43
  in
44
  match output.exit_status with
45
  | Ok () ->
57✔
46
      return (Ok output.stdout)
47
  | Error (`Exit_non_zero status) ->
×
48
      let%map () = print_output () in
×
49
      Or_error.errorf "command exited with status code %d" status
×
50
  | Error (`Signal signal) ->
×
51
      let%map () = print_output () in
×
52
      Or_error.errorf "command exited prematurely due to signal %d"
×
53
        (Signal.to_system_int signal)
×
54

55
let run_cmd_or_error_timeout ~timeout_seconds dir prog args =
56
  [%log' spam (Logger.create ())]
×
57
    "Running command (from %s): $command" dir
58
    ~metadata:[ ("command", `String (String.concat (prog :: args) ~sep:" ")) ] ;
×
59
  let open Deferred.Let_syntax in
×
60
  let%bind process = Process.create_exn ~working_dir:dir ~prog ~args () in
×
61
  let%bind res =
62
    match%map
63
      Timeout.await ()
×
64
        ~timeout_duration:(Time.Span.create ~sec:timeout_seconds ())
×
65
        (Process.collect_output_and_wait process)
×
66
    with
67
    | `Ok output ->
×
68
        check_cmd_output ~prog ~args output
69
    | `Timeout ->
×
70
        Deferred.return (Or_error.error_string "timed out running command")
×
71
  in
72
  res
×
73

74
let run_cmd_or_error ?env dir prog args =
75
  let%bind output = run_cmd dir prog args ?env () in
9✔
76
  check_cmd_output ~prog ~args output
9✔
77

78
let run_cmd_exn ?env dir prog args =
79
  match%map run_cmd_or_error ?env dir prog args with
4✔
80
  | Ok output ->
4✔
81
      output
82
  | Error error ->
×
83
      Error.raise error
84

85
let run_cmd_or_hard_error ?exit_code ?env dir prog args =
UNCOV
86
  let%bind output = run_cmd dir prog args ?env () in
×
87
  Deferred.bind
×
88
    ~f:(Malleable_error.or_hard_error ?exit_code)
89
    (check_cmd_output ~prog ~args output)
×
90

91
let run_cmd_exn_timeout ~timeout_seconds dir prog args =
92
  match%map run_cmd_or_error_timeout ~timeout_seconds dir prog args with
×
93
  | Ok output ->
×
94
      output
95
  | Error error ->
×
96
      Error.raise error
97

98
let rec prompt_continue prompt_string =
99
  print_string prompt_string ;
×
100
  let%bind () = Writer.flushed (Lazy.force Writer.stdout) in
×
101
  let c = Option.value_exn In_channel.(input_char stdin) in
×
102
  print_newline () ;
×
103
  if Char.equal c 'y' || Char.equal c 'Y' then Deferred.unit
×
104
  else prompt_continue prompt_string
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc