Clean up installer (remove unneeded checks, better editor & pager detection & path handling); update twtest to count failures instead of exiting on first one.

This commit is contained in:
Brian Cox 2017-03-30 22:22:52 -07:00
parent 9e1b078aac
commit a67d3c3a86
3 changed files with 128 additions and 129 deletions

View File

@ -17,7 +17,7 @@
## from Larry Wall's metaconfig.
##-------------------------------------------------------
PATH='.:/bin:/usr/bin'
PATH=".:/bin:/usr/bin:/usr/local/bin:$PATH"
export PATH || (echo 'You must use sh to run this script'; kill $$)
if [ ! -t 0 ] ; then
echo "Say 'sh install.sh', not 'sh < install.sh'"
@ -66,52 +66,24 @@ for p in $awknames; do
fi
done
##-------------------------------------------------------
## Does this system have a copy of grep we can use?
## Some greps don't return status (amazing, huh?),
## so we look for a copy of grep that
## returns 0 status for an exact match
## returns 0 status for a case-insensitive match
## returns 0 status for a wildcard match
## returns non-zero status for a failed match
##-------------------------------------------------------
GREP=""
grepnames="grep egrep"
lcgrepstr="findensiemich" # all lower case
mcgrepstr="FindenSieMich" # mixed case
wcgrepstr="sie.ich$" # wild card match
nogrepstr="WoBistDu" # should not be able to find this
for p in $grepnames; do
(echo "$lcgrepstr" | $p "$lcgrepstr") 2> /dev/null 1>&2
if [ $? -eq 0 ]; then
(echo "$lcgrepstr" | $p -i "$mcgrepstr") 2> /dev/null 1>&2
if [ $? -eq 0 ]; then
(echo "$lcgrepstr" | $p "$wcgrepstr") 2> /dev/null 1>&2
if [ $? -eq 0 ]; then
(echo "$lcgrepstr" | $p "$nogrepstr") 2> /dev/null 1>&2
if [ $? -ne 0 ]; then
GREP=$p
break
fi
fi
fi
fi
done
##-------------------------------------------------------
## Does this system have a pager that we can use?
## Use cat if desperate.
##-------------------------------------------------------
MORE="cat"
morenames="more less cat"
morenames="less more most pg cat"
for p in $morenames; do
($p $0 < /dev/null) 2> /dev/null 1>&2
if [ $? -eq 0 ]; then
MORE=$p
break
fi
pagerpath=`command -v $p`
if [ -z $pagerpath ]; then
continue
fi
if [ -x $pagerpath ]; then
MORE=$pagerpath
break
fi
done
##-------------------------------------------------------
@ -404,15 +376,21 @@ else
##-------------------------------------------------------
## Verify that the specified editor program exists
##-------------------------------------------------------
TWEDITOR=${TWEDITOR:-'/bin/vi'}
DEFAULTEDITOR=${EDITOR:-/bin/vi}
TWEDITOR=${TWEDITOR:-$DEFAULTEDITOR}
TWEDITOR_PATH=`command -v $TWEDITOR`
if [ -n ${TWEDITOR_PATH} ]; then
TWEDITOR=$TWEDITOR_PATH
fi
if [ -x ${TWEDITOR} ]; then
echo "${TWEDITOR} exists. Continuing installation."
echo
echo "${TWEDITOR} exists. Continuing installation."
echo
else
echo "${TWEDITOR} does not exist. Exiting."
exit 1
echo "${TWEDITOR} not found. Continuing, but your configuration may need to be edited after installation."
echo
fi
##-------------------------------------------------------

View File

@ -154,90 +154,109 @@ void Usage()
const int MAX_TEST_ID = 88;
static int failed_count = 0;
static void Test(int testID)
{
TCERR << std::endl << "=== Running test ID #" << testID << " ===" << std::endl;
switch (testID)
try {
switch (testID)
{
case 1: TestArchive(); break;
case 2: TestCmdLineParser(); break;
case 3: TestCrypto(); break;
case 4: TestCryptoArchive(); break;
case 5: TestDebug(); break;
case 6: TestError(); break;
case 7: TestErrorBucketImpl(); break;
case 8: TestFCOCompare(); break;
case 12: TestFCOName(); break;
case 13: TestFCONameTbl(); break;
case 14: TestFCOPropVector(); break;
case 15: TestFCOPropImpl(); break;
case 16: TestFCOReport(); break;
case 18: TestFCOSetImpl(); break;
case 20: TestFCOSpecAttr(); break;
case 21: TestFCOSpecHelper(); break;
case 22: TestFCOSpecList(); break;
case 23: TestFcoSpecUtil(); break;
case 24: TestFileHeader(); break;
case 26: TestFSPropSet(); break;
case 27: TestFSPropCalc(); break;
case 28: TestFCOSpecImpl(); break;
case 29: TestHashTable(); break;
case 31: TestRefCountObj(); break;
case 32: TestSerializerImpl(); break;
case 33: TestSerRefCountObj(); break;
case 34: TestSignature(); break;
case 35: TestTaskTimer(); break;
//case 36: TestTripwire(); break;
case 37: TestTextReportViewer(); break;
case 39: TestSerRefCountObj(); break;
case 40: TestError(); break;
case 41: TestFCODatabaseFile(); break;
case 42: TestHashTable(); break;
case 43: TestTCHAR(); break;
case 44: TestUnixFSServices(); break;
case 46: TestConfigFile(); break;
case 47: TestPolicyParser(); break;
case 48: TestKeyFile(); break;
case 49: TestTWUtil(); break;
case 50: TestFSPropDisplayer(); break;
case 52: TestGenre(); break;
case 53: TestFSDataSourceIter(); break;
//case 54: TestGenerateDb(); break;
case 55: TestHierDatabaseInteractive(); break;
case 56: TestGenreSwitcher(); break;
case 57: TestDbDataSource(); break;
case 58: TestGenreSpecList(); break;
//case 59: TestIntegrityCheck(); break;
case 65: TestWchar16(); break;
case 66: TestStringEncoder(); break;
case 69: TestGrowHeap(); break;
case 70: TestPlatform(); break;
case 71: TestBlockFile(); break;
case 72: TestBlockRecordArray(); break;
case 74: TestFileUtil(); break;
case 75: TestTWLocale(); break;
case 76: TestFCONameTranslator(); break;
case 77: TestStringUtil(); break;
case 78: TestCodeConverter(); break;
case 79: TestCharToHex(); break;
case 80: TestHexToChar(); break;
case 81: TestStringToHex(); break;
case 82: TestHexToString(); break;
// case 83: TestUnconvertable(); break;
// case 84: TestUnprintable(); break;
case 85: TestQuoteAndBackSlash(); break;
case 86: TestDisplayEncoderBasic(); break;
case 87: TestCharUtilBasic(); break;
case 88: TestConfigFile2(); break;
}
}
catch (eError& error)
{
case 1: TestArchive(); break;
case 2: TestCmdLineParser(); break;
case 3: TestCrypto(); break;
case 4: TestCryptoArchive(); break;
case 5: TestDebug(); break;
case 6: TestError(); break;
case 7: TestErrorBucketImpl(); break;
case 8: TestFCOCompare(); break;
case 12: TestFCOName(); break;
case 13: TestFCONameTbl(); break;
case 14: TestFCOPropVector(); break;
case 15: TestFCOPropImpl(); break;
case 16: TestFCOReport(); break;
case 18: TestFCOSetImpl(); break;
case 20: TestFCOSpecAttr(); break;
case 21: TestFCOSpecHelper(); break;
case 22: TestFCOSpecList(); break;
case 23: TestFcoSpecUtil(); break;
case 24: TestFileHeader(); break;
case 26: TestFSPropSet(); break;
case 27: TestFSPropCalc(); break;
case 28: TestFCOSpecImpl(); break;
case 29: TestHashTable(); break;
case 31: TestRefCountObj(); break;
case 32: TestSerializerImpl(); break;
case 33: TestSerRefCountObj(); break;
case 34: TestSignature(); break;
case 35: TestTaskTimer(); break;
//case 36: TestTripwire(); break;
case 37: TestTextReportViewer(); break;
case 39: TestSerRefCountObj(); break;
case 40: TestError(); break;
case 41: TestFCODatabaseFile(); break;
case 42: TestHashTable(); break;
case 43: TestTCHAR(); break;
case 44: TestUnixFSServices(); break;
case 46: TestConfigFile(); break;
case 47: TestPolicyParser(); break;
case 48: TestKeyFile(); break;
case 49: TestTWUtil(); break;
case 50: TestFSPropDisplayer(); break;
case 52: TestGenre(); break;
case 53: TestFSDataSourceIter(); break;
//case 54: TestGenerateDb(); break;
case 55: TestHierDatabaseInteractive(); break;
case 56: TestGenreSwitcher(); break;
case 57: TestDbDataSource(); break;
case 58: TestGenreSpecList(); break;
//case 59: TestIntegrityCheck(); break;
case 65: TestWchar16(); break;
case 66: TestStringEncoder(); break;
case 69: TestGrowHeap(); break;
case 70: TestPlatform(); break;
case 71: TestBlockFile(); break;
case 72: TestBlockRecordArray(); break;
case 74: TestFileUtil(); break;
case 75: TestTWLocale(); break;
case 76: TestFCONameTranslator(); break;
case 77: TestStringUtil(); break;
case 78: TestCodeConverter(); break;
case 79: TestCharToHex(); break;
case 80: TestHexToChar(); break;
case 81: TestStringToHex(); break;
case 82: TestHexToString(); break;
// case 83: TestUnconvertable(); break;
// case 84: TestUnprintable(); break;
case 85: TestQuoteAndBackSlash(); break;
case 86: TestDisplayEncoderBasic(); break;
case 87: TestCharUtilBasic(); break;
case 88: TestConfigFile2(); break;
cTWUtil::PrintErrorMsg(error);
failed_count++;
}
catch (std::exception& e) {
TCERR << "FAILED: " << e.what() << std::endl;
failed_count++;
}
catch (...) {
TCERR << "FAILED: <unknown>" << std::endl;
failed_count++;
}
TCERR << std::endl << "=== test ID #" << testID << " completed ===" << std::endl;
@ -333,9 +352,9 @@ int _tmain(int argc, TCHAR** argv)
// force user to hit <CR>
std::cout << std::endl << "Tests completed" << std::endl;
return 0;
std::cout << std::endl << "Tests completed with " << failed_count << " failures." << std::endl;
return failed_count ? -1 : 0;
}

View File

@ -49,6 +49,8 @@
#endif
#include <iostream>
#include <stdexcept>
using namespace std;
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -69,7 +71,7 @@ TSS_EndPackage( cTest )
#define TEST(exp) if (!(exp)) \
{ \
std::cerr<<"TEST(" << #exp << ") failure, file " << __FILE__ << " line " << __LINE__ << std::endl; \
exit(-1); \
throw std::runtime_error(#exp); \
}
///////////////////////////////////////////////////////////////////////////////