Skip to content

Commit

Permalink
[runtest]: new CLI argument --bin
Browse files Browse the repository at this point in the history
This argument tells `runtest` which binary to use for EasyCrypt.

It takes precedence over what is found in the INI file (in default/bin).

Moreover, `easycrypt runtest` automatically set --bin to itself. This
allows to select the correct version of EasyCrypt without having to tweak
the INI file accordingly.
  • Loading branch information
strub committed Sep 6, 2023
1 parent 7d59877 commit 8243791
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ ECEXTRA ?= --report=report.log
ECPROVERS ?= Alt-Ergo Z3 CVC4
CHECKPY ?=
CHECK := $(CHECKPY) scripts/testing/runtest
CHECK += --bin-args="$(ECARGS)" --bin-args="$(ECPROVERS:%=-p %)"
CHECK += --bin=./ec.native --bin-args="$(ECARGS)"
CHECK += --bin-args="$(ECPROVERS:%=-p %)"
CHECK += --timeout="$(ECTOUT)" --jobs="$(ECJOBS)"
CHECK += $(ECEXTRA) config/tests.config

Expand Down
3 changes: 0 additions & 3 deletions config/tests.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[default]
bin = ./ec.native

[test-prelude]
args = -boot
okdirs = theories/prelude
Expand Down
15 changes: 13 additions & 2 deletions scripts/testing/runtest
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ def _options():

parser = OptionParser()

parser.add_option(
'', '--bin',
action = 'store',
metavar = 'BIN',
default = None,
help = 'EasyCrypt binary to use')

parser.add_option(
'', '--bin-args',
action = 'append',
Expand Down Expand Up @@ -148,8 +155,12 @@ def _options():
targets.append(name)
return targets

options.bin = config.get('default', 'bin')
options.args = config.get('default', 'args').split()
options.bin = cmdopt.bin

if options.bin is None:
options.bin = config.get('default', 'bin', fallback = 'easycrypt')

options.args = config.get('default', 'args', fallback = '').split()
options.targets = resolve_targets(args[1:])

if options.report is None:
Expand Down
7 changes: 6 additions & 1 deletion src/ec.ml
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,12 @@ let main () =
| None ->
EcRelocate.resource ["commands"] in
let cmd = Filename.concat root "runtest" in
let args = ["runtest"; input.runo_input] @ input.runo_scenarios in
let args = [
"runtest";
Format.sprintf "--bin=%s" Sys.executable_name;
input.runo_input
] @ input.runo_scenarios
in
Format.eprintf "Executing: %s@." (String.concat " " (cmd :: args));
Unix.execv cmd (Array.of_list args)
end
Expand Down

0 comments on commit 8243791

Please sign in to comment.