Passes ~current:(ref 0) to Arg.parse_argv, to ensure ~argv is parsed from the beginning each time, in case OMP is linked into a larger process that calls into OMP multiple times.
Adds ?exit_on_error to functions that might parse arguments (i.e., act as top-level functions of the driver). The default value is ~exit_on_error:true, which roughly mimics the behavior before this PR. If ~exit_on_error:false is provided, none of the functions ever call exit. Instead, they raise (leak) the exceptions that would have terminated the process. I decided to add this to all functions because there are three top-level "entry points" into Driver, and they call each other, so they all need this change. It is modeled after Alcotest.run.
This changes the result type of Driver.run_main and Driver.run_as_ppx_rewriter from 'a to unit, because these functions no longer call exit in all paths unconditionally.
The exit behavior is also changed in a few other ways, even with ~exit_on_error:true:
run_main no longer calls exit 0 at its ends, so execution continues in the caller.
Exit codes are more disciplined. Previously, the exit code was sometimes 1 on Arg.Help, and 1 on Arg.Bad. In the former case, the help message would be printed to STDERR. Now, Arg.Help always prints to STDOUT, and the exit code is 0, and the exit code for Arg.Bad is always 2. This is in accordance with convention and this code in Arg.
Fixes #83.
~current:(ref 0)
toArg.parse_argv
, to ensure~argv
is parsed from the beginning each time, in case OMP is linked into a larger process that calls into OMP multiple times.?exit_on_error
to functions that might parse arguments (i.e., act as top-level functions of the driver). The default value is~exit_on_error:true
, which roughly mimics the behavior before this PR. If~exit_on_error:false
is provided, none of the functions ever callexit
. Instead, they raise (leak) the exceptions that would have terminated the process. I decided to add this to all functions because there are three top-level "entry points" intoDriver
, and they call each other, so they all need this change. It is modeled afterAlcotest.run
.This changes the result type of
Driver.run_main
andDriver.run_as_ppx_rewriter
from'a
tounit
, because these functions no longer callexit
in all paths unconditionally.The
exit
behavior is also changed in a few other ways, even with~exit_on_error:true
:run_main
no longer callsexit 0
at its ends, so execution continues in the caller.Arg.Help
, and 1 onArg.Bad
. In the former case, the help message would be printed to STDERR. Now,Arg.Help
always prints to STDOUT, and the exit code is 0, and the exit code forArg.Bad
is always 2. This is in accordance with convention and this code inArg
.