Merge pull request #673 from rgrinberg/configurator-blackbox
Add a blackbox test suite for configurator
This commit is contained in:
commit
5217051915
|
@ -1,5 +1,6 @@
|
|||
(library
|
||||
((name configurator)
|
||||
(public_name jbuilder.configurator)
|
||||
(libraries (stdune ocaml_config))
|
||||
(flags (:standard -safe-string (:include flags/flags.sexp)))
|
||||
(preprocess no_preprocessing)))
|
||||
|
|
|
@ -2,5 +2,6 @@
|
|||
|
||||
(library
|
||||
((name ocaml_config)
|
||||
(public_name jbuilder.ocaml_config)
|
||||
(libraries (stdune usexp))
|
||||
(synopsis "Interpret the output of 'ocamlc -config'")))
|
||||
(synopsis "[Internal] Interpret the output of 'ocamlc -config'")))
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
(** Represent the output of [ocamlc -config] *)
|
||||
(** Represent the output of [ocamlc -config].
|
||||
|
||||
This library is internal to jbuilder and guarantees no API stability. *)
|
||||
|
||||
open Stdune
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
(** This library is internal to jbuilder and guarantees no API stability. *)
|
||||
|
||||
module Filename = Filename
|
||||
module String = String
|
||||
module Char = Char
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
(library
|
||||
((name caml)
|
||||
(synopsis "Wrapped version of the OCaml stdlib")))
|
||||
(public_name jbuilder.caml)
|
||||
(synopsis "[Internal] Wrapped version of the OCaml stdlib")))
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
(library
|
||||
((name stdune)
|
||||
(synopsis "Standard library of Dune")
|
||||
(public_name jbuilder.stdune)
|
||||
(synopsis "[Internal] Standard library of Dune")
|
||||
(libraries (caml unix))))
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
(jbuild_version 1)
|
||||
|
||||
(library ((name usexp)))
|
||||
(library
|
||||
((name usexp)
|
||||
(synopsis "[Internal] S-expression library")
|
||||
(public_name jbuilder.usexp)))
|
||||
|
||||
(rule
|
||||
(with-stdout-to table.ml.gen (run gen/gen_parser_automaton.exe)))
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
(** Parsing of s-expressions *)
|
||||
(** Parsing of s-expressions.
|
||||
|
||||
This library is internal to jbuilder and guarantees no API stability.*)
|
||||
|
||||
module Atom : sig
|
||||
type t = private A of string [@@unboxed]
|
||||
|
|
|
@ -459,3 +459,13 @@
|
|||
(progn
|
||||
(run ${exe:cram.exe} run.t)
|
||||
(diff? run.t run.t.corrected))))))
|
||||
|
||||
(alias
|
||||
((name runtest)
|
||||
(deps ((package jbuilder)
|
||||
(files_recursively_in test-cases/configurator)))
|
||||
(action
|
||||
(chdir test-cases/configurator
|
||||
(progn
|
||||
(run ${exe:cram.exe} run.t)
|
||||
(diff? run.t run.t.corrected))))))
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
(jbuild_version 1)
|
||||
|
||||
(executable
|
||||
((name run)
|
||||
(libraries (jbuilder.configurator))))
|
|
@ -0,0 +1,15 @@
|
|||
|
||||
let () =
|
||||
Configurator.main ~name:"c_test" (fun t ->
|
||||
let c_result =
|
||||
Configurator.c_test t {c|
|
||||
#include <stdio.h>
|
||||
int main()
|
||||
{
|
||||
printf("Hello, World!");
|
||||
return 0;
|
||||
}
|
||||
|c} in
|
||||
assert c_result;
|
||||
print_endline "Successfully compiled c program"
|
||||
)
|
|
@ -0,0 +1,5 @@
|
|||
(jbuild_version 1)
|
||||
|
||||
(executable
|
||||
((name run)
|
||||
(libraries (jbuilder.configurator))))
|
|
@ -0,0 +1,6 @@
|
|||
let () =
|
||||
Configurator.main ~name:"config" (fun t ->
|
||||
match Configurator.ocaml_config_var t "version" with
|
||||
| None -> failwith "version is absent"
|
||||
| Some _ -> print_endline "version is present"
|
||||
)
|
|
@ -0,0 +1,5 @@
|
|||
(jbuild_version 1)
|
||||
|
||||
(executable
|
||||
((name run)
|
||||
(libraries (jbuilder.configurator))))
|
|
@ -0,0 +1,15 @@
|
|||
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
|
||||
]
|
||||
);
|
||||
print_endline "Successfully import #define's"
|
||||
)
|
|
@ -0,0 +1,11 @@
|
|||
Show that config values are present
|
||||
$ jbuilder exec config/run.exe
|
||||
version is present
|
||||
|
||||
We're able to compile C program sucessfully
|
||||
$ jbuilder exec c_test/run.exe
|
||||
Successfully compiled c program
|
||||
|
||||
Importing #define's from code is successful
|
||||
$ jbuilder exec import-define/run.exe
|
||||
Successfully import #define's
|
Loading…
Reference in New Issue