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

ocaml / dune / 28976

06 Nov 2024 09:44AM UTC coverage: 6.927% (+0.01%) from 6.913%
28976

push

github

web-flow
fix: Add or remove dune from package sets to allow resolving packages depending on it (#11103)

* fix: Add `dune` to existing packages to allow resolving

Signed-off-by: Marek Kubica <marek@tarides.com>

* Alternate solution which removes `dune` from formulas

Signed-off-by: Marek Kubica <marek@tarides.com>

* chore: leave a comment

Signed-off-by: Rudi Grinberg <me@rgrinberg.com>

* fix(pkg): use correct dune version to evaluate

Signed-off-by: Rudi Grinberg <me@rgrinberg.com>

---------

Signed-off-by: Marek Kubica <marek@tarides.com>
Signed-off-by: Rudi Grinberg <me@rgrinberg.com>
Co-authored-by: Rudi Grinberg <me@rgrinberg.com>

1 of 6 new or added lines in 2 files covered. (16.67%)

1612 existing lines in 28 files now uncovered.

2951 of 42601 relevant lines covered (6.93%)

26740.63 hits per line

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

0.0
/src/dune_rules/test_rules.ml
1
open Import
2
open Memo.O
3

4
let alias mode ~dir =
5
  match mode with
×
6
  | `js mode -> Jsoo_rules.js_of_ocaml_runtest_alias ~dir ~mode
×
7
  | `exe | `bc -> Memo.return Alias0.runtest
×
8
;;
9

10
let test_kind dir_contents (loc, name, ext) =
11
  let files = Dir_contents.text_files dir_contents in
×
12
  let expected_basename = name ^ ".expected" in
×
13
  if Filename.Set.mem files expected_basename
14
  then
15
    `Expect
×
16
      { Diff.file1 = String_with_vars.make_text loc expected_basename
×
17
      ; file2 = String_with_vars.make_text loc (name ^ ext ^ ".output")
×
18
      ; optional = false
19
      ; mode = Text
20
      }
21
  else `Regular
×
22
;;
23

24
let ext_of_mode runtest_mode =
25
  match runtest_mode with
×
26
  | `js mode -> Js_of_ocaml.Ext.exe ~mode
×
27
  | `bc -> ".bc"
×
28
  | `exe -> ".exe"
×
29
;;
30

31
let custom_runner runtest_mode =
32
  match runtest_mode with
×
33
  | `js _ -> Some Jsoo_rules.runner
×
34
  | `bc | `exe -> None
×
35
;;
36

37
let runtest_modes modes jsoo_enabled_modes project =
38
  if Dune_project.dune_version project < (3, 0)
×
39
  then [ `exe ]
×
40
  else
41
    Executables.Link_mode.Map.to_list modes
×
42
    |> List.filter_map ~f:(fun ((mode : Executables.Link_mode.t), _) ->
×
43
      match mode with
×
44
      | Byte_complete -> Some `exe
×
45
      | Other { kind = Exe; mode = Native | Best } -> Some `exe
×
46
      | Other { kind = Exe; mode = Byte } -> Some `bc
×
47
      | Other { kind = C | Object | Shared_object | Plugin; _ } ->
×
48
        (* We don't know how to run tests in these cases *)
49
        None
UNCOV
50
      | Jsoo mode ->
×
51
        Option.some_if (Js_of_ocaml.Mode.Pair.select ~mode jsoo_enabled_modes) (`js mode))
×
UNCOV
52
    |> List.sort_uniq ~compare:Poly.compare
×
53
;;
54

55
let rules (t : Tests.t) ~sctx ~dir ~scope ~expander ~dir_contents =
56
  let* () =
×
57
    let* runtest_modes =
58
      let+ jsoo_enabled_modes =
59
        Jsoo_rules.jsoo_enabled_modes
60
          ~expander
61
          ~dir
62
          ~in_context:(Js_of_ocaml.In_context.make ~dir t.exes.buildable.js_of_ocaml)
×
63
      in
64
      runtest_modes t.exes.modes jsoo_enabled_modes (Scope.project scope)
×
65
    in
UNCOV
66
    Expander.eval_blang expander t.enabled_if
×
67
    >>= function
68
    | false ->
×
69
      let loc = Nonempty_list.hd t.exes.names |> fst in
×
70
      Memo.parallel_iter runtest_modes ~f:(fun mode ->
×
71
        let* alias_name = alias mode ~dir in
×
UNCOV
72
        let alias = Alias.make alias_name ~dir in
×
UNCOV
73
        Simple_rules.Alias_rules.add_empty sctx ~loc ~alias)
×
74
    | true ->
×
75
      Nonempty_list.to_list t.exes.names
UNCOV
76
      |> Memo.parallel_iter ~f:(fun (loc, s) ->
×
77
        Memo.parallel_iter runtest_modes ~f:(fun runtest_mode ->
×
78
          let ext = ext_of_mode runtest_mode in
×
79
          let custom_runner = custom_runner runtest_mode in
×
80
          let test_pform = Pform.Var Test in
×
81
          let run_action =
82
            match t.action with
UNCOV
83
            | Some a -> a
×
UNCOV
84
            | None ->
×
85
              (match custom_runner with
UNCOV
86
               | None ->
×
87
                 Action_unexpanded.run (String_with_vars.make_pform loc test_pform) []
×
UNCOV
88
               | Some runner ->
×
89
                 Action_unexpanded.run
×
UNCOV
90
                   (String_with_vars.make_text loc runner)
×
91
                   [ String_with_vars.make_pform loc test_pform ])
×
92
          in
93
          let test_exe = s ^ ext in
94
          let extra_bindings =
95
            let test_exe_path =
96
              Expander.map_exe expander (Path.relative (Path.build dir) test_exe)
×
97
            in
UNCOV
98
            Pform.Map.singleton test_pform [ Value.Path test_exe_path ]
×
99
          in
UNCOV
100
          let* runtest_alias = alias runtest_mode ~dir in
×
UNCOV
101
          let deps =
×
102
            (* is this useless? we are going to infer the dependency anyway *)
103
            match custom_runner with
UNCOV
104
            | None -> t.deps
×
UNCOV
105
            | Some _ ->
×
UNCOV
106
              Bindings.Unnamed (Dep_conf.File (String_with_vars.make_text loc test_exe))
×
107
              :: t.deps
108
          in
109
          let add_alias ~loc ~action =
110
            (* CR rgrinberg: why are we going through the stanza api? *)
UNCOV
111
            let alias =
×
112
              { Alias_conf.name = runtest_alias
113
              ; locks = t.locks
114
              ; package = t.package
115
              ; deps
116
              ; action = Some (loc, action)
117
              ; enabled_if = t.enabled_if
118
              ; loc
119
              }
120
            in
121
            Simple_rules.alias sctx ~extra_bindings ~dir ~expander alias
122
          in
123
          match test_kind dir_contents (loc, s, ext) with
UNCOV
124
          | `Regular -> add_alias ~loc ~action:run_action
×
UNCOV
125
          | `Expect diff ->
×
126
            let rule =
127
              { Rule_conf.targets = Infer
128
              ; deps
129
              ; action =
130
                  ( loc
131
                  , Action_unexpanded.Redirect_out (Stdout, diff.file2, Normal, run_action)
132
                  )
133
              ; mode = Standard
134
              ; locks = t.locks
135
              ; loc
136
              ; enabled_if = t.enabled_if
137
              ; aliases = []
138
              ; package = t.package
139
              }
140
            in
141
            add_alias ~loc ~action:(Diff diff)
142
            >>> let+ (_ignored_targets : Targets.Validated.t option) =
UNCOV
143
                  Simple_rules.user_rule sctx rule ~extra_bindings ~dir ~expander
×
144
                in
UNCOV
145
                ()))
×
146
  in
UNCOV
147
  Exe_rules.rules t.exes ~sctx ~dir ~scope ~expander ~dir_contents
×
148
;;
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

© 2026 Coveralls, Inc