SHARE
TWEET

Untitled

a guest Feb 16th, 2019 108 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. From 15bb2fd920a51c997dce0d1fec20161f2631b849 Mon Sep 17 00:00:00 2001
  2. From: Gabriel Kerneis <gabriel@kerneis.info>
  3. Date: Tue, 13 Aug 2013 09:27:25 +0100
  4. Subject: [PATCH] ocamlbuild_test: permissive match of failure_msg
  5.  
  6. ---
  7.  ocamlbuild/testsuite/level0.ml          |    1 +
  8.  ocamlbuild/testsuite/ocamlbuild_test.ml |   16 ++++++++++------
  9.  2 files changed, 11 insertions(+), 6 deletions(-)
  10.  
  11. diff --git a/ocamlbuild/testsuite/level0.ml b/ocamlbuild/testsuite/level0.ml
  12. index 23780f9..593d27e 100644
  13. --- a/ocamlbuild/testsuite/level0.ml
  14. +++ b/ocamlbuild/testsuite/level0.ml
  15. @@ -1,4 +1,5 @@
  16.  #load "unix.cma";;
  17. +#load "str.cma";;
  18.  
  19.  let ocamlbuild = try Sys.getenv "OCAMLBUILD" with Not_found -> "ocamlbuild";;
  20.  
  21. diff --git a/ocamlbuild/testsuite/ocamlbuild_test.ml b/ocamlbuild/testsuite/ocamlbuild_test.ml
  22. index 317d981..383319e 100644
  23. --- a/ocamlbuild/testsuite/ocamlbuild_test.ml
  24. +++ b/ocamlbuild/testsuite/ocamlbuild_test.ml
  25. @@ -444,13 +444,17 @@ let run ~root =
  26.          Printf.printf "\x1b[0;31m\x1b[1m[FAILED]\x1b[0m \x1b[1m%-20s\x1b[0;33m%s.\n\x1b[m%!" name
  27.            (Printf.sprintf "Command '%s' with error code %n output written to %s" cmd n log_name);
  28.        | Some failing_msg ->
  29. -        let starts_with_plus s = String.length s > 0 && s.[0] = '+' in
  30. -        let lines = List.filter (fun s -> not (starts_with_plus s)) lines in
  31. -        let msg = String.concat "\n" lines in
  32. -        if failing_msg = msg then
  33. +        let output = String.concat "\n" lines in
  34. +        let indent = Str.global_replace (Str.regexp "^") "         " in
  35. +        begin try
  36. +          let _ = Str.search_forward (Str.regexp_string failing_msg) output 0 in
  37.            Printf.printf "\x1b[0;32m\x1b[1m[PASSED]\x1b[0m \x1b[1m%-20s\x1b[0;36m%s.\n\x1b[m%!" name description
  38. -        else
  39. -          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)
  40. +        with Not_found ->
  41. +          let match_fail =
  42. +            Printf.sprintf "Failure.\nCould not find expected message:\n%s\nin output:\n%s"
  43. +            (indent failing_msg) (indent output) in
  44. +          Printf.printf "\x1b[0;31m\x1b[1m[FAILED]\x1b[0m \x1b[1m%-20s\x1b[0;33m%s\n\x1b[m%!" name  match_fail
  45. +        end
  46.        end;
  47.      | _ ->
  48.        let errors = List.concat (List.map (Match.match_with_fs ~root:full_name) matching) in
  49. --
  50. 1.7.10.4
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top