diff --git a/tests/crowbar/test_ghost_cfg.ml b/tests/crowbar/test_ghost_cfg.ml index 95bd01fd9dc465fe4585dd7a90d1d913e8d860c5..5395704f25785573813d99aff2ec956e3939248b 100644 --- a/tests/crowbar/test_ghost_cfg.ml +++ b/tests/crowbar/test_ghost_cfg.ml @@ -512,12 +512,18 @@ let check_file (env, file) = let prj2 = Project.create "copy" in Project.set_current prj2; Kernel.Files.set [ Filepath.Normalized.of_string file_name ]; - File.init_from_cmdline (); - let copy_buf = Buffer.create 150 in - let fmt = Format.formatter_of_buffer copy_buf in - let f = Globals.Functions.find_by_name "f" in - Kernel_function.pretty fmt f; - if Buffer.contents norm_buf <> Buffer.contents copy_buf then begin + let parse_success = + try + File.init_from_cmdline (); true + with + Log.AbortError _ -> ignore_deferred_errors (); false + in + if parse_success then begin + let copy_buf = Buffer.create 150 in + let fmt = Format.formatter_of_buffer copy_buf in + let f = Globals.Functions.find_by_name "f" in + Kernel_function.pretty fmt f; + if Buffer.contents norm_buf <> Buffer.contents copy_buf then begin let norm = open_out (file_name ^ ".norm.c") in Buffer.output_buffer norm norm_buf; flush norm; @@ -528,6 +534,9 @@ let check_file (env, file) = close_out copy; report file_name "Found ghost code not well pretty-printed" end else true + end else begin + report file_name "Error during re-parsing of pretty-printed code" + end end else report file_name "Found ghost code that should have been accepted"