|
1 | 1 | open Import |
2 | 2 |
|
3 | | -let find_cram_test path ~parent_dir = |
| 3 | +let cram_tests_of_dir parent_dir = |
4 | 4 | let open Memo.O in |
5 | 5 | Source_tree.find_dir parent_dir |
6 | 6 | >>= function |
7 | | - | None -> Memo.return None |
8 | | - | Some dir -> |
9 | | - Dune_rules.Cram_rules.cram_tests dir |
10 | | - >>| List.find_map ~f:(function |
11 | | - | Ok cram_test when Path.Source.equal path (Source.Cram_test.path cram_test) -> |
12 | | - Some cram_test |
13 | | - (* We raise any error we encounter when looking for our test specifically. *) |
14 | | - | Error (Dune_rules.Cram_rules.Missing_run_t cram_test) |
15 | | - when Path.Source.equal path (Source.Cram_test.path cram_test) -> |
16 | | - Dune_rules.Cram_rules.missing_run_t cram_test |
17 | | - (* Any errors or successes unrelated to our test are discarded. *) |
18 | | - | Error (Dune_rules.Cram_rules.Missing_run_t _) | Ok _ -> None) |
| 7 | + | None -> Memo.return [] |
| 8 | + | Some dir -> Dune_rules.Cram_rules.cram_tests dir |
| 9 | +;; |
| 10 | + |
| 11 | +let find_cram_test cram_tests path = |
| 12 | + List.find_map cram_tests ~f:(function |
| 13 | + | Ok cram_test when Path.Source.equal path (Source.Cram_test.path cram_test) -> |
| 14 | + Some cram_test |
| 15 | + (* We raise any error we encounter when looking for our test specifically. *) |
| 16 | + | Error (Dune_rules.Cram_rules.Missing_run_t cram_test) |
| 17 | + when Path.Source.equal path (Source.Cram_test.path cram_test) -> |
| 18 | + Dune_rules.Cram_rules.missing_run_t cram_test |
| 19 | + (* Any errors or successes unrelated to our test are discarded. *) |
| 20 | + | Error (Dune_rules.Cram_rules.Missing_run_t _) | Ok _ -> None) |
19 | 21 | ;; |
20 | 22 |
|
21 | 23 | let explain_unsuccessful_search path ~parent_dir = |
@@ -57,8 +59,8 @@ let disambiguate_test_name path = |
57 | 59 | | None -> Memo.return @@ `Runtest (Path.source Path.Source.root) |
58 | 60 | | Some parent_dir -> |
59 | 61 | let open Memo.O in |
60 | | - find_cram_test path ~parent_dir |
61 | | - >>= (function |
| 62 | + let* cram_tests = cram_tests_of_dir parent_dir in |
| 63 | + (match find_cram_test cram_tests path with |
62 | 64 | | Some test -> |
63 | 65 | (* If we find the cram test, then we request that is run. *) |
64 | 66 | Memo.return (`Cram (parent_dir, test)) |
|
0 commit comments