mirror of
https://git.sr.ht/~bryan_bennett/flake_env
synced 2025-12-19 16:01:25 +01:00
WIP
This commit is contained in:
parent
31cac9373c
commit
5e505b178b
13 changed files with 486 additions and 165 deletions
39
tests/flake_env_test_util.re
Normal file
39
tests/flake_env_test_util.re
Normal 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),
|
||||
]),
|
||||
]),
|
||||
);
|
||||
Loading…
Add table
Add a link
Reference in a new issue