X-Git-Url: http://git.marmaro.de/?a=blobdiff_plain;f=test%2Fformat%2Ftest-myname;h=dda0f37bf8cb8e79092f5d2c2597a4702478e224;hb=eba408368603a3afe170ef61a334c3a479ea5a29;hp=4e1dfaa35b540c5495dacdb11c7c618cd2a9e000;hpb=23af631076209b31fb28feb90a779ff8dcc153a2;p=mmh diff --git a/test/format/test-myname b/test/format/test-myname index 4e1dfaa..dda0f37 100755 --- a/test/format/test-myname +++ b/test/format/test-myname @@ -4,34 +4,56 @@ # the Signature profile entry, and via SIGNATURE environment variable. # -if [ -z "${MH_TEST_COMMON}" ]; then - echo "MH_TEST_COMMON not set; try running via 'make check'" +set -e + +if test -z "${MH_OBJ_DIR}"; then + srcdir=`dirname "$0"`/../.. + MH_OBJ_DIR=`cd "$srcdir" && pwd`; export MH_OBJ_DIR fi -. ${MH_TEST_COMMON} +. "$MH_OBJ_DIR/test/common.sh" setup_test -unset SIGNATURE - -runtest() -{ - testoutput=$(${MH_LIB_DIR}/ap -format "%(myname)" ignore) - - if [ x"$1" != x"${testoutput}" ]; then - echo "For $2, expected $1 but got ${testoutput}" - exit 1 - fi -} +unset SIGNATURE -runtest "$(${MH_OBJ_DIR}/test/getfullname)" "GECOS field test" +fullname=`${MH_OBJ_DIR}/test/getfullname` +run_test "${MH_LIB_DIR}/ap -format %(myname) ignore" \ + "$fullname" "GECOS field test" echo "Signature: Some Random Name 1" >> ${MH} -runtest "Some Random Name 1" "MH Profile Signature test" - -export SIGNATURE="Some Random Name 2" - -runtest "${SIGNATURE}" "SIGNATURE Environment test" - -exit 0 +run_test "${MH_LIB_DIR}/ap -format %(myname) ignore" \ + "Some Random Name 1" "MH Profile Signature test" + +SIGNATURE="Some Random Name 2" +export SIGNATURE + +run_test "${MH_LIB_DIR}/ap -format %(myname) ignore" \ + "${SIGNATURE}" "SIGNATURE Environment test" + +#### Test escaping of display names. +escape="${MH_OBJ_DIR}/test/getfullname" +run_test "$escape "'user' 'user' 'no escape' +run_test "$escape "'first.last' '"first.last"' 'escape' +run_test "$escape "'"first.last"' '"first.last"' 'already escaped' +run_test "$escape "'first.last"' '"first.last"' 'missing initial "' +run_test "$escape "'"first.last' '"first.last"' 'missing final "' +run_test "$escape "'embedded"quote' '"embedded\"quote"' 'embedded quote' +run_test "$escape "'server\name,#' '"server\name"' 'Windows form' +run_test "$escape "'"' '"\""' 'special "' +run_test "$escape "'(' '"("' 'special (' +run_test "$escape "')' '")"' 'special )' +#### We stop at the first comma so this one gets eliminated: +run_test "$escape "',' '' 'special ,' +run_test "$escape "'.' '"."' 'special .' +run_test "$escape "':' '":"' 'special :' +run_test "$escape "';' '";"' 'special ;' +run_test "$escape "'<' '"<"' 'special <' +run_test "$escape "'>' '">"' 'special >' +run_test "$escape "'@' '"@"' 'special @' +run_test "$escape "'[' '"["' 'special [' +run_test "$escape "'\\' '"\\"' 'special \\' +run_test "$escape "']' '"]"' 'special ]' + +exit $failed