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

MinaProtocol / mina / 1612

21 Oct 2024 08:28AM UTC coverage: 61.111% (+0.02%) from 61.093%
1612

push

buildkite

web-flow
Merge pull request #16255 from MinaProtocol/release/3.0.2

682 of 1335 new or added lines in 129 files covered. (51.09%)

148 existing lines in 47 files now uncovered.

47180 of 77204 relevant lines covered (61.11%)

555482.14 hits per line

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

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

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

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

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

72
let run_cmd_or_error ?env dir prog args =
NEW
73
  let%bind output = run_cmd dir prog args ?env () in
×
UNCOV
74
  check_cmd_output ~prog ~args output
×
75

76
let run_cmd_exn ?env dir prog args =
NEW
77
  match%map run_cmd_or_error ?env dir prog args with
×
UNCOV
78
  | Ok output ->
×
79
      output
80
  | Error error ->
×
81
      Error.raise error
82

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

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

96
let rec prompt_continue prompt_string =
97
  print_string prompt_string ;
×
98
  let%bind () = Writer.flushed (Lazy.force Writer.stdout) in
×
99
  let c = Option.value_exn In_channel.(input_char stdin) in
×
100
  print_newline () ;
×
101
  if Char.equal c 'y' || Char.equal c 'Y' then Deferred.unit
×
102
  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

© 2025 Coveralls, Inc