expect
Library
Module
Module type
Parameter
Class
Class type
type expect_match = [
]
Describe expectation about the output of the process. Lines includes the EOL (i.e. \n).
val spawn :
?verbose:bool ->
?verbose_output:( string -> unit ) ->
?timeout:float option ->
?env:string array ->
?use_stderr:bool ->
string ->
string array ->
t
spawn prg args
Start a process and monitor its output. Contrary to Unix.create_process
, you don't need to repeat the program name at the beginning of args.
Optional parameters:
~timeout
: define the default timeout, in seconds. None means that you can wait forever~env
: provide environment to run the process~use_stderr
: redirect stderr to stdout and process it through expect
val send : t -> string -> unit
Send a string to a process.
val expect :
t ->
?fmatches:( string -> 'a option ) list ->
(expect_match * 'a) list ->
'a ->
'a
expect t ~fmatches matches dflt
Waits for output of the process and match it against expectations matches
. If no expectations match at timeout, returns dflt
. You can use ~fmatch
to define while processing the output what the result is, if you find a match, return Some res
otherwise return None
. The function take into account matches
before ~fmatch
and it picks the first result which is not None
.
val close : t -> Unix.process_status
Close the process.
val with_spawn :
?verbose:bool ->
?verbose_output:( string -> unit ) ->
?timeout:float option ->
?env:string array ->
?use_stderr:bool ->
string ->
string array ->
( t -> 'a -> 'a ) ->
'a ->
'a * Unix.process_status
Take care of opening and closing the process.