Skip to content

Commit 36e617d

Browse files
committed
[CLI]: ec-runtest is now accessible via a CLI subcommand
- the subcommand is named `runtest` - the real script is now in `<libexec>/easycrypt/commands/`
1 parent 796cc2d commit 36e617d

File tree

8 files changed

+66
-16
lines changed

8 files changed

+66
-16
lines changed

dune

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
(dirs src theories examples scripts)
22

3+
(install
4+
(section (site (easycrypt commands)))
5+
(files (scripts/testing/runtest as runtest)))
6+
37
(install
48
(section (bin))
5-
(files (scripts/testing/runtest as ec-runtest)))
9+
(files (scripts/testing/bin-ec-runtest as ec-runtest)))

dune-project

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
(package
1212
(name easycrypt)
13-
(sites (lib theories))
13+
(sites (lib theories) (libexec commands))
1414
(depends
1515
(ocaml (>= 4.08.0))
1616
(batteries (>= 3))

scripts/testing/bin-ec-runtest

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#! /bin/bash
2+
3+
exec $(dirname $0)/easycrypt runtest "$@"

src/dune

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
(public_name easycrypt)
1010
(name ec)
1111
(promote (until-clean))
12-
(libraries batteries camlp-streams dune-build-info inifiles why3 yojson zarith))
12+
(libraries batteries camlp-streams cmdliner dune-build-info inifiles why3 yojson zarith))
1313

1414
(ocamllex ecLexer)
1515

src/ec.ml

+22
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,24 @@ let main () =
132132

133133
in (conffile, EcOptions.parse_cmdline ?ini Sys.argv) in
134134

135+
(* Execution of eager commands *)
136+
begin
137+
match options.o_command with
138+
| `Runtest input -> begin
139+
let root =
140+
match EcRelocate.sourceroot with
141+
| Some root ->
142+
List.fold_left Filename.concat root ["scripts"; "testing"]
143+
| None ->
144+
EcRelocate.resource ["commands"] in
145+
let cmd = Filename.concat root "runtest" in
146+
Format.eprintf "Executing: %s %s@." cmd input.runo_input;
147+
Unix.execv cmd [| "runtest"; input.runo_input |]
148+
end
149+
150+
| _ -> ()
151+
end;
152+
135153
(* chrdir_$PATH if in reloc mode (FIXME / HACK) *)
136154
let relocdir =
137155
match options.o_options.o_reloc with
@@ -266,6 +284,10 @@ let main () =
266284
Some name, terminal, false, cmpopts.cmpo_noeco)
267285

268286
end
287+
288+
| `Runtest _ ->
289+
(* Eagerly executed *)
290+
assert false
269291
in
270292

271293
(match input with

src/ecOptions.ml

+23-9
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ open EcMaps
44

55
(* -------------------------------------------------------------------- *)
66
type command = [
7-
| `Compile of cmp_option
8-
| `Cli of cli_option
9-
| `Config
10-
| `Why3Config
11-
]
7+
| `Compile of cmp_option
8+
| `Cli of cli_option
9+
| `Config
10+
| `Runtest of run_option
11+
| `Why3Config
12+
]
1213

1314
and options = {
1415
o_options : glb_options;
@@ -29,6 +30,11 @@ and cli_option = {
2930
clio_provers : prv_options;
3031
}
3132

33+
and run_option = {
34+
runo_input : string;
35+
runo_scenarios : string list;
36+
}
37+
3238
and prv_options = {
3339
prvo_maxjobs : int;
3440
prvo_timeout : int;
@@ -222,8 +228,8 @@ let specs = {
222228

223229
`Group "loader";
224230
];
225-
xp_commands = [
226231

232+
xp_commands = [
227233
("compile", "Check an EasyCrypt file", [
228234
`Group "loader";
229235
`Group "provers";
@@ -239,6 +245,8 @@ let specs = {
239245

240246
("config", "Print EasyCrypt configuration", []);
241247

248+
("runtest", "Run a test-suite", []);
249+
242250
("why3config", "Configure why3", []);
243251
];
244252

@@ -386,17 +394,23 @@ let parse ?ini argv =
386394
end
387395

388396
| "cli" ->
389-
if anons != [] then
397+
if not (List.is_empty anons) then
390398
raise (Arg.Bad "this command does not take arguments");
391399
`Cli (cli_options_of_values ?ini values)
392400

393401
| "config" ->
394-
if anons != [] then
402+
if not (List.is_empty anons) then
395403
raise (Arg.Bad "this command does not take arguments");
396404
`Config
397405

406+
| "runtest" -> begin
407+
match anons with
408+
| runo_input :: runo_scenarios -> `Runtest { runo_input; runo_scenarios; }
409+
| _ -> raise (Arg.Bad "this command expects at least one positional argument")
410+
end
411+
398412
| "why3config" ->
399-
if anons != [] then
413+
if not (List.is_empty anons) then
400414
raise (Arg.Bad "this command does not take arguments");
401415
`Why3Config
402416

src/ecOptions.mli

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
(* -------------------------------------------------------------------- *)
22
type command = [
3-
| `Compile of cmp_option
4-
| `Cli of cli_option
5-
| `Config
6-
| `Why3Config
3+
| `Compile of cmp_option
4+
| `Cli of cli_option
5+
| `Config
6+
| `Runtest of run_option
7+
| `Why3Config
78
]
89

910
and options = {
@@ -25,6 +26,11 @@ and cli_option = {
2526
clio_provers : prv_options;
2627
}
2728

29+
and run_option = {
30+
runo_input : string;
31+
runo_scenarios : string list;
32+
}
33+
2834
and prv_options = {
2935
prvo_maxjobs : int;
3036
prvo_timeout : int;

src/ecRelocate.mli

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
val sourceroot : string option
2+
val resource : string list -> string
23

34
module Sites : sig
45
val theories : string list

0 commit comments

Comments
 (0)