From 03e8d25f5a3e47d9c858910ddda9a5a686cf4fe1 Mon Sep 17 00:00:00 2001 From: Gabriel Scherer Date: Mon, 26 Feb 2018 11:27:25 +0100 Subject: ocamltest: also announce system errors as unexpected errors If you forget to commit a test file with your patch (but include it in ocamltests), ocamltest will fail (print a message to standard error and return a non-zero code), but until now it would not print the standard-format "testing ... => unexpected error" message which makes the failure visible to the summarize.awk script. This commit ensures that such early failures still result in an explicit unexpected-error message being shown in the standard way, in addition to stderr-level error reporting. --- ocamltest/main.ml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/ocamltest/main.ml b/ocamltest/main.ml index d0e441fc61..b4774c52f2 100644 --- a/ocamltest/main.ml +++ b/ocamltest/main.ml @@ -38,6 +38,13 @@ let is_test filename = | _ -> false *) +(* this primitive announce should be used for tests + that were aborted on system error before ocamltest + could parse them *) +let announce_test_error test_filename error = + Printf.printf " ... testing '%s' => unexpected error (%s)\n%!" + (Filename.basename test_filename) error + let tsl_block_of_file test_filename = let input_channel = open_in test_filename in let lexbuf = Lexing.from_channel input_channel in @@ -49,10 +56,12 @@ let tsl_block_of_file test_filename = let tsl_block_of_file_safe test_filename = try tsl_block_of_file test_filename with | Sys_error message -> - Printf.eprintf "%s\n" message; + Printf.eprintf "%s\n%!" message; + announce_test_error test_filename message; exit 1 | Parsing.Parse_error -> - Printf.eprintf "Could not read test block in %s\n" test_filename; + Printf.eprintf "Could not read test block in %s\n%!" test_filename; + announce_test_error test_filename "could not read test block"; exit 1 let print_usage () = -- cgit v1.2.1