-
Notifications
You must be signed in to change notification settings - Fork 76
/
ocaml_tests.ml
190 lines (176 loc) · 4.41 KB
/
ocaml_tests.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
(**************************************************************************)
(* *)
(* OCaml *)
(* *)
(* Sebastien Hinderer, projet Gallium, INRIA Paris *)
(* *)
(* Copyright 2016 Institut National de Recherche en Informatique et *)
(* en Automatique. *)
(* *)
(* All rights reserved. This file is distributed under the terms of *)
(* the GNU Lesser General Public License version 2.1, with the *)
(* special exception on linking described in the file LICENSE. *)
(* *)
(**************************************************************************)
(* Tests specific to the OCaml compiler *)
open Tests
open Builtin_actions
open Ocaml_actions
let bytecode =
let byte_build =
[
setup_ocamlc_byte_build_env;
ocamlc_byte;
check_ocamlc_byte_output
] in
let opt_build =
[
setup_ocamlc_opt_build_env;
ocamlc_opt;
check_ocamlc_opt_output
] in
{
test_name = "bytecode";
test_run_by_default = true;
test_description = "Build bytecode program, run it and check its output";
test_actions =
(if true && Ocamltest_config.native_compiler then
opt_build
else
byte_build) @
[
run;
check_program_output;
] @
(if false && Ocamltest_config.native_compiler then
opt_build @ [compare_bytecode_programs]
else
[]
)
}
let native =
let byte_build =
[
setup_ocamlopt_byte_build_env;
ocamlopt_byte;
check_ocamlopt_byte_output;
] in
let opt_build =
[
setup_ocamlopt_opt_build_env;
ocamlopt_opt;
check_ocamlopt_opt_output;
] in
let opt_actions =
(if true then
opt_build
else
byte_build
) @
[
run;
check_program_output;
] @
(if false then
opt_build
else
[]
) in
{
test_name = "native";
test_run_by_default = true;
test_description = "Build native program, run it and check its output";
test_actions =
(if Ocamltest_config.native_compiler then opt_actions else [skip])
}
let toplevel = {
test_name = "toplevel";
test_run_by_default = false;
test_description =
"Run the program in the OCaml toplevel and check its output";
test_actions =
[
setup_ocaml_build_env;
ocaml;
check_ocaml_output;
]
}
let nattoplevel = {
test_name = "toplevel.opt";
test_run_by_default = false;
test_description =
"Run the program in the native OCaml toplevel (ocamlnat) and check its \
output";
test_actions =
[
shared_libraries;
setup_ocamlnat_build_env;
ocamlnat;
check_ocamlnat_output;
]
}
let expect =
{
test_name = "expect";
test_run_by_default = false;
test_description =
"Run expect tests in the program in the OCaml toplevel and check their \
output";
test_actions =
[
setup_simple_build_env;
run_expect;
check_program_output
]
}
let ocamldoc =
{
test_name = "ocamldoc";
test_run_by_default = false;
test_description = "Run ocamldoc on the test and compare with the reference";
test_actions =
if Ocamltest_config.ocamldoc then
[
shared_libraries;
setup_ocamldoc_build_env;
run_ocamldoc;
check_program_output;
check_ocamldoc_output
]
else
[ skip ]
}
let asmgen_skip_on_bytecode_only =
Actions_helpers.skip_with_reason "native compiler disabled"
let msvc64 =
Ocamltest_config.ccomptype = "msvc" && Ocamltest_config.arch="amd64"
let asmgen_skip_on_msvc64 =
Actions_helpers.skip_with_reason "not ported to MSVC64 yet"
let asmgen_actions =
if not Ocamltest_config.native_compiler then [asmgen_skip_on_bytecode_only]
else if msvc64 then [asmgen_skip_on_msvc64]
else [
setup_simple_build_env;
codegen;
cc;
]
let asmgen =
{
test_name = "asmgen";
test_run_by_default = false;
test_description =
"Generate the assembly for the test program; and also use the C compiler \
to make the executable";
test_actions = asmgen_actions
}
let init () =
List.iter register
[
bytecode;
native;
toplevel;
nattoplevel;
expect;
ocamldoc;
asmgen;
]