summaryrefslogtreecommitdiff
path: root/src/DllPlugInTester
diff options
context:
space:
mode:
authorBaptiste Lepilleur <gaiacrtn@free.fr>2002-04-21 09:57:52 +0000
committerBaptiste Lepilleur <gaiacrtn@free.fr>2002-04-21 09:57:52 +0000
commitca5f94534beb3fb395a397a2fe991f4c64fb2f84 (patch)
tree1ab95c541266dc554500d201865f683616a11dbc /src/DllPlugInTester
parentaa3e46e802dc5139e3e2c32e6a00526697e8a0aa (diff)
downloadcppunit-ca5f94534beb3fb395a397a2fe991f4c64fb2f84.tar.gz
Src/DllPlugInTester/makefile.
src/DllPlugInTester/makefile.am: removed ld.so from LDADD flags. * src/DllPlugInTester/CommandLineParser.h: * src/DllPlugInTester/CommandLineParser.cpp: rewrote, fixed problem with double quotes in command line... * src/DllPlugInTester/CommandLineParserTest.h: * src/DllPlugInTester/CommandLineParserTest.cpp: * src/DllPlugInTester/DllPlugInTesterTest.cpp: added, unit tests for CommandLineParser. * src/msvc6/TestPlugIn/*: removed.
Diffstat (limited to 'src/DllPlugInTester')
-rw-r--r--src/DllPlugInTester/CommandLineParser.cpp191
-rw-r--r--src/DllPlugInTester/CommandLineParser.h39
-rw-r--r--src/DllPlugInTester/CommandLineParserTest.cpp221
-rw-r--r--src/DllPlugInTester/CommandLineParserTest.h61
-rw-r--r--src/DllPlugInTester/DllPlugInTester.cpp68
-rw-r--r--src/DllPlugInTester/DllPlugInTesterTest.cpp16
-rw-r--r--src/DllPlugInTester/DllPlugInTesterTest.dsp149
-rw-r--r--src/DllPlugInTester/Makefile.am16
8 files changed, 605 insertions, 156 deletions
diff --git a/src/DllPlugInTester/CommandLineParser.cpp b/src/DllPlugInTester/CommandLineParser.cpp
index e365ca3..1187266 100644
--- a/src/DllPlugInTester/CommandLineParser.cpp
+++ b/src/DllPlugInTester/CommandLineParser.cpp
@@ -3,7 +3,7 @@
CommandLineParser::CommandLineParser( int argc,
char *argv[] )
- : m_currentIndex( 0 )
+ : m_currentArgument( 0 )
, m_useCompiler( false )
, m_useXml( false )
, m_briefProgress( false )
@@ -13,9 +13,8 @@ CommandLineParser::CommandLineParser( int argc,
{
for ( int index =1; index < argc; ++index )
{
- if ( index > 1 )
- m_line += " ";
- m_line += argv[index];
+ std::string argument( argv[index ] );
+ m_arguments.push_back( argument );
}
}
@@ -28,7 +27,7 @@ CommandLineParser::~CommandLineParser()
void
CommandLineParser::parse()
{
- while ( hasNext() )
+ while ( hasNextArgument() )
{
getNextOption();
if ( isOption( "c", "compiler" ) )
@@ -36,12 +35,12 @@ CommandLineParser::parse()
else if ( isOption( "x", "xml" ) )
{
m_useXml = true;
- m_xmlFileName = getOptionalParameter();
+ m_xmlFileName = getNextOptionalParameter();
}
else if ( isOption( "s", "xsl" ) )
- m_xsl = getParameter();
+ m_xsl = getNextParameter();
else if ( isOption( "e", "encoding" ) )
- m_encoding = getParameter();
+ m_encoding = getNextParameter();
else if ( isOption( "b", "brief-progress" ) )
m_briefProgress = true;
else if ( isOption( "n", "no-progress" ) )
@@ -52,186 +51,114 @@ CommandLineParser::parse()
m_useCout = true;
else if ( !m_option.empty() )
fail( "Unknown option" );
- else if ( hasNext() )
+ else if ( hasNextArgument() )
readNonOptionCommands();
}
}
-bool
-CommandLineParser::isOption( const std::string &shortName,
- const std::string &longName )
-{
- return (m_option == "-" + shortName) ||
- (m_option == "--" + longName);
-}
-
-
-bool
-CommandLineParser::hasNext() const
-{
- return m_currentIndex < m_line.length();
-}
-
-
-std::string
-CommandLineParser::getParameter()
+void
+CommandLineParser::readNonOptionCommands()
{
- if ( startsWith( "\"" ) )
- return getQuotedParameter();
+ if ( argumentStartsWith( ":" ) )
+ m_testPath = getNextArgument().substr( 1 );
else
- return getUnquotedParameter();
-}
-
-
-std::string
-CommandLineParser::getUnquotedParameter()
-{
- std::string parameter;
-
- if ( !hasNext() )
- fail( "missing option parameter" );
-
- while ( hasNext() && !isSpace() )
- parameter += next();
- return parameter;
-}
-
-
-std::string
-CommandLineParser::getQuotedParameter()
-{
- std::string parameter;
- while ( !startsWith( "\"" ) )
{
- if ( !hasNext() )
- fail( "Unmatched \" in option parameter" );
-
- if ( startsWith( "\\" ) )
+ CommandLinePlugInInfo plugIn;
+ int indexParameter = getCurrentArgument().find( '=' );
+ if ( indexParameter < 0 )
+ plugIn.m_fileName = getCurrentArgument();
+ else
{
- skipNext();
- if ( !hasNext() )
- fail( "Missing escaped character in option parameter" );
+ plugIn.m_fileName = getCurrentArgument().substr( 0, indexParameter );
+ std::string parameters = getCurrentArgument().substr( indexParameter +1 );
+ plugIn.m_parameters.push_back( parameters );
}
+
+ m_plugIns.push_back( plugIn );
- parameter += next();
+ getNextArgument();
}
- return parameter;
}
-std::string
-CommandLineParser::getOptionalParameter()
+bool
+CommandLineParser::hasNextArgument() const
{
- if ( !hasNext() || startsWith( "-" ) || startsWith( ":" ) )
- return "";
- return getParameter();
+ return m_currentArgument < m_arguments.size();
}
-void
-CommandLineParser::getNextOption()
+std::string
+CommandLineParser::getNextArgument()
{
- skipSpaces();
- m_option = "";
- if ( startsWith( "-" ) || startsWith( "--" ) )
- {
- while ( hasNext() && !isSpace() )
- m_option += next();
-
- skipSpaces();
- }
+ if ( hasNextArgument() )
+ return m_arguments[ m_currentArgument++ ];
+ return "";
}
-void
-CommandLineParser::readNonOptionCommands()
+std::string
+CommandLineParser::getCurrentArgument() const
{
- if ( startsWith( ":" ) )
- {
- skipNext();
- m_testPath = getParameter();
- }
- else
- {
- CommandLinePlugInInfo plugIn;
- while ( hasNext() && !isSpace() && !startsWith( "=" ) )
- plugIn.m_fileName += next();
-
- std::string parameters;
- if ( startsWith( "=" ) )
- {
- m_option = plugIn.m_fileName;
- skipNext();
- parameters = getParameter();
- }
-
- plugIn.m_parameters.push_back( parameters );
- m_plugIns.push_back( plugIn );
- }
+ if ( m_currentArgument < m_arguments.size() )
+ return m_arguments[ m_currentArgument ];
+ return "";
}
bool
-CommandLineParser::startsWith( const std::string &expected ) const
+CommandLineParser::argumentStartsWith( const std::string &expected ) const
{
- return m_line.substr( m_currentIndex, expected.length() ) == expected;
+ return getCurrentArgument().substr( 0, expected.length() ) == expected;
}
void
-CommandLineParser::skipSpaces()
-{
- while ( hasNext() && isSpace() )
- skipNext();
-}
-
-
-bool
-CommandLineParser::isSpace() const
+CommandLineParser::getNextOption()
{
- if ( !hasNext() )
- return true;
-
- return isSpace( m_line[m_currentIndex] );
+ if ( argumentStartsWith( "-" ) || argumentStartsWith( "--" ) )
+ m_option = getNextArgument();
+ else
+ m_option = "";
}
bool
-CommandLineParser::isSpace( unsigned char c )
+CommandLineParser::isOption( const std::string &shortName,
+ const std::string &longName )
{
- return c <= 32;
+ return (m_option == "-" + shortName) ||
+ (m_option == "--" + longName);
}
-char
-CommandLineParser::next()
+std::string
+CommandLineParser::getNextParameter()
{
- if ( !hasNext() )
- fail( "unexpected error while parsing option" );
-
- return m_line[ m_currentIndex++ ];
+ if ( !hasNextArgument() )
+ fail( "missing parameter" );
+ return getNextArgument();
}
-void
-CommandLineParser::skipNext( int count )
+std::string
+CommandLineParser::getNextOptionalParameter()
{
- m_currentIndex += count;
- if ( m_currentIndex > m_line.length() )
- m_currentIndex = m_line.length();
+ if ( argumentStartsWith( "-" ) || argumentStartsWith( ":" ) )
+ return "";
+ return getNextArgument();
}
void
CommandLineParser::fail( std::string message )
{
- throw CommandLineParserException( "Error while parsing option: " + m_option+
- "\n" + message );
+ throw CommandLineParserException( "while parsing option " + m_option+
+ ",\n" + message );
}
-
bool
CommandLineParser::useCompilerOutputter() const
{
diff --git a/src/DllPlugInTester/CommandLineParser.h b/src/DllPlugInTester/CommandLineParser.h
index 9fd5c5d..ed1b1f6 100644
--- a/src/DllPlugInTester/CommandLineParser.h
+++ b/src/DllPlugInTester/CommandLineParser.h
@@ -77,31 +77,28 @@ protected:
/// Prevents the use of the copy operator.
void operator =( const CommandLineParser &copy );
+ void readNonOptionCommands();
+
+ bool hasNextArgument() const;
+
+ std::string getNextArgument();
+
+ std::string getCurrentArgument() const;
+
+ bool argumentStartsWith( const std::string &expected ) const;
+
+ void getNextOption();
+
bool isOption( const std::string &shortName,
const std::string &longName );
- bool hasNext() const;
- bool startsWith( const std::string &expected ) const;
- char next();
- void skipNext( int count =1 );
- bool isSpace() const;
+ std::string getNextParameter();
- std::string getParameter();
- std::string getQuotedParameter();
- std::string getUnquotedParameter();
- std::string getOptionalParameter();
- void fail( std::string message );
- void getNextOption();
- void skipSpaces();
- static bool isSpace( unsigned char c );
+ std::string getNextOptionalParameter();
- void readNonOptionCommands();
+ void fail( std::string message );
protected:
- std::string m_line;
- int m_currentIndex;
- std::string m_option;
-
bool m_useCompiler;
bool m_useXml;
std::string m_xmlFileName;
@@ -115,6 +112,12 @@ protected:
typedef std::deque<CommandLinePlugInInfo> PlugIns;
PlugIns m_plugIns;
+
+ typedef std::deque<std::string> Arguments;
+ Arguments m_arguments;
+ int m_currentArgument;
+
+ std::string m_option;
};
diff --git a/src/DllPlugInTester/CommandLineParserTest.cpp b/src/DllPlugInTester/CommandLineParserTest.cpp
new file mode 100644
index 0000000..8f2f2bf
--- /dev/null
+++ b/src/DllPlugInTester/CommandLineParserTest.cpp
@@ -0,0 +1,221 @@
+#include "CommandLineParser.h"
+#include "CommandLineParserTest.h"
+
+CPPUNIT_TEST_SUITE_REGISTRATION( CommandLineParserTest );
+
+
+CommandLineParserTest::CommandLineParserTest() :
+ CppUnit::TestCase()
+{
+}
+
+
+CommandLineParserTest::~CommandLineParserTest()
+{
+}
+
+
+void
+CommandLineParserTest::setUp()
+{
+ _parser = NULL;
+}
+
+
+void
+CommandLineParserTest::tearDown()
+{
+ delete _parser;
+}
+
+
+void
+CommandLineParserTest::parse( char **lines )
+{
+ int count =0;
+ for ( char **line = lines; *line != NULL; ++line, ++count );
+
+ delete _parser;
+ _parser = new CommandLineParser( count, lines );
+ _parser->parse();
+}
+
+
+void
+CommandLineParserTest::testEmptyCommandLine()
+{
+ static char *lines[] = { "", NULL };
+ parse( lines );
+
+ std::string none;
+ CPPUNIT_ASSERT_EQUAL( none, _parser->getEncoding() );
+ CPPUNIT_ASSERT_EQUAL( none, _parser->getTestPath() );
+ CPPUNIT_ASSERT_EQUAL( none, _parser->getXmlFileName() );
+ CPPUNIT_ASSERT_EQUAL( none, _parser->getXmlStyleSheet() );
+ CPPUNIT_ASSERT( !_parser->noTestProgress() );
+ CPPUNIT_ASSERT( !_parser->useBriefTestProgress() );
+ CPPUNIT_ASSERT( !_parser->useCompilerOutputter() );
+ CPPUNIT_ASSERT( !_parser->useCoutStream() );
+ CPPUNIT_ASSERT( !_parser->useTextOutputter() );
+ CPPUNIT_ASSERT( !_parser->useXmlOutputter() );
+}
+
+
+void
+CommandLineParserTest::testFlagCompiler()
+{
+ static char *lines[] = { "", "-c", NULL };
+ parse( lines );
+
+ std::string none;
+ CPPUNIT_ASSERT_EQUAL( none, _parser->getEncoding() );
+ CPPUNIT_ASSERT_EQUAL( none, _parser->getTestPath() );
+ CPPUNIT_ASSERT_EQUAL( none, _parser->getXmlFileName() );
+ CPPUNIT_ASSERT_EQUAL( none, _parser->getXmlStyleSheet() );
+ CPPUNIT_ASSERT( !_parser->noTestProgress() );
+ CPPUNIT_ASSERT( !_parser->useBriefTestProgress() );
+ CPPUNIT_ASSERT( _parser->useCompilerOutputter() );
+ CPPUNIT_ASSERT( !_parser->useCoutStream() );
+ CPPUNIT_ASSERT( !_parser->useTextOutputter() );
+ CPPUNIT_ASSERT( !_parser->useXmlOutputter() );
+ CPPUNIT_ASSERT_EQUAL( 0, _parser->getPlugInCount() );
+}
+
+
+void
+CommandLineParserTest::testLongFlagBriefProgress()
+{
+ static char *lines[] = { "", "--brief-progress", NULL };
+ parse( lines );
+
+ std::string none;
+ CPPUNIT_ASSERT_EQUAL( none, _parser->getEncoding() );
+ CPPUNIT_ASSERT_EQUAL( none, _parser->getTestPath() );
+ CPPUNIT_ASSERT_EQUAL( none, _parser->getXmlFileName() );
+ CPPUNIT_ASSERT_EQUAL( none, _parser->getXmlStyleSheet() );
+ CPPUNIT_ASSERT( !_parser->noTestProgress() );
+ CPPUNIT_ASSERT( _parser->useBriefTestProgress() );
+ CPPUNIT_ASSERT( !_parser->useCompilerOutputter() );
+ CPPUNIT_ASSERT( !_parser->useCoutStream() );
+ CPPUNIT_ASSERT( !_parser->useTextOutputter() );
+ CPPUNIT_ASSERT( !_parser->useXmlOutputter() );
+ CPPUNIT_ASSERT_EQUAL( 0, _parser->getPlugInCount() );
+}
+
+
+void
+CommandLineParserTest::testFileName()
+{
+ static char *lines[] = { "", "TestPlugIn.dll", NULL };
+ parse( lines );
+
+ std::string none;
+ CPPUNIT_ASSERT_EQUAL( none, _parser->getEncoding() );
+ CPPUNIT_ASSERT_EQUAL( none, _parser->getTestPath() );
+ CPPUNIT_ASSERT_EQUAL( none, _parser->getXmlFileName() );
+ CPPUNIT_ASSERT_EQUAL( none, _parser->getXmlStyleSheet() );
+ CPPUNIT_ASSERT( !_parser->noTestProgress() );
+ CPPUNIT_ASSERT( !_parser->useBriefTestProgress() );
+ CPPUNIT_ASSERT( !_parser->useCompilerOutputter() );
+ CPPUNIT_ASSERT( !_parser->useCoutStream() );
+ CPPUNIT_ASSERT( !_parser->useTextOutputter() );
+ CPPUNIT_ASSERT( !_parser->useXmlOutputter() );
+
+ CPPUNIT_ASSERT_EQUAL( 1, _parser->getPlugInCount() );
+
+ CommandLinePlugInInfo info( _parser->getPlugInAt( 0 ) );
+ CPPUNIT_ASSERT_EQUAL( std::string("TestPlugIn.dll"), info.m_fileName );
+ CPPUNIT_ASSERT_EQUAL( 0, int(info.m_parameters.size()) );
+}
+
+
+void
+CommandLineParserTest::testTestPath()
+{
+ static char *lines[] = { "", ":Core", NULL };
+ parse( lines );
+
+ std::string none;
+ CPPUNIT_ASSERT_EQUAL( none, _parser->getEncoding() );
+ CPPUNIT_ASSERT_EQUAL( std::string("Core"), _parser->getTestPath() );
+ CPPUNIT_ASSERT_EQUAL( none, _parser->getXmlFileName() );
+ CPPUNIT_ASSERT_EQUAL( none, _parser->getXmlStyleSheet() );
+ CPPUNIT_ASSERT( !_parser->noTestProgress() );
+ CPPUNIT_ASSERT( !_parser->useBriefTestProgress() );
+ CPPUNIT_ASSERT( !_parser->useCompilerOutputter() );
+ CPPUNIT_ASSERT( !_parser->useCoutStream() );
+ CPPUNIT_ASSERT( !_parser->useTextOutputter() );
+ CPPUNIT_ASSERT( !_parser->useXmlOutputter() );
+ CPPUNIT_ASSERT_EQUAL( 0, _parser->getPlugInCount() );
+}
+
+
+void
+CommandLineParserTest::testParameterWithSpace()
+{
+ static char *lines[] = { "", "--xml", "Test Results.xml", NULL };
+ parse( lines );
+
+ std::string none;
+ CPPUNIT_ASSERT_EQUAL( none, _parser->getEncoding() );
+ CPPUNIT_ASSERT_EQUAL( none, _parser->getTestPath() );
+ CPPUNIT_ASSERT_EQUAL( std::string("Test Results.xml"),
+ _parser->getXmlFileName() );
+ CPPUNIT_ASSERT_EQUAL( none, _parser->getXmlStyleSheet() );
+ CPPUNIT_ASSERT( !_parser->noTestProgress() );
+ CPPUNIT_ASSERT( !_parser->useBriefTestProgress() );
+ CPPUNIT_ASSERT( !_parser->useCompilerOutputter() );
+ CPPUNIT_ASSERT( !_parser->useCoutStream() );
+ CPPUNIT_ASSERT( !_parser->useTextOutputter() );
+ CPPUNIT_ASSERT( _parser->useXmlOutputter() );
+ CPPUNIT_ASSERT_EQUAL( 0, _parser->getPlugInCount() );
+}
+
+
+void
+CommandLineParserTest::testMissingStyleSheetParameterThrow()
+{
+ static char *lines[] = { "", "--xsl", NULL };
+ parse( lines );
+}
+
+
+void
+CommandLineParserTest::testMissingEncodingParameterThrow()
+{
+ static char *lines[] = { "", "--encoding", NULL };
+ parse( lines );
+}
+
+
+void
+CommandLineParserTest::testXmlFileNameIsOptional()
+{
+ static char *lines[] = { "", "--xml", NULL };
+ parse( lines );
+
+ std::string none;
+ CPPUNIT_ASSERT_EQUAL( none, _parser->getXmlFileName() );
+}
+
+
+void
+CommandLineParserTest::testPlugInsWithParameters()
+{
+ static char *lines[] = { "", "TestPlugIn1.dll=login = lain",
+ "Clocker.dll", NULL };
+ parse( lines );
+
+ CPPUNIT_ASSERT_EQUAL( 2, _parser->getPlugInCount() );
+
+ CommandLinePlugInInfo info1( _parser->getPlugInAt( 0 ) );
+
+ CPPUNIT_ASSERT_EQUAL( std::string("TestPlugIn1.dll"), info1.m_fileName );
+ CPPUNIT_ASSERT_EQUAL( 1, int(info1.m_parameters.size()) );
+ CPPUNIT_ASSERT_EQUAL( std::string("login = lain"),
+ info1.m_parameters[0] );
+
+ CommandLinePlugInInfo info2( _parser->getPlugInAt( 1 ) );
+ CPPUNIT_ASSERT_EQUAL( std::string("Clocker.dll"), info2.m_fileName );
+ CPPUNIT_ASSERT_EQUAL( 0, int(info2.m_parameters.size()) );
+}
diff --git a/src/DllPlugInTester/CommandLineParserTest.h b/src/DllPlugInTester/CommandLineParserTest.h
new file mode 100644
index 0000000..3e31709
--- /dev/null
+++ b/src/DllPlugInTester/CommandLineParserTest.h
@@ -0,0 +1,61 @@
+#ifndef COMMANDLINEPARSERTEST_H
+#define COMMANDLINEPARSERTEST_H
+
+#include <cppunit/extensions/HelperMacros.h>
+
+
+class CommandLineParser;
+class CommandLineParserException;
+
+
+class CommandLineParserTest : public CppUnit::TestCase
+{
+ CPPUNIT_TEST_SUITE( CommandLineParserTest );
+ CPPUNIT_TEST( testEmptyCommandLine );
+ CPPUNIT_TEST( testFlagCompiler );
+ CPPUNIT_TEST( testLongFlagBriefProgress );
+ CPPUNIT_TEST( testFileName );
+ CPPUNIT_TEST( testTestPath );
+ CPPUNIT_TEST( testParameterWithSpace );
+ CPPUNIT_TEST_EXCEPTION( testMissingStyleSheetParameterThrow, CommandLineParserException);
+ CPPUNIT_TEST_EXCEPTION( testMissingEncodingParameterThrow, CommandLineParserException);
+ CPPUNIT_TEST( testXmlFileNameIsOptional );
+ CPPUNIT_TEST( testPlugInsWithParameters );
+ CPPUNIT_TEST_SUITE_END();
+
+public:
+ CommandLineParserTest();
+ virtual ~CommandLineParserTest();
+
+ void setUp();
+ void tearDown();
+
+ void testEmptyCommandLine();
+ void testFlagCompiler();
+ void testLongFlagBriefProgress();
+ void testFileName();
+ void testTestPath();
+ void testParameterWithSpace();
+ void testMissingStyleSheetParameterThrow();
+ void testMissingEncodingParameterThrow();
+ void testXmlFileNameIsOptional();
+ void testPlugInsWithParameters();
+
+private:
+ CommandLineParserTest( const CommandLineParserTest &other );
+ void operator =( const CommandLineParserTest &other );
+
+ void parse( char **lines );
+
+private:
+ CommandLineParser *_parser;
+};
+
+
+
+// Inlines methods for CommandLineParserTest:
+// ------------------------------------------
+
+
+
+#endif // COMMANDLINEPARSERTEST_H
diff --git a/src/DllPlugInTester/DllPlugInTester.cpp b/src/DllPlugInTester/DllPlugInTester.cpp
index df55e06..d7cf099 100644
--- a/src/DllPlugInTester/DllPlugInTester.cpp
+++ b/src/DllPlugInTester/DllPlugInTester.cpp
@@ -99,6 +99,66 @@ runTests( const CommandLineParser &parser )
}
+void
+printShortUsage( const std::string &applicationName )
+{
+ std::cout << "Usage:" << std::endl
+ << applicationName << " [-c -b -n -t -o] [-x xml-filename]"
+ "[-s stylesheet] [-e encoding] plug-in[=parameters] [plug-in...] [:testPath]"
+ << std::endl << std::endl;
+}
+
+
+void
+printUsage( const std::string &applicationName )
+{
+ printShortUsage( applicationName );
+ std::cout <<
+"-c --compiler\n"
+" Use CompilerOutputter\n"
+"-x --xml [filename]\n"
+" Use XmlOutputter (if filename is omitted, then output to cout or\n"
+" cerr.\n"
+"-s --xsl stylesheet\n"
+" XML style sheet for XML Outputter\n"
+"-e --encoding encoding\n"
+" XML file encoding (UTF8, shift_jis, ISO-8859-1...)\n"
+"-b --brief-progress\n"
+" Use BriefTestProgressListener (default is TextTestProgressListener)\n"
+"-n --no-progress\n"
+" Show no test progress (disable default TextTestProgressListener)\n"
+"-t --text\n"
+" Use TextOutputter\n"
+"-o --cout\n"
+" Ouputters output to cout instead of the default cerr.\n"
+"filename[=\"options\"]\n"
+" Many filenames can be specified. They are the name of the \n"
+" test plug-ins to load. Optional plug-ins parameters can be \n"
+" specified after the filename by adding '='.\n"
+"[:testpath]\n"
+" Optional. Only one test path can be specified. It must \n"
+" be prefixed with ':'. See TestPath constructor for syntax.\n"
+"\n"
+"'parameters' (test plug-in or XML filename, test path...) may contains \n"
+"spaces if double quoted. Quote may be escaped with \".\n"
+"\n"
+"Some examples of command lines:\n"
+"\n"
+"DllPlugInTesterd_dll.exe -b -x tests.xml -c simple_plugind.dll CppUnitTestPlugInd.dll\n"
+"\n"
+" Will load 2 tests plug-ins (available in lib/), use the brief test\n"
+"progress, output the result in XML in file tests.xml and also\n"
+"output the result using the compiler outputter.\n"
+"\n"
+"DllPlugInTesterd_dll.exe ClockerPlugInd.dll=\"flat\" -n CppUnitTestPlugInd.dll\n"
+"\n"
+" Will load the 2 test plug-ins, and pass the parameter string \"flat\"\n"
+"to the Clocker plug-in, disable test progress.\n"
+ << std::endl;
+
+}
+
+
/*! Main
*
* Usage:
@@ -139,10 +199,7 @@ main( int argc,
std::string applicationName( argv[0] );
if ( argc < 2 )
{
- std::cerr << "Usage: " << std::endl
- << applicationName
- << " dll-filename1 [dll-filename2 ...] [:test-path]..."
- << std::endl;
+ printUsage( applicationName );
return badCommadLineReturnCode;
}
@@ -154,7 +211,8 @@ main( int argc,
catch ( CommandLineParserException &e )
{
std::cerr << "Error while parsing command line: " << e.what()
- << std::endl;
+ << std::endl << std::endl;
+ printShortUsage( applicationName );
return badCommadLineReturnCode;
}
diff --git a/src/DllPlugInTester/DllPlugInTesterTest.cpp b/src/DllPlugInTester/DllPlugInTesterTest.cpp
new file mode 100644
index 0000000..e85d02b
--- /dev/null
+++ b/src/DllPlugInTester/DllPlugInTesterTest.cpp
@@ -0,0 +1,16 @@
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+
+int main(int argc, char* argv[])
+{
+ CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
+ CppUnit::TextUi::TestRunner runner;
+ runner.addTest( suite );
+ runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),
+ std::cerr ) );
+ bool wasSucessful = runner.run();
+ return wasSucessful ? 0 : 1;
+}
+
diff --git a/src/DllPlugInTester/DllPlugInTesterTest.dsp b/src/DllPlugInTester/DllPlugInTesterTest.dsp
new file mode 100644
index 0000000..74044d6
--- /dev/null
+++ b/src/DllPlugInTester/DllPlugInTesterTest.dsp
@@ -0,0 +1,149 @@
+# Microsoft Developer Studio Project File - Name="DllPlugInTesterTest" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=DllPlugInTesterTest - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "DllPlugInTesterTest.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "DllPlugInTesterTest.mak" CFG="DllPlugInTesterTest - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "DllPlugInTesterTest - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "DllPlugInTesterTest - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "DllPlugInTesterTest - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "ReleaseTest"
+# PROP Intermediate_Dir "ReleaseTest"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GR /GX /O2 /I "..\..\include" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "CPPUNIT_DLL" /YX /FD /c
+# ADD BASE RSC /l 0x40c /d "NDEBUG"
+# ADD RSC /l 0x40c /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib cppunit_dll.lib /nologo /subsystem:console /machine:I386 /libpath:"../../lib"
+# Begin Special Build Tool
+TargetPath=.\ReleaseTest\DllPlugInTesterTest.exe
+SOURCE="$(InputPath)"
+PostBuild_Desc=Unit testing...
+PostBuild_Cmds=$(TargetPath)
+# End Special Build Tool
+
+!ELSEIF "$(CFG)" == "DllPlugInTesterTest - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "DebugTest"
+# PROP Intermediate_Dir "DebugTest"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm /GR /GX /ZI /Od /I "..\..\include" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "CPPUNIT_DLL" /YX /FD /GZ /c
+# ADD BASE RSC /l 0x40c /d "_DEBUG"
+# ADD RSC /l 0x40c /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib cppunitd_dll.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"../../lib"
+# Begin Special Build Tool
+TargetPath=.\DebugTest\DllPlugInTesterTest.exe
+SOURCE="$(InputPath)"
+PostBuild_Desc=Unit testing...
+PostBuild_Cmds=$(TargetPath)
+# End Special Build Tool
+
+!ENDIF
+
+# Begin Target
+
+# Name "DllPlugInTesterTest - Win32 Release"
+# Name "DllPlugInTesterTest - Win32 Debug"
+# Begin Source File
+
+SOURCE=..\..\src\DllPlugInTester\CommandLineParser.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\src\DllPlugInTester\CommandLineParser.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\CommandLineParserTest.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\CommandLineParserTest.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\lib\cppunitd_dll.dll
+
+!IF "$(CFG)" == "DllPlugInTesterTest - Win32 Release"
+
+# Begin Custom Build - Updating $(InputPath)
+IntDir=.\ReleaseTest
+InputPath=..\..\lib\cppunitd_dll.dll
+InputName=cppunitd_dll
+
+"$(IntDir)\$(InputName).dll" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ copy $(InputPath) $(IntDir)\$(InputName).dll
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "DllPlugInTesterTest - Win32 Debug"
+
+# Begin Custom Build - Updating $(InputPath)
+IntDir=.\DebugTest
+InputPath=..\..\lib\cppunitd_dll.dll
+InputName=cppunitd_dll
+
+"$(IntDir)\$(InputName).dll" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ copy $(InputPath) $(IntDir)\$(InputName).dll
+
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\src\DllPlugInTester\DllPlugInTesterTest.cpp
+# End Source File
+# End Target
+# End Project
diff --git a/src/DllPlugInTester/Makefile.am b/src/DllPlugInTester/Makefile.am
index 6c37f47..6c6333a 100644
--- a/src/DllPlugInTester/Makefile.am
+++ b/src/DllPlugInTester/Makefile.am
@@ -1,9 +1,12 @@
-EXTRA_DIST = DllPlugInTester.dsp
+EXTRA_DIST = DllPlugInTester.dsp DllPlugInTesterTest.dsp
INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include
bin_PROGRAMS=DllPlugInTester
+TESTS = DllPlugInTesterTest
+check_PROGRAMS = $(TESTS)
+
DllPlugInTester_SOURCES= DllPlugInTester.cpp \
CommandLineParser.h \
CommandLineParser.cpp
@@ -12,3 +15,14 @@ DllPlugInTester_LDADD= \
$(top_builddir)/src/cppunit/libcppunit.la
DllPlugInTester_LDFLAGS = -ldl
+
+DllPlugInTesterTest_SOURCES = DllPlugInTesterTest.cpp \
+ CommandLineParser.cpp \
+ CommandLineParser.h \
+ CommandLineParserTest.cpp \
+ CommandLineParserTest.h
+
+DllPlugInTesterTest_LDADD= \
+ $(top_builddir)/src/cppunit/libcppunit.la
+
+DllPlugInTesterTest_LDFLAGS = -ldl