modrunner.cpp
00001 /* 00002 * Copyright (C) 2005 Jeroen Wijnhout <Jeroen.Wijnhout@kdemail.net> 00003 * 00004 * Redistribution and use in source and binary forms, with or without 00005 * modification, are permitted provided that the following conditions 00006 * are met: 00007 * 00008 * 1. Redistributions of source code must retain the above copyright 00009 * notice, this list of conditions and the following disclaimer. 00010 * 2. Redistributions in binary form must reproduce the above copyright 00011 * notice, this list of conditions and the following disclaimer in the 00012 * documentation and/or other materials provided with the distribution. 00013 * 00014 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 00015 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00016 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 00017 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 00018 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 00019 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00020 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 00021 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00022 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 00023 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00024 */ 00025 00026 #include <kdebug.h> 00027 #include <kglobal.h> 00028 #include <kinstance.h> 00029 #include <kaboutdata.h> 00030 #include <kcmdlineargs.h> 00031 #include <klocale.h> 00032 00033 #include "runner.h" 00034 00035 static const char description[] = 00036 I18N_NOOP("A command-line application that can be used to run KUnitTest modules."); 00037 00038 static const char version[] = "0.1"; 00039 00040 static KCmdLineOptions options[] = 00041 { 00042 {"query [regexp]", I18N_NOOP("Only run modules whose filenames match the regexp."), "^kunittest_.*\\.la$"}, 00043 {"folder [folder]", I18N_NOOP("Only run tests modules which are found in the folder. Use the query option to select modules."), "."}, 00044 { "enable-dbgcap", I18N_NOOP("Disables debug capturing. You typically use this option when you use the GUI."), 0}, 00045 KCmdLineLastOption 00046 }; 00047 00048 00049 int main( int argc, char **argv ) 00050 { 00051 KInstance instance("modrunner"); 00052 00053 KAboutData about("KUnitTest Module Runner", I18N_NOOP("KUnitTest ModRunner"), version, description, 00054 KAboutData::License_BSD, "(C) 2005 Jeroen Wijnhout", 0, 0, 00055 "Jeroen.Wijnhout@kdemail.net"); 00056 00057 KCmdLineArgs::init(argc, argv, &about); 00058 KCmdLineArgs::addCmdLineOptions( options ); 00059 KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); 00060 00061 KUnitTest::Runner::loadModules(args->getOption("folder"), args->getOption("query")); 00062 KUnitTest::Runner::setDebugCapturingEnabled(args->isSet("enable-dbgcap")); 00063 00064 KUnitTest::Runner::self()->runTests(); 00065 00066 return KUnitTest::Runner::self()->numberOfFailedTests() - KUnitTest::Runner::self()->numberOfExpectedFailures(); 00067 }