From 96b8cec2aa3c4e2a5bdd547423e68769a1111608 Mon Sep 17 00:00:00 2001 From: Assaf Gordon Date: Sat, 22 Apr 2017 14:06:56 -0400 Subject: [PATCH] tests: new function remove_cr_inplace in init.cfg When testing on Windows OSes, remove any CR (\r) characters from output files (before comparing them to expected output). This functionality was used by the old-style tests, embedded directly in 'Makefile.tests'. * init.cfg: (remove_cr_inplace): New function. --- init.cfg | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/init.cfg b/init.cfg index 915a260..a15041c 100644 --- a/init.cfg +++ b/init.cfg @@ -110,3 +110,13 @@ require_valid_ja_eucjp_locale_() local n=$(printf '\262C' | LC_ALL="$1" test-mbrtowc) test "x$n" = "x-2,-1" || skip_ "locale '$1' is buggy" } + +# When testing on a Windows machine, sed might output +# line endings as CR,LF (\r\n) pairs - which will +# then fail comparison with the expected output files. +# +# This function removes the CR (\r) characters from the given input file. +remove_cr_inplace() +{ + sed -i -e "s/\r//g" "$@" || framework_failure_ +}