mirror of
https://git.sr.ht/~bryan_bennett/flake_env
synced 2025-12-19 07:51:23 +01:00
39 lines
1.1 KiB
ReasonML
39 lines
1.1 KiB
ReasonML
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),
|
|
]),
|
|
]),
|
|
);
|