Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a blackbox test suite for configurator #673

Merged
merged 6 commits into from
Apr 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/configurator/jbuild
Original file line number Diff line number Diff line change
@@ -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)))
Expand Down
3 changes: 2 additions & 1 deletion src/ocaml-config/jbuild
Original file line number Diff line number Diff line change
Expand Up @@ -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'")))
4 changes: 3 additions & 1 deletion src/ocaml-config/ocaml_config.mli
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 2 additions & 0 deletions src/stdune/caml/caml.ml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
(** This library is internal to jbuilder and guarantees no API stability. *)

module Filename = Filename
module String = String
module Char = Char
Expand Down
3 changes: 2 additions & 1 deletion src/stdune/caml/jbuild
Original file line number Diff line number Diff line change
@@ -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")))
3 changes: 2 additions & 1 deletion src/stdune/jbuild
Original file line number Diff line number Diff line change
@@ -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))))
5 changes: 4 additions & 1 deletion src/usexp/jbuild
Original file line number Diff line number Diff line change
@@ -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)))
Expand Down
4 changes: 3 additions & 1 deletion src/usexp/usexp.mli
Original file line number Diff line number Diff line change
@@ -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]
Expand Down
10 changes: 10 additions & 0 deletions test/blackbox-tests/jbuild
Original file line number Diff line number Diff line change
Expand Up @@ -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))))))
5 changes: 5 additions & 0 deletions test/blackbox-tests/test-cases/configurator/c_test/jbuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(jbuild_version 1)

(executable
((name run)
(libraries (jbuilder.configurator))))
15 changes: 15 additions & 0 deletions test/blackbox-tests/test-cases/configurator/c_test/run.ml
Original file line number Diff line number Diff line change
@@ -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"
)
5 changes: 5 additions & 0 deletions test/blackbox-tests/test-cases/configurator/config/jbuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(jbuild_version 1)

(executable
((name run)
(libraries (jbuilder.configurator))))
6 changes: 6 additions & 0 deletions test/blackbox-tests/test-cases/configurator/config/run.ml
Original file line number Diff line number Diff line change
@@ -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"
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(jbuild_version 1)

(executable
((name run)
(libraries (jbuilder.configurator))))
15 changes: 15 additions & 0 deletions test/blackbox-tests/test-cases/configurator/import-define/run.ml
Original file line number Diff line number Diff line change
@@ -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"
)
11 changes: 11 additions & 0 deletions test/blackbox-tests/test-cases/configurator/run.t
Original file line number Diff line number Diff line change
@@ -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