[Fwbuilder-discussion] PATCH: fix commandLinePrintingTest
Brought to you by:
mikehorn
From: Vadim Z. <per...@gm...> - 2011-07-06 21:19:58
|
Hello all. This patch does following: * Replace non-portable "#!/bin/bash" shebang with "#!/bin/sh"; * Allow to catch actual qmake output that's printed on stderr; * Replace "$(basename `pwd`)" with more simple and robust "${0##/}"; * Respect $QMAKE variable (useful when qmake lives under, say, "qmake4" binary; this variable is automatically provided when invoking "make"); * Replace non-portable "echo -en" with POSIX "printf"; * Use "$@" special feature, which is not the same as "$*" or $@; * Use more robust "[[ ... ]]" instead of "[ ... ]" construction where apporiate; * Avoid potential problems with test names containing whitespace; * Make test command arguments being split in obvious way. -- Best wishes, Vadim Zhukov A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing in e-mail? /* * Copyright (c) 2011 Vadim Zhukov <per...@gm...> * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ --- src/unit_tests/commandLinePrintingTest/commandLinePrintingTest.ports.orig Wed Jul 6 01:00:35 2011 +++ src/unit_tests/commandLinePrintingTest/commandLinePrintingTest Thu Jul 7 00:48:40 2011 @@ -1,9 +1,9 @@ -#!/bin/bash +#!/bin/sh rm -f print.pdf >/dev/null 2>/dev/null -QTVERSION=`qmake --version | tail -n1| cut -d' ' -f4` -TESTNAME=$(basename `pwd`) +QTVERSION=$(${QMAKE:-qmake} --version 2>&1 | tail -n1| cut -d' ' -f4) +TESTNAME=${0##/} PASSED=0 FAILED=0 SKIPPED=0 @@ -31,17 +31,16 @@ function run_command # test_name command { test=$1 shift - command=$@ - output=$($command 2>&1) + output=$("$@" 2>&1) returned=$? ORIGIFS=$IFS - IFS=`echo -en "\n\b"` + IFS=`printf "\n\b"` for line in $output do output $test $line done IFS=$ORIGIFS - [ $returned -eq 0 ] && pass $test || fail $test + [[ $returned -eq 0 ]] && pass "$test" || fail "$test" } @@ -51,8 +50,8 @@ pass "initTestCase" # -------- actual testing goes here -------- -run_command "runPrinting" "../../gui/fwbuilder -f test.fwb -P test" -run_command "fileExists" "ls print.pdf" +run_command "runPrinting" ../../gui/fwbuilder -f test.fwb -P test +run_command "fileExists" ls print.pdf # --------- end of actual testing --------- @@ -61,4 +60,4 @@ rm -f print.pdf >/dev/null 2>&1 pass "cleanupTestCase" echo "Totals: ${PASSED} passed, ${FAILED} failed, ${SKIPPED} skipped" echo "********* Finished testing of ${TESTNAME} *********" -[ ${FAILED} -eq 0 ] && exit 0 || exit 1 +[[ ${FAILED} -eq 0 ]] && exit 0 || exit 1 |