Improve configurator tests

* Don't use asserts to test extracted values. Just print them and relying on
  diffing for comparison

* Use a string constant type.
This commit is contained in:
Rudi Grinberg 2018-04-16 13:01:25 +07:00
parent f1f60c4081
commit c1ca2f96b9
2 changed files with 16 additions and 11 deletions

View File

@ -3,15 +3,18 @@ module Configurator = Configurator.V1
let () =
let module C_define = Configurator.C_define in
Configurator.main ~name:"c_test" (fun t ->
assert (
C_define.import t
~includes:["caml/config.h"]
[ "CAML_CONFIG_H", C_define.Type.Switch
; "Page_log", C_define.Type.Int
] =
[ "CAML_CONFIG_H", C_define.Value.Switch true
; "Page_log", Int 12
C_define.import t
~includes:["caml/config.h"]
[ "CAML_CONFIG_H", C_define.Type.Switch
; "Page_log", C_define.Type.Int
; "__func__", C_define.Type.String
]
);
print_endline "Successfully import #define's"
|> List.iter (fun (n, v) ->
Printf.printf "%s=%s\n"
n (match v with
| C_define.Value.String s -> s
| Int i -> string_of_int i
| Switch b -> string_of_bool b
)
)
)

View File

@ -9,4 +9,6 @@ We're able to compile C program sucessfully
Importing #define's from code is successful
$ jbuilder exec import-define/run.exe
Successfully import #define's
CAML_CONFIG_H=true
Page_log=12
__func__=main