Mesa (master): glcpp: Fix glcpp-test-cr-lf "make check" test for Mac OS X

Carl Worth cworth at kemper.freedesktop.org
Wed Aug 20 23:44:17 UTC 2014


Module: Mesa
Branch: master
Commit: f90b7e0f2bee56af22edeebfea292ab960ce0628
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=f90b7e0f2bee56af22edeebfea292ab960ce0628

Author: Carl Worth <cworth at cworth.org>
Date:   Mon Aug 18 16:26:34 2014 -0700

glcpp: Fix glcpp-test-cr-lf "make check" test for Mac OS X

There were two problems with the way this script used sed on OS X:

  1. The OS X sed doesn't interpret "\r" in a replacement list as a
     carriage-return character, (instead it was inserting a literal
     'r' character).

     We fix this by putting an actual ^M character into the source of
     the script, (rather than a two-character escape sequence hoping
     for sed to do the right thing).

  2. When generating the test files with LF-CR ("\n\r") newlines, the
     OS X sed was adding an undesired final newline ("\n") at the end
     of the file. We avoid this by first using sed to add the ^M
     before the newlines, then using tr to swap the \r and \n
     characters. This way, sed never sees any lines ending with
     anything but \n, so it doesn't get confused and doesn't add any
     bogus extra newlines.

Tested-by: Vinson Lee <vlee at freedesktop.org>

Vinson's testing confirmed that this patch fixes FreeBSD as well.

---

 src/glsl/glcpp/tests/glcpp-test-cr-lf |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/glsl/glcpp/tests/glcpp-test-cr-lf b/src/glsl/glcpp/tests/glcpp-test-cr-lf
index edaa29d..7988c05 100755
--- a/src/glsl/glcpp/tests/glcpp-test-cr-lf
+++ b/src/glsl/glcpp/tests/glcpp-test-cr-lf
@@ -111,7 +111,7 @@ rm -rf ./subtest-cr-lf
 mkdir subtest-cr-lf
 for file in "$testdir"/*.c; do
     base=$(basename "$file")
-    sed -e 's/$/\r/' < "$file" > subtest-cr-lf/"$base"
+    sed -e 's/$/
/' < "$file" > subtest-cr-lf/"$base"
     cp subtest-lf/"$base".out subtest-cr-lf/"$base".expected
 done
 
@@ -124,7 +124,7 @@ rm -rf ./subtest-lf-cr
 mkdir subtest-lf-cr
 for file in "$testdir"/*.c; do
     base=$(basename "$file")
-    tr "\n" "\r" < "$file" | sed -e 's/\r/\n\r/g' > subtest-lf-cr/"$base"
+    sed -e 's/$/
/' < "$file" | tr "\n\r" "\r\n" > subtest-lf-cr/"$base"
     cp subtest-lf/"$base".out subtest-lf-cr/"$base".expected
 done
 




More information about the mesa-commit mailing list