00001 #include <iostream>
00002 #include <stdexcept>
00003
00004 #include <cppunit/TestResult.h>
00005 #include <cppunit/TestResultCollector.h>
00006 #include <cppunit/TestRunner.h>
00007 #include <cppunit/BriefTestProgressListener.h>
00008 #include <cppunit/TextTestResult.h>
00009 #include <cppunit/TextOutputter.h>
00010
00011 #include <cppunit/extensions/HelperMacros.h>
00012 #include <cppunit/extensions/TestFactoryRegistry.h>
00013
00014 #include "Basis/CmdOptions.h"
00015 #include "Link/TeamCity/TeamCity.h"
00016
00017
00018 #include "Core/Array/Test/TestMakeRandom.h"
00019 #include "Core/Array/Test/TestEquals.h"
00020 #include "Core/Feature/Test/TestFunctions.h"
00021 #include "Core/Feature/Test/TestRandomTree.h"
00022 #include "Core/Feature/Test/TestMakeRandomTree.h"
00023 #include "Core/Histogram/Test/TestEntropy.h"
00024 #include "Core/Training/Test/TestBestFile.h"
00025 #include "Core/Training/Test/TestSvm.h"
00026
00027
00028 #include "Link/ImpalaLib.cpp"
00029
00030 using namespace CPPUNIT_NS;
00031 using namespace Impala::Link;
00032
00033 int main(int argc, char **argv)
00034 {
00035
00036 Impala::CmdOptions& options = Impala::CmdOptions::GetInstance();
00037 options.Initialise(true, false, true);
00038 if (! options.ParseArgs(argc, argv, ""))
00039 return 1;
00040
00041 ILOG_VAR(Impala.Test.mainUnitTest);
00042
00043
00044 TestResult controller;
00045
00046
00047 TestResultCollector resultCollector;
00048 controller.addListener(&resultCollector);
00049
00050
00051 TestListener *listener = 0;
00052 TextOutputter* out = 0;
00053 if (TeamCity::TeamCityUsed())
00054 if (TeamCity::UnderTeamCity() || options.GetBool("verb"))
00055 listener = TeamCity::GetTestListener();
00056 if (listener == 0)
00057 {
00058 TestResultCollector* trl = new TestResultCollector();
00059 out = new TextOutputter(trl, std::cout);
00060 listener = trl;
00061 }
00062 controller.addListener(listener);
00063
00064
00065 TestRunner runner;
00066 runner.addTest(TestFactoryRegistry::getRegistry().makeTest());
00067
00068
00069
00070 #ifdef NO_DIALOGONCRASH
00071 #ifdef WIN32
00072 DWORD oldMode = ::SetErrorMode(SEM_NOGPFAULTERRORBOX);
00073 ::SetErrorMode(oldMode | SEM_NOGPFAULTERRORBOX);
00074 #endif
00075 #endif
00076
00077 runner.run(controller);
00078
00079
00080 if(out)
00081 {
00082 out->write();
00083 delete out;
00084 }
00085 delete listener;
00086
00087 return resultCollector.wasSuccessful() ? 0 : 1;
00088 }