From 6d45927b69819d7b251b64def5fdb8a2cc876377 Mon Sep 17 00:00:00 2001 From: Robin Mills Date: Sat, 10 Nov 2012 20:24:09 +0000 Subject: [PATCH] Issue: #850. Windows/cygwin fixes to SVN:2942 --- test/functions.source | 80 ++++++++++++++++++++++++------------------- test/preview-test.sh | 8 ++--- test/video-test.sh | 5 +-- 3 files changed, 49 insertions(+), 44 deletions(-) diff --git a/test/functions.source b/test/functions.source index 95c267ba..73be48dd 100644 --- a/test/functions.source +++ b/test/functions.source @@ -1,30 +1,5 @@ #!/bin/bash -## -# locale setting -export LC_ALL=C - -## -# initialize globals -this=$(basename $0 .sh) -here=$PWD -datapath="../data" -testdir="$here/tmp" -datadir="../data" - -if [ -z "$EXIV2_BINDIR" ] ; then - bin="$here/../bin" -else - bin="$EXIV2_BINDIR" -fi - -exe=$(uname) -if [ "${os:0:4}" == "CYGW" -o $exe==mingw ]; then - exe=.exe -else - unset exe -fi - ## # run a test runTest() @@ -228,7 +203,7 @@ iptcTest() cp $datapath/$dst $test #run tests - $bin/metacopy -ip $datapath/$src $test + runTest metacopy -ip $datapath/$src $test #check results diffCheck $test $good @@ -242,7 +217,7 @@ diffCheck() good=$2 #run diff and check results - diff -q --binary $test $good + diff -q --binary $diffargs $test $good if [ $? -ne 0 ]; then errors=`expr $errors + 1` else @@ -366,23 +341,59 @@ extendedTest() } ## -# prepare temp files +# prepare temp files and other variables prepareTest() { - diffargs="--strip-trailing-cr" - good="$here/data/${this}.out" - results="$here/tmp/${this}.out" - ## - # cygwin needs a private version of diff for linux compatibility + # locale setting + export LC_ALL=C + + ## + # initialize globals + this=$(basename $0 .sh) + here=$PWD + datapath="../data" + testdir="$here/tmp" + datadir="../data" + + if [ -z "$EXIV2_BINDIR" ] ; then + bin="$here/../bin" + else + bin="$EXIV2_BINDIR" + fi + os=$(uname) if [ "${os:0:4}" == "CYGW" ]; then - export "PATH=$PWD/../msvc:$PATH" export PLATFORM=cygwin else export PLATFORM=$os fi + if [ "$PLATFORM" == cygwin -o "$PLATFORM" == mingw ]; then + exe=.exe + fi + + if [ "$PLATFORM" == cygwin -o "$PLATFORM" == mingw ]; then + # We need a private version of diff for linux compatibility + diff() + { + args=() + for i in "$@"; do + if [ ${i:0:1} != '-' ]; then + i="$(cygpath -aw $i)" + fi + args+=($i) + done + "$here/../msvc/diff$exe" ${args[@]} + } + fi + + ## + # figure out arguments for diff + diffargs="--strip-trailing-cr" + good="$here/data/${this}.out" + results="$here/tmp/${this}.out" + tmpfile=$here/tmp/$this touch $tmpfile diff -q $diffargs $tmpfile $tmpfile 2>/dev/null @@ -403,7 +414,6 @@ prepareTest() da2="" fi diffargs="$da1 $da2" - } prepareTest diff --git a/test/preview-test.sh b/test/preview-test.sh index 53a270b1..1f61df05 100755 --- a/test/preview-test.sh +++ b/test/preview-test.sh @@ -1,8 +1,6 @@ #!/bin/bash # Test driver for previews -# ---------------------------------------------------------------------- -# Setup source ./functions.source ( cd "$testdir" @@ -128,14 +126,14 @@ source ./functions.source done done -) 3>&1 > "preview-test.out" 2>&1 +) 3>&1 > "$testdir/preview-test.out" 2>&1 echo "." # ---------------------------------------------------------------------- # Result -if ! diff -q $diffargs "../data/preview/preview-test.out" "preview-test.out" ; then - diff -u $diffargs "../data/preview/preview-test.out" "preview-test.out" +if ! diff -q $diffargs "$testdir/$datadir/preview/preview-test.out" "$testdir/preview-test.out" ; then + diff -u $diffargs "$testdir/$datadir/preview/preview-test.out" "$testdir/preview-test.out" exit 1 fi echo "All testcases passed." diff --git a/test/video-test.sh b/test/video-test.sh index 944d843d..4f4dde90 100755 --- a/test/video-test.sh +++ b/test/video-test.sh @@ -6,12 +6,8 @@ # video-matroska.mkv http://www.bunkus.org/videotools/mkvtoolnix/samples/vsshort-vorbis-subs.mkv # video-quicktime.mp4 http://dev.exiv2.org/attachments/362/20100709_002.mp4 -# ---------------------------------------------------------------------- -# Setup source ./functions.source -# ---------------------------------------------------------------------- -# Tests ( cd "$testdir" for file in ../data/video/video-*; do @@ -36,6 +32,7 @@ source ./functions.source fi fi done + ) 3>&1 > "$testdir/video-test.out" 2>&1 echo "."