Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
verimag
synchrone
rdbg
Commits
67b87872
Commit
67b87872
authored
Oct 27, 2022
by
erwan
Browse files
test: make sure to wait long enough batch mode (rdbg -in)
parent
17268740
Pipeline
#114017
passed with stages
in 6 minutes and 43 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
bin/rdbgwrap.ml
View file @
67b87872
(* Time-stamp: <modified the 2
0/06
/2022 (at 1
4:05
) by Erwan Jahier> *)
(* Time-stamp: <modified the 2
7/10
/2022 (at 1
6:46
) by Erwan Jahier> *)
(** A wrapper around rdbg-top to
- avoid typing "()" and ";;"
- generate initial sessions
...
...
@@ -84,20 +84,28 @@ let rdbg_cmd = ref "*"
let
rec
my_read_line
ic
=
try
let
str
=
flush
stdout
;
input_line
ic
in
(* Printf.printf "rdbg: my_read_line <- '%s'\n" str; *)
match
str
with
|
"#auto"
->
add_semi_ref
:=
true
;
print_string
"type '#auto_off' to disable automatic semicolumn mode
\n
"
;
flush
stdout
;
my_read_line
ic
add_semi_ref
:=
true
;
print_string
"type '#auto_off' to disable automatic semicolumn mode
\n
"
;
flush
stdout
;
my_read_line
ic
|
"#auto_off"
->
add_semi_ref
:=
false
;
print_string
"type '#auto' to enable automatic semicolumn mode
\n
"
;
flush
stdout
;
my_read_line
ic
add_semi_ref
:=
false
;
print_string
"type '#auto' to enable automatic semicolumn mode
\n
"
;
flush
stdout
;
my_read_line
ic
|
""
->
if
!
rdbg_cmd
=
""
then
my_read_line
ic
else
!
rdbg_cmd
|
_
->
str
with
End_of_file
->
Unix
.
sleep
1
;
"q"
with
End_of_file
->
if
!
input_file
<>
None
then
(
print_string
"End_of_file: wait a little...
\n
"
;
flush
stdout
;
Unix
.
sleep
2
;
(* should be higher than the Thread.delay below *)
);
"q"
let
log_oc
=
if
!
log
then
open_out
"rdbg.log"
else
stdout
...
...
@@ -314,19 +322,19 @@ let rec myloop ic_stdout ic_stderr ic oc str =
if
start_with
str
"man"
then
"RdbgMain.man"
else
(* sugaring help and apropos *)
if
start_with
str
"help "
&&
not
(
String
.
contains
str
'\"'
)
then
Printf
.
sprintf
"help
\"
%s
\"
"
(
String
.
sub
str
5
(
s
-
5
))
else
if
start_with
str
"h "
&&
not
(
String
.
contains
str
'\"'
)
then
Printf
.
sprintf
"help
\"
%s
\"
"
(
String
.
sub
str
2
(
s
-
2
))
else
if
start_with
str
"apropos "
&&
not
(
String
.
contains
str
'\"'
)
then
Printf
.
sprintf
"apropos
\"
%s
\"
"
(
String
.
sub
str
8
(
s
-
8
))
else
if
start_with
str
"a "
&&
not
(
String
.
contains
str
'\"'
)
then
Printf
.
sprintf
"apropos
\"
%s
\"
"
(
String
.
sub
str
2
(
s
-
2
))
else
if
str
=
"a"
||
str
=
"apropos"
then
Printf
.
sprintf
"apropos
\"\"
"
else
if
str
=
"h"
||
str
=
"help"
then
Printf
.
sprintf
"RdbgMain.man"
else
str
if
start_with
str
"help "
&&
not
(
String
.
contains
str
'\"'
)
then
Printf
.
sprintf
"help
\"
%s
\"
"
(
String
.
sub
str
5
(
s
-
5
))
else
if
start_with
str
"h "
&&
not
(
String
.
contains
str
'\"'
)
then
Printf
.
sprintf
"help
\"
%s
\"
"
(
String
.
sub
str
2
(
s
-
2
))
else
if
start_with
str
"apropos "
&&
not
(
String
.
contains
str
'\"'
)
then
Printf
.
sprintf
"apropos
\"
%s
\"
"
(
String
.
sub
str
8
(
s
-
8
))
else
if
start_with
str
"a "
&&
not
(
String
.
contains
str
'\"'
)
then
Printf
.
sprintf
"apropos
\"
%s
\"
"
(
String
.
sub
str
2
(
s
-
2
))
else
if
str
=
"a"
||
str
=
"apropos"
then
Printf
.
sprintf
"apropos
\"\"
"
else
if
str
=
"h"
||
str
=
"help"
then
Printf
.
sprintf
"RdbgMain.man"
else
str
in
let
str
=
if
((
str
.
[
0
]
=
'
'
||
start_with
str
"let "
)
&&
not
(
has_semicol
str
))
...
...
@@ -334,7 +342,7 @@ let rec myloop ic_stdout ic_stderr ic oc str =
in
let
add_par
=
if
String
.
contains
str
'
'
then
""
else
"()"
in
let
semicol
=
if
(
!
add_semi_ref
&&
str
.
[
0
]
<>
'
'
)
&&
not
(
has_semicol
str
)
then
";;"
else
""
then
";;"
else
""
in
if
start_with
str
"wait "
then
(
(* useful for rdbg scripts run via --input when the RP don't wait before exiting *)
...
...
@@ -342,9 +350,9 @@ let rec myloop ic_stdout ic_stderr ic oc str =
let
t
=
try
int_of_string
t
with
_
->
Printf
.
printf
"fail to parse int (do not use spaces before your int)
\n
%!"
;
1
in
Printf
.
printf
"wait %d seconds (%s)
\n
%!"
t
str
;
Unix
.
sleep
t
;
myloop
ic_stdout
ic_stderr
ic
oc
(
my_read_line
ic
)
Printf
.
printf
"wait %d seconds (%s)
\n
%!"
t
str
;
Unix
.
sleep
t
;
myloop
ic_stdout
ic_stderr
ic
oc
(
my_read_line
ic
)
)
else
if
str
=
"q"
||
str
=
"quit"
then
(
ignore
(
Unix
.
close_process_full
(
ic_stdout
,
oc
,
ic_stderr
));
flush_all
()
;
...
...
@@ -352,7 +360,7 @@ let rec myloop ic_stdout ic_stderr ic oc str =
else
(
rdbg_cmd
:=
if
!
rdbg_cmd
=
"*"
then
""
else
str
;
let
str
=
str
^
add_par
^
semicol
in
if
!
verbose
then
if
!
verbose
||
!
RdbgWrapperArgs
.
input_file
<>
None
then
Printf
.
printf
"rdbg sends to the ocaml toplevel the string:
\"
%s
\"\n
%!"
str
;
output_string
oc
(
str
^
"
\n
"
);
flush
oc
;
...
...
@@ -384,11 +392,11 @@ let rdbg_session_manager outc =
read user input,
create a new session if asked
launch the chosen session
*)
*)
let
ic
,
close_ic
=
match
!
RdbgWrapperArgs
.
input_file
with
|
None
->
stdin
,
fun
()
->
()
|
Some
f
->
if
Sys
.
file_exists
f
then
(
if
Sys
.
file_exists
f
then
(
Printf
.
printf
"rdbg: reading commands from %s.
\n
%!"
f
;
let
ic
=
open_in
f
in
ic
,
(
fun
()
->
Printf
.
printf
"rdbg: %s have been processed.
\n
%!"
f
;
close_in
ic
)
...
...
@@ -411,7 +419,7 @@ let rdbg_session_manager outc =
if
!
first
then
Thread
.
delay
1
.
5
;
(* not a big deal, but otherwise, the ocamltop process do not
have the time to write on its stdout, and only the first read
can take ca
s
e of hiding the ocaml loading msgs. *)
can take ca
r
e of hiding the ocaml loading msgs. *)
flush_all
()
;
Thread
.
delay
0
.
05
;
read_rdbgtop_out
oc
ic_stdout
ic_stderr
!
first
!
first
;
...
...
exemples/session/test1-session
View file @
67b87872
ni 189
cg
f
cg
lib/rdbgWrapperArgs.ml
View file @
67b87872
(* Time-stamp: <modified the
30/06
/202
1
(at 1
0:22
) by Erwan Jahier> *)
(* Time-stamp: <modified the
26/10
/202
2
(at 1
6:10
) by Erwan Jahier> *)
let
rdbg_tuning_file
=
"my-rdbg-tuning.ml"
let
rdbg_cmds_file
=
"rdbg-cmds.ml"
...
...
@@ -141,7 +141,7 @@ let (mkoptab : unit -> unit) =
[
"Set the output file name (currently,
\"
"
^
!
output_file
^
"
\"
)"
];
mkopt
[
"-in"
;
"--input"
]
~
cat
:
More
(
Arg
.
String
(
fun
str
->
input_file
:=
Some
str
))
[
"Read rdbg command in a file and exit
s
"
];
[
"Read rdbg command in a file and exit"
];
mkopt
[
"-norif"
;
"--no-rif"
]
~
cat
:
More
(
Arg
.
Unit
(
fun
()
->
no_rif
:=
true
))
[
"Do not print data in the rif file (useful when there are too many variables)"
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment