Tweak twest usage/help, & add version info and zero-tests-ran error
This commit is contained in:
parent
a56b687594
commit
9c645498e2
|
@ -60,6 +60,7 @@
|
||||||
#include "db/blockfile.h"
|
#include "db/blockfile.h"
|
||||||
#include "db/blockrecordarray.h"
|
#include "db/blockrecordarray.h"
|
||||||
#include "db/hierdatabase.h"
|
#include "db/hierdatabase.h"
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
@ -132,14 +133,28 @@ void RegisterSuite_Wchar16();
|
||||||
/// This is easier than all the (cpp) files and declarations
|
/// This is easier than all the (cpp) files and declarations
|
||||||
#include "stringutil_t.h"
|
#include "stringutil_t.h"
|
||||||
|
|
||||||
|
#if IS_AROS
|
||||||
|
# define VERSION_PREFIX "$VER: "
|
||||||
|
#else
|
||||||
|
# define VERSION_PREFIX "@(#)"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const char* STR_EMBEDDED_VERSION = _T(VERSION_PREFIX "twtest " PACKAGE_VERSION);
|
||||||
|
|
||||||
|
|
||||||
void Usage()
|
void Usage()
|
||||||
{
|
{
|
||||||
TCERR << _T("Usage: test {all | list | testid [testid ...]}\n")
|
TCERR << _T("Usage: twtest {all | list | help | version | testid [testid ...]}\n")
|
||||||
_T("\n")
|
_T("\n")
|
||||||
_T("Ex: test foo bar/baz\n")
|
_T("Ex: twtest foo bar/baz\n")
|
||||||
_T("(runs suite foo and test bar/baz)\n\n");
|
_T("(runs suite foo and test bar/baz)\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Version()
|
||||||
|
{
|
||||||
|
TCOUT << "twtest " << PACKAGE_VERSION << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
static int ran_count = 0;
|
static int ran_count = 0;
|
||||||
static int failed_count = 0;
|
static int failed_count = 0;
|
||||||
static int skipped_count = 0;
|
static int skipped_count = 0;
|
||||||
|
@ -432,8 +447,10 @@ int _tmain(int argc, TCHAR** argv)
|
||||||
EXCEPTION_NAMESPACE set_terminate(tw_terminate_handler);
|
EXCEPTION_NAMESPACE set_terminate(tw_terminate_handler);
|
||||||
EXCEPTION_NAMESPACE set_unexpected(tw_unexpected_handler);
|
EXCEPTION_NAMESPACE set_unexpected(tw_unexpected_handler);
|
||||||
|
|
||||||
if (argc < 2)
|
if (argc < 2) {
|
||||||
Usage();
|
Usage();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
cTWInit twInit;
|
cTWInit twInit;
|
||||||
twInit.Init( argv[0] );
|
twInit.Init( argv[0] );
|
||||||
|
@ -445,14 +462,27 @@ int _tmain(int argc, TCHAR** argv)
|
||||||
//cDebug::SetDebugLevel(cDebug::D_DEBUG);
|
//cDebug::SetDebugLevel(cDebug::D_DEBUG);
|
||||||
|
|
||||||
RegisterSuites();
|
RegisterSuites();
|
||||||
|
std::string arg1 = argv[1];
|
||||||
|
|
||||||
if (_tcsicmp(argv[1], _T("all")) == 0)
|
|
||||||
|
if (arg1 == "all" || arg1 == "--all")
|
||||||
{
|
{
|
||||||
RunAllTests();
|
RunAllTests();
|
||||||
}
|
}
|
||||||
else if(_tcsicmp(argv[1], _T("list")) == 0)
|
else if(arg1 == "list" || arg1 == "--list")
|
||||||
{
|
{
|
||||||
ListTests();
|
ListTests();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else if(arg1 == "help" || arg1 == "--help" || arg1 == "-?")
|
||||||
|
{
|
||||||
|
Usage();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else if(arg1 == "version" || arg1 == "--version")
|
||||||
|
{
|
||||||
|
Version();
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -467,6 +497,12 @@ int _tmain(int argc, TCHAR** argv)
|
||||||
ASSERT(false);
|
ASSERT(false);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
catch (std::exception& error)
|
||||||
|
{
|
||||||
|
TCERR << "Caught std::exception: " << error.what() << std::endl;
|
||||||
|
ASSERT(false);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
TCERR << _T("Unhandled exception caught!");
|
TCERR << _T("Unhandled exception caught!");
|
||||||
|
@ -478,6 +514,12 @@ int _tmain(int argc, TCHAR** argv)
|
||||||
// this test always fails because of the static cFCONameTbl
|
// this test always fails because of the static cFCONameTbl
|
||||||
//TEST(cRefCountObj::AllRefCountObjDestoryed() == true);
|
//TEST(cRefCountObj::AllRefCountObjDestoryed() == true);
|
||||||
|
|
||||||
|
if (!ran_count)
|
||||||
|
{
|
||||||
|
std::cout << "Ran 0 unit tests. The specified group/test names may be incorrect (names are case sensitive).\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
std::cout << std::endl << "Ran " << ran_count << " unit tests with " << failed_count << " failures, " << skipped_count << " skipped." << std::endl;
|
std::cout << std::endl << "Ran " << ran_count << " unit tests with " << failed_count << " failures, " << skipped_count << " skipped." << std::endl;
|
||||||
std::cout << "(total test assertions: " << macro_count << ")" << std::endl;
|
std::cout << "(total test assertions: " << macro_count << ")" << std::endl;
|
||||||
|
|
||||||
|
@ -503,6 +545,9 @@ int _tmain(int argc, TCHAR** argv)
|
||||||
|
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return failed_count ? -1 : 0;
|
return failed_count ? -1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue