This commit is contained in:
Bryan Bennett 2024-01-05 06:25:13 -05:00
parent 31cac9373c
commit 5e505b178b
No known key found for this signature in database
GPG key ID: EE149E4215408DE9
13 changed files with 486 additions and 165 deletions

View file

@ -0,0 +1,39 @@
open Core;
module Unix = Core_unix;
open Lib.Util;
let pp_exit_or_signal = (pp_fmt) => (e) => Fmt.pf(pp_fmt, "%s", Unix.Exit_or_signal.to_string_hum(e));
let exit_or_signal_eq = (a, b) => Unix.Exit_or_signal.compare(a, b) == 0;
let testable_exit_or_signal = Alcotest.testable(pp_exit_or_signal, exit_or_signal_eq);
let test_run_process_success = () =>
Alcotest.(check(Alcotest.pair(testable_exit_or_signal, string)))(
"Returns expected",
(Ok(), ""),
run_process("true", []));
let test_run_process_failure = () =>
Alcotest.(check(Alcotest.pair(testable_exit_or_signal, string)))(
"Returns expected",
(Error(`Exit_non_zero(1)), ""),
run_process("false", []));
let test_run_process_stdout = () =>
Alcotest.(check(Alcotest.pair(testable_exit_or_signal, string)))(
"Returns expected",
(Ok(), "echoed\n"),
run_process("echo", ["echoed"]));
let () =
Alcotest.(
run(
"Watches",
[("run_process",
[
test_case("Capture's Stdout", `Quick, test_run_process_stdout),
test_case("Success", `Quick, test_run_process_success),
test_case("Failure", `Quick, test_run_process_failure),
]),
]),
);