package bisect_ppx

  1. Overview
  2. Docs

Source file register.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
(* This Source Code Form is subject to the terms of the Mozilla Public License,
   v. 2.0. If a copy of the MPL was not distributed with this file, You can
   obtain one at http://mozilla.org/MPL/2.0/. *)



let conditional = ref false

let switches = [
  ("-exclude",
  Arg.String Exclusions.add,
  "<pattern>  Exclude functions matching pattern") ;

  ("-exclude-file",
  Arg.String Exclusions.add_file,
  "<filename>  Exclude functions listed in given file") ;

  ("-mode",
  (Arg.Symbol (["safe"; "fast"; "faster"], ignore)),
  "  Ignored") ;

  ("-conditional",
  Arg.Set conditional,
  "  Do not instrument unless environment variable BISECT_ENABLE is YES");
]

   

open Migrate_parsetree
open Ppx_tools_404

let () =
  Driver.register ~name:"bisect_ppx" ~args:switches
    Versions.ocaml_404 begin fun _config _cookies ->
      let enabled =
        match !conditional with
        | false ->
          `Enabled
        | true ->
          match Sys.getenv "BISECT_ENABLE" with
          | exception Not_found ->
            `Disabled
          | s when (String.uppercase [@ocaml.warning "-3"]) s = "YES" ->
            `Enabled
          | _ ->
            `Disabled
      in

      match enabled with
      | `Enabled ->
        Ast_mapper_class.to_mapper (new Instrument.instrumenter)
      | `Disabled ->
        Ast_404.shallow_identity
    end
OCaml

Innovation. Community. Security.