[Kdevcppunit-commits] kdevcppunit/src/launcher .cvsignore,NONE,1.1 KCppUnitListener.cpp,NONE,1.1 KCp
Status: Pre-Alpha
Brought to you by:
ewald-arnold
Update of /cvsroot/kdevcppunit/kdevcppunit/src/launcher In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7455/src/launcher Added Files: .cvsignore KCppUnitListener.cpp KCppUnitListener.h Makefile.am kdevcppunit_launcher.cpp kdevcppunit_launcher.h Log Message: restructured file tree --- NEW FILE: kdevcppunit_launcher.h --- /** @file @brief Application to load libraries and execute the tests inside. $Id: kdevcppunit_launcher.h,v 1.1 2005/02/20 17:26:22 ewald-arnold Exp $ ***************************************************************************/ /************************************************************************** begin : Wed Feb 10 2005 copyright : (C) 2004-2005 by Ewald Arnold email : kdevcppunit at ewald-arnold dot de This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ***************************************************************************/ --- NEW FILE: .cvsignore --- Makefile.in *.bak *~ *.~* --- NEW FILE: Makefile.am --- INCLUDES = -I$(top_srcdir)/lib/interfaces -I$(top_srcdir)/lib/util \ $(all_includes) METASOURCES = AUTO CPPUNITLIB = -lcppunit MOCKPPLIB = #-lmockpp bin_PROGRAMS = kdevcppunit_launcher kdevcppunit_launcher_LDFLAGS = $(all_libraries) $(CPPUNITLIB) $(MOCKPPLIB) kdevcppunit_launcher_SOURCES = kdevcppunit_launcher.cpp lib_LTLIBRARIES = libkdevcppunit.la libkdevcppunit_la_LDFLAGS = $(all_libraries) libkdevcppunit_la_SOURCES = KCppUnitListener.cpp kdevcppunit_launcher_LDADD = $(top_builddir)/src/launcher/libkdevcppunit.la \ -ldl --- NEW FILE: KCppUnitListener.h --- /** @file @brief $Id: KCppUnitListener.h,v 1.1 2005/02/20 17:26:22 ewald-arnold Exp $ ***************************************************************************/ /************************************************************************** begin : Wed Feb 10 2005 copyright : (C) 2004-2005 by Ewald Arnold email : kdevcppunit at ewald-arnold dot de This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ***************************************************************************/ #include <ctime> #include <iosfwd> # include <cppunit/TextTestProgressListener.h> # include <cppunit/TestResult.h> # include <cppunit/TestFailure.h> class KCppUnitListener : public CppUnit::TextTestProgressListener { public: KCppUnitListener(); void startTest( CppUnit::Test *test ); void addFailure( const CppUnit::TestFailure &failure ); void endTest(CppUnit::Test *test); void done(); private: std::time_t starttime; std::ostream &outstream; }; --- NEW FILE: kdevcppunit_launcher.cpp --- /** @file @brief Application to load libraries and execute the tests inside. $Id: kdevcppunit_launcher.cpp,v 1.1 2005/02/20 17:26:22 ewald-arnold Exp $ ***************************************************************************/ /************************************************************************** begin : Wed Feb 10 2005 copyright : (C) 2004-2005 by Ewald Arnold email : kdevcppunit at ewald-arnold dot de This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ***************************************************************************/ #include "kdevcppunit_launcher.h" // always first #include <iostream> #include <ctime> #include <cppunit/extensions/TestFactoryRegistry.h> #include <cppunit/extensions/HelperMacros.h> #include <cppunit/ui/text/TestRunner.h> #include "KCppUnitListener.h" void dummy() // dummy to ensure exception support { try { throw 1; } catch(...) { } } int main(int argc, char **argv) { int ret = 1; CppUnit::TextUi::TestRunner runner; CppUnit::TestFactory ®istry = CppUnit::TestFactoryRegistry::getRegistry(); runner.addTest(registry.makeTest()); std::cout << "starting tests..\n" << "Options\n" << " --kdevcppunit-output generate output for KDevCppUnit\n" << "\n"; for (int i = 1; i < argc; ++i) { if (strcmp (argv[i], "--kdevcppunit-output") == 0) runner.eventManager().addListener(new KCppUnitListener()); } ret = runner.run() ? 0 : 1; std::cout << "Result: " << ret << std::endl; return ret; } --- NEW FILE: KCppUnitListener.cpp --- /** @file @brief $Id: KCppUnitListener.cpp,v 1.1 2005/02/20 17:26:22 ewald-arnold Exp $ ***************************************************************************/ /************************************************************************** begin : Wed Feb 10 2005 copyright : (C) 2004-2005 by Ewald Arnold email : kdevcppunit at ewald-arnold dot de This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ***************************************************************************/ #include <iostream> #include "KCppUnitListener.h" #include <cppunit/Test.h> #include <cppunit/SourceLine.h> #define TAG_STARTTEST ">>> " #define TAG_ENDTEST "<<< " #define TAG_STARTINFO "!!! " #define TAG_MESSAGE " -MSG " #define TAG_FAILURE " -FAIL " #define TAG_ERROR " -ERR " #define TAG_TRACE " -TRACE " #define TAG_SEPARATOR ";" KCppUnitListener::KCppUnitListener() : outstream(std::cerr) { } void KCppUnitListener::startTest( CppUnit::Test *test ) { starttime = std::time(0); outstream << TAG_STARTTEST << test->getName() << TAG_SEPARATOR << starttime << std::endl; std::cerr.flush(); } void KCppUnitListener::addFailure( const CppUnit::TestFailure &failure ) { outstream << ( failure.isError() ? TAG_ERROR : TAG_FAILURE ) << std::endl; outstream << "line: " << failure.sourceLine().lineNumber() << std::endl; outstream << "file: " << failure.sourceLine().fileName() << std::endl; outstream.flush(); } void KCppUnitListener::endTest(CppUnit::Test *test) { outstream << std::endl; std::time_t endtime = std::time(0); std::time_t difftime = starttime - endtime; unsigned m = difftime / 60; unsigned s = difftime % 60; outstream << TAG_ENDTEST << test->getName() << TAG_SEPARATOR << endtime << TAG_SEPARATOR << m << ":" << s << std::endl; } void KCppUnitListener::done() { outstream << std::endl; outstream.flush(); } |