/* ***** BEGIN LICENSE BLOCK ***** * * $Id: utmain.cpp,v 1.2 2004/11/22 13:26:48 asuraparaju Exp $ $Name: Dirac_0_7_0 $ * * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License * Version 1.1 (the "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for * the specific language governing rights and limitations under the License. * * The Original Code is BBC Research and Development code. * * The Initial Developer of the Original Code is the British Broadcasting * Corporation. * Portions created by the Initial Developer are Copyright (C) 2004. * All Rights Reserved. * * Contributor(s): Anuradha Suraparaju (Original Author), Thomas Davies * * Alternatively, the contents of this file may be used under the terms of * the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser * Public License Version 2.1 (the "LGPL"), in which case the provisions of * the GPL or the LGPL are applicable instead of those above. If you wish to * allow use of your version of this file only under the terms of the either * the GPL or LGPL and not to allow others to use your version of this file * under the MPL, indicate your decision by deleting the provisions above * and replace them with the notice and other provisions required by the GPL * or LGPL. If you do not delete the provisions above, a recipient may use * your version of this file under the terms of any one of the MPL, the GPL * or the LGPL. * ***** END LICENSE BLOCK ***** */ #include #include #include #include #include #include #include #include #include #include int main( int argc, char* argv[] ) { // Retreive test path from command line first argument. Default to "" which resolve // to the top level suite. std::string testPath = (argc > 1) ? std::string(argv[1]) : std::string(""); // Create the event manager and test controller CPPUNIT_NS::TestResult controller; // Add a listener that colllects test result CPPUNIT_NS::TestResultCollector result; controller.addListener( &result ); // Add a listener that print dots as test run. #ifdef WIN32 CPPUNIT_NS::TextTestProgressListener progress; #else CPPUNIT_NS::BriefTestProgressListener progress; #endif controller.addListener( &progress ); // Add the top suite to the test runner CPPUNIT_NS::TestRunner runner; runner.addTest( CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest() ); try { std::string test_path = testPath.empty() ? " all unit tests" : testPath; std::cerr << "Running " << test_path << std::endl; runner.run( controller, testPath ); std::cerr << std::endl; // Print test in a compiler compatible format. CPPUNIT_NS::CompilerOutputter outputter( &result, std::cerr ); outputter.write(); // Uncomment this for XML output // std::ofstream file( "tests.xml" ); // CPPUNIT_NS::XmlOutputter xml( &result, file ); // xml.setStyleSheet( "report.xsl" ); // xml.write(); // file.close(); } catch ( std::invalid_argument &e ) // Test path not resolved { std::cerr << std::endl << "ERROR: " << e.what() << std::endl; return 0; } return result.wasSuccessful() ? 0: 1; }