Skip to content
Snippets Groups Projects
Commit 8f573979 authored by Patrick Baudin's avatar Patrick Baudin
Browse files

[Ptests] fixes #1035

parent b893d0cd
No related branches found
No related tags found
No related merge requests found
...@@ -694,7 +694,7 @@ let launch command_string = ...@@ -694,7 +694,7 @@ let launch command_string =
exit 1 exit 1
module Test_config: sig module Test_config: sig
val scan_directives: val scan_directives: drop:bool ->
SubDir.t -> file:string -> Scanf.Scanning.in_channel -> config -> config SubDir.t -> file:string -> Scanf.Scanning.in_channel -> config -> config
val current_config: unit -> config val current_config: unit -> config
val scan_test_file: config -> SubDir.t -> string -> config val scan_test_file: config -> SubDir.t -> string -> config
...@@ -805,12 +805,12 @@ end = struct ...@@ -805,12 +805,12 @@ end = struct
(* how to process options *) (* how to process options *)
let config_exec ~once ~file:_ dir s current = let config_exec ~once ~drop:_ ~file:_ dir s current =
{ current with { current with
dc_execnow = dc_execnow =
scan_execnow ~once dir current.dc_timeout s :: current.dc_execnow } scan_execnow ~once dir current.dc_timeout s :: current.dc_execnow }
let config_macro ~file _dir s current = let config_macro ~drop:_ ~file _dir s current =
let regex = Str.regexp "[ \t]*\\([^ \t@]+\\)\\([ \t]+\\(.*\\)\\|$\\)" in let regex = Str.regexp "[ \t]*\\([^ \t@]+\\)\\([ \t]+\\(.*\\)\\|$\\)" in
Mutex.lock str_mutex; Mutex.lock str_mutex;
if Str.string_match regex s 0 then begin if Str.string_match regex s 0 then begin
...@@ -841,30 +841,29 @@ end = struct ...@@ -841,30 +841,29 @@ end = struct
lock_printf "%% - Macro %s for -load-module with definition %s@." name def; lock_printf "%% - Macro %s for -load-module with definition %s@." name def;
Macros.add_list [name, def] macros Macros.add_list [name, def] macros
let add_make_modules ~file dir deps current = let add_make_modules ~drop ~file dir deps current =
List.fold_left (fun acc s -> List.fold_left (fun acc s ->
let make_cmd = Macros.expand current.dc_macros "@PTEST_MAKE_MODULE@" in let make_cmd = Macros.expand current.dc_macros "@PTEST_MAKE_MODULE@" in
let acc = config_exec ~once:true ~file dir (make_cmd ^ " " ^ s) acc in let acc = config_exec ~once:true ~drop ~file dir (make_cmd ^ " " ^ s) acc in
{ acc with dc_deps_module = s :: acc.dc_deps_module }) { acc with dc_deps_module = s :: acc.dc_deps_module })
current deps current deps
let config_module ~file dir s current = let config_module ~drop ~file dir s current =
let s = Macros.expand current.dc_macros s in let s = Macros.expand current.dc_macros s in
let deps = List.map (fun s -> "@PTEST_DIR@/" ^ (Filename.remove_extension s) ^ ".cmxs") let deps = List.map (fun s -> "@PTEST_DIR@/" ^ (Filename.remove_extension s) ^ ".cmxs")
(str_split_list s) (str_split_list s)
in in
let current = add_make_modules ~file dir deps current in let current = add_make_modules ~drop ~file dir deps current in
{ current with dc_deps_module = deps @ current.dc_deps_module; { current with dc_deps_module = deps @ current.dc_deps_module;
dc_macros = set_load_modules deps current.dc_macros } dc_macros = set_load_modules deps current.dc_macros }
let config_options = let config_options =
[ "CMD", [ "CMD",
(fun ~file:_ _ s current -> (fun ~drop:_ ~file:_ _ s current -> { current with dc_default_toplevel = s});
{ current with dc_default_toplevel = s});
"OPT", "OPT",
(fun ~file _ s current -> (fun ~drop ~file _ s current ->
if not current.dc_framac then if not (drop || current.dc_framac) then
lock_eprintf lock_eprintf
"%s: a NOFRAMAC directive has been defined before a sub-test defined by a 'OPT' directive (That NOFRAMAC directive could be misleading.).@." "%s: a NOFRAMAC directive has been defined before a sub-test defined by a 'OPT' directive (That NOFRAMAC directive could be misleading.).@."
file; file;
...@@ -881,8 +880,8 @@ end = struct ...@@ -881,8 +880,8 @@ end = struct
dc_commands = t :: current.dc_commands }); dc_commands = t :: current.dc_commands });
"STDOPT", "STDOPT",
(fun ~file _ s current -> (fun ~drop ~file _ s current ->
if not current.dc_framac then if not (drop || current.dc_framac) then
lock_eprintf lock_eprintf
"%s: a NOFRAMAC directive has been defined before a sub-test defined by a 'STDOPT' directive (That NOFRAMAC directive could be misleading.).@." "%s: a NOFRAMAC directive has been defined before a sub-test defined by a 'STDOPT' directive (That NOFRAMAC directive could be misleading.).@."
file; file;
...@@ -901,24 +900,24 @@ end = struct ...@@ -901,24 +900,24 @@ end = struct
dc_default_log = !default_parsing_env.current_default_log }); dc_default_log = !default_parsing_env.current_default_log });
"FILEREG", "FILEREG",
(fun ~file:_ _ s current -> { current with dc_test_regexp = s }); (fun ~drop:_ ~file:_ _ s current -> { current with dc_test_regexp = s });
"FILTER", "FILTER",
(fun ~file:_ _ s current -> { current with dc_filter = Some s }); (fun ~drop:_ ~file:_ _ s current -> { current with dc_filter = Some s });
"EXIT", "EXIT",
(fun ~file:_ _ s current -> { current with dc_exit_code = Some s }); (fun ~drop:_ ~file:_ _ s current -> { current with dc_exit_code = Some s });
"GCC", "GCC",
(fun ~file _ _ acc -> (fun ~drop ~file _ _ acc ->
lock_eprintf "%s: GCC directive (DEPRECATED)@." file; if not drop then lock_eprintf "%s: GCC directive (DEPRECATED)@." file;
acc); acc);
"COMMENT", "COMMENT",
(fun ~file:_ _ _ acc -> acc); (fun ~drop:_ ~file:_ _ _ acc -> acc);
"DONTRUN", "DONTRUN",
(fun ~file:_ _ s current -> { current with dc_dont_run = true }); (fun ~drop:_ ~file:_ _ s current -> { current with dc_dont_run = true });
"EXECNOW", config_exec ~once:true; "EXECNOW", config_exec ~once:true;
"EXEC", config_exec ~once:false; "EXEC", config_exec ~once:false;
...@@ -928,22 +927,21 @@ end = struct ...@@ -928,22 +927,21 @@ end = struct
"MODULE", config_module; "MODULE", config_module;
"LOG", "LOG",
(fun ~file:_ _ s current -> (fun ~drop:_ ~file:_ _ s current -> { current with dc_default_log = s :: current.dc_default_log });
{ current with dc_default_log = s :: current.dc_default_log });
"TIMEOUT", "TIMEOUT",
(fun ~file:_ _ s current -> { current with dc_timeout = s }); (fun ~drop:_ ~file:_ _ s current -> { current with dc_timeout = s });
"NOFRAMAC", "NOFRAMAC",
(fun ~file _ _ current -> (fun ~drop ~file _ _ current ->
if current.dc_commands <> [] && current.dc_framac then if not drop && current.dc_commands <> [] && current.dc_framac then
lock_eprintf lock_eprintf
"%s: a NOFRAMAC directive has the effect of ignoring previous defined sub-tests (by some 'OPT' or 'STDOPT' directives that seems misleading). @." "%s: a NOFRAMAC directive has the effect of ignoring previous defined sub-tests (by some 'OPT' or 'STDOPT' directives that seems misleading). @."
file; file;
{ current with dc_commands = []; dc_framac = false; }); { current with dc_commands = []; dc_framac = false; });
] ]
let scan_directives dir ~file scan_buffer default = let scan_directives ~drop dir ~file scan_buffer default =
set_default_parsing_env default; set_default_parsing_env default;
let r = ref { default with dc_commands = [] } in let r = ref { default with dc_commands = [] } in
let treat_line s = let treat_line s =
...@@ -951,7 +949,7 @@ end = struct ...@@ -951,7 +949,7 @@ end = struct
Scanf.sscanf s "%[ *]%[A-Za-z0-9]: %s@\n" Scanf.sscanf s "%[ *]%[A-Za-z0-9]: %s@\n"
(fun _ name opt -> (fun _ name opt ->
try try
r := (List.assoc name config_options) ~file dir opt !r r := (List.assoc name config_options) ~drop ~file dir opt !r
with Not_found -> with Not_found ->
lock_eprintf "@[%s: unknown configuration option: %s@\n%!@]" file name) lock_eprintf "@[%s: unknown configuration option: %s@\n%!@]" file name)
with with
...@@ -1001,14 +999,14 @@ end = struct ...@@ -1001,14 +999,14 @@ end = struct
let configs = Str.split split_config (String.trim names) in let configs = Str.split split_config (String.trim names) in
if List.exists is_current_config configs then if List.exists is_current_config configs then
(* Found options for current config! *) (* Found options for current config! *)
scan_directives dir ~file:f scan_buffer default scan_directives ~drop:false dir ~file:f scan_buffer default
else (* config name does not match: eat config and continue. else (* config name does not match: eat config and continue.
But only if the comment is still opened by the end of But only if the comment is still opened by the end of
the line and we are indeed reading a config the line and we are indeed reading a config
*) *)
(if List.exists is_config configs && (if List.exists is_config configs &&
not (str_string_match end_comment names 0) then not (str_string_match end_comment names 0) then
ignore (scan_directives dir ~file:f scan_buffer default); ignore (scan_directives ~drop:true dir ~file:f scan_buffer default);
scan_config ())) scan_config ()))
in in
try try
...@@ -1028,7 +1026,7 @@ end = struct ...@@ -1028,7 +1026,7 @@ end = struct
if Sys.file_exists general_config_file if Sys.file_exists general_config_file
then begin then begin
let scan_buffer = Scanf.Scanning.from_file general_config_file in let scan_buffer = Scanf.Scanning.from_file general_config_file in
scan_directives scan_directives ~drop:false
(SubDir.create ~with_subdir:false Filename.current_dir_name) (SubDir.create ~with_subdir:false Filename.current_dir_name)
~file:general_config_file ~file:general_config_file
scan_buffer scan_buffer
...@@ -1840,7 +1838,7 @@ let () = ...@@ -1840,7 +1838,7 @@ let () =
if Sys.file_exists file if Sys.file_exists file
then begin then begin
let scan_buffer = Scanf.Scanning.from_file file in let scan_buffer = Scanf.Scanning.from_file file in
Test_config.scan_directives directory Test_config.scan_directives ~drop:false directory
~file scan_buffer dir_config ~file scan_buffer dir_config
end end
else dir_config else dir_config
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment