Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- From 15bb2fd920a51c997dce0d1fec20161f2631b849 Mon Sep 17 00:00:00 2001
- From: Gabriel Kerneis <gabriel@kerneis.info>
- Date: Tue, 13 Aug 2013 09:27:25 +0100
- Subject: [PATCH] ocamlbuild_test: permissive match of failure_msg
- ---
- ocamlbuild/testsuite/level0.ml | 1 +
- ocamlbuild/testsuite/ocamlbuild_test.ml | 16 ++++++++++------
- 2 files changed, 11 insertions(+), 6 deletions(-)
- diff --git a/ocamlbuild/testsuite/level0.ml b/ocamlbuild/testsuite/level0.ml
- index 23780f9..593d27e 100644
- --- a/ocamlbuild/testsuite/level0.ml
- +++ b/ocamlbuild/testsuite/level0.ml
- @@ -1,4 +1,5 @@
- #load "unix.cma";;
- +#load "str.cma";;
- let ocamlbuild = try Sys.getenv "OCAMLBUILD" with Not_found -> "ocamlbuild";;
- diff --git a/ocamlbuild/testsuite/ocamlbuild_test.ml b/ocamlbuild/testsuite/ocamlbuild_test.ml
- index 317d981..383319e 100644
- --- a/ocamlbuild/testsuite/ocamlbuild_test.ml
- +++ b/ocamlbuild/testsuite/ocamlbuild_test.ml
- @@ -444,13 +444,17 @@ let run ~root =
- Printf.printf "\x1b[0;31m\x1b[1m[FAILED]\x1b[0m \x1b[1m%-20s\x1b[0;33m%s.\n\x1b[m%!" name
- (Printf.sprintf "Command '%s' with error code %n output written to %s" cmd n log_name);
- | Some failing_msg ->
- - let starts_with_plus s = String.length s > 0 && s.[0] = '+' in
- - let lines = List.filter (fun s -> not (starts_with_plus s)) lines in
- - let msg = String.concat "\n" lines in
- - if failing_msg = msg then
- + let output = String.concat "\n" lines in
- + let indent = Str.global_replace (Str.regexp "^") " " in
- + begin try
- + let _ = Str.search_forward (Str.regexp_string failing_msg) output 0 in
- Printf.printf "\x1b[0;32m\x1b[1m[PASSED]\x1b[0m \x1b[1m%-20s\x1b[0;36m%s.\n\x1b[m%!" name description
- - else
- - Printf.printf "\x1b[0;31m\x1b[1m[FAILED]\x1b[0m \x1b[1m%-20s\x1b[0;33m%s.\n\x1b[m%!" name ((Printf.sprintf "Failure with not matching message:\n%s\n!=\n%s\n") msg failing_msg)
- + with Not_found ->
- + let match_fail =
- + Printf.sprintf "Failure.\nCould not find expected message:\n%s\nin output:\n%s"
- + (indent failing_msg) (indent output) in
- + Printf.printf "\x1b[0;31m\x1b[1m[FAILED]\x1b[0m \x1b[1m%-20s\x1b[0;33m%s\n\x1b[m%!" name match_fail
- + end
- end;
- | _ ->
- let errors = List.concat (List.map (Match.match_with_fs ~root:full_name) matching) in
- --
- 1.7.10.4
Add Comment
Please, Sign In to add comment