WIP: started augmenting my test-runner class to be configurable via cmdline
Added dependency to boost::program_options. Still trying to get into pace with the testing thing ;-)
This commit is contained in:
parent
0f3bf1aa31
commit
cb13b09360
15 changed files with 353 additions and 26 deletions
13
SConstruct
13
SConstruct
|
|
@ -174,6 +174,7 @@ def configurePlatform(env):
|
|||
print 'Did not find the pthread lib or pthread.h, exiting.'
|
||||
else:
|
||||
conf.env.Append(CPPFLAGS = ' -DHAVE_PTHREAD_H')
|
||||
conf.env.Append(CCFLAGS = ' -pthread')
|
||||
|
||||
if conf.CheckCHeader('execinfo.h'):
|
||||
conf.env.Append(CPPFLAGS = ' -DHAS_EXECINFO_H')
|
||||
|
|
@ -188,10 +189,14 @@ def configurePlatform(env):
|
|||
if not conf.CheckCXXHeader('boost/config.hpp'):
|
||||
print 'We need the C++ boost-lib.'
|
||||
Exit(1)
|
||||
|
||||
if not conf.CheckCXXHeader('boost/shared_ptr.hpp'):
|
||||
print 'We need boost::shared_ptr (shared_ptr.hpp).'
|
||||
Exit(1)
|
||||
else:
|
||||
if not conf.CheckCXXHeader('boost/shared_ptr.hpp'):
|
||||
print 'We need boost::shared_ptr (shared_ptr.hpp).'
|
||||
Exit(1)
|
||||
if not conf.CheckLibWithHeader('boost_program_options-mt','boost/program_options.hpp','C++'):
|
||||
print 'We need boost::program_options (also the corresponding binary lib).'
|
||||
Exit(1)
|
||||
|
||||
|
||||
# create new env containing the finished configuration
|
||||
return conf.Finish()
|
||||
|
|
|
|||
|
|
@ -22,9 +22,21 @@
|
|||
|
||||
|
||||
#include "common/error.hpp"
|
||||
#include "nobugcfg.h"
|
||||
|
||||
///////////////////////////////////TODO
|
||||
#include <iostream>
|
||||
|
||||
extern void booo()
|
||||
{
|
||||
std::cerr << "Booooo!!!" << std::endl;
|
||||
std::cerr.flush();
|
||||
}
|
||||
///////////////////////////////////TODO
|
||||
|
||||
namespace cinelerra
|
||||
{
|
||||
char* killme ="cinelerra Errrror. TODO real description needed";
|
||||
|
||||
/** Description of the problem, including the internal char constant
|
||||
* in accordance to cinelerras error identification scheme.
|
||||
|
|
@ -34,6 +46,8 @@ namespace cinelerra
|
|||
const char*
|
||||
Error::what () const throw()
|
||||
{
|
||||
TODO("really implement cinelerra::Error description");
|
||||
return killme;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -46,6 +60,7 @@ namespace cinelerra
|
|||
std::exception
|
||||
Error::rootCause() const throw()
|
||||
{
|
||||
UNIMPLEMENTED("storing and managing root causes");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -72,6 +72,11 @@ namespace cinelerra
|
|||
{
|
||||
|
||||
};
|
||||
|
||||
class Fatal : public Logic
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
class Config : public Error
|
||||
{
|
||||
|
|
@ -93,10 +98,24 @@ namespace cinelerra
|
|||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace error
|
||||
|
||||
} // namespace cinelerra
|
||||
|
||||
#include <iostream>
|
||||
|
||||
extern void booo();
|
||||
|
||||
/******************************************************
|
||||
* if NoBug is used, redefine some macros
|
||||
* to rather throw Cinelerra Errors instead of aborting
|
||||
*/
|
||||
#ifdef NOBUG_ABORT
|
||||
#undef NOBUG_ABORT
|
||||
#define NOBUG_ABORT throw cinelerra::error::Fatal(); ////////////////TODO
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include "helper/suite.hpp"
|
||||
#include "common/test/suite.hpp"
|
||||
|
||||
|
||||
namespace test
|
||||
|
|
@ -37,7 +37,7 @@ namespace test
|
|||
using std::string;
|
||||
using std::auto_ptr;
|
||||
|
||||
typedef std::vector<string> * Arg;
|
||||
typedef std::vector<string> & Arg;
|
||||
|
||||
|
||||
|
||||
|
|
@ -89,4 +89,12 @@ using ::test::Arg;
|
|||
using ::test::Test;
|
||||
using ::test::Launch;
|
||||
|
||||
// and provide shortcut for registration
|
||||
#define LAUNCHER(_TEST_CLASS_, _GROUPS_) \
|
||||
/** Register _TEST_CLASS_ to be invoked in some test suites (groups) _GROUPS_ */ \
|
||||
Launch<_TEST_CLASS_> run_##_TEST_CLASS_##_(STRINGIFY(_TEST_CLASS_), _GROUPS_);
|
||||
|
||||
#define STRINGIFY(TOKEN) __STRINFY(TOKEN)
|
||||
#define __STRINFY(TOKEN) #TOKEN
|
||||
|
||||
#endif
|
||||
|
|
@ -28,8 +28,8 @@
|
|||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
#include "helper/suite.hpp"
|
||||
#include "helper/run.hpp"
|
||||
#include "common/test/suite.hpp"
|
||||
#include "common/test/run.hpp"
|
||||
#include "common/error.hpp"
|
||||
#include "common/util.hpp"
|
||||
|
||||
|
|
@ -151,15 +151,18 @@ namespace test
|
|||
// go ahead and invoke just this test.
|
||||
if (argc > 2)
|
||||
{ // pass additional cmdline as vector
|
||||
FIXME("use Optparser");
|
||||
vector<string> arglist(argc-2);
|
||||
for ( int i=2; i<argc; ++i )
|
||||
arglist.push_back(string(argv[i]));
|
||||
|
||||
// run single Testcase with provided arguments
|
||||
(*test)()->run(&arglist);
|
||||
(*test)()->run(arglist);
|
||||
}
|
||||
else
|
||||
(*test)()->run(0); // without additional argumens
|
||||
FIXME("use Optparser");
|
||||
vector<string> nix;
|
||||
(*test)()->run(nix); // without additional argumens
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
@ -172,7 +175,9 @@ namespace test
|
|||
{
|
||||
std::cout << " ----------"<< i->first<< "----------\n";
|
||||
Launcher& test = *(i->second);
|
||||
test()->run(0); // without cmdline arguments
|
||||
FIXME("use Optparser");
|
||||
vector<string> nix;
|
||||
test()->run(nix); // without cmdline arguments
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -37,10 +37,12 @@ namespace test
|
|||
class Launcher;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Helper class for running a collection of tests.
|
||||
*
|
||||
* Enables running a collection of tests.
|
||||
* In internal registration service #enroll() is provided
|
||||
* for the individual Test - inscances to be recognized as
|
||||
* testcases. The groupID passed to the constructor selects
|
||||
* all testcases declared as belonging to this Group.
|
||||
*/
|
||||
class Suite
|
||||
{
|
||||
|
|
@ -53,8 +55,7 @@ namespace test
|
|||
|
||||
static const string ALLGROUP;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace test
|
||||
#endif
|
||||
122
src/common/test/testoption.cpp
Normal file
122
src/common/test/testoption.cpp
Normal file
|
|
@ -0,0 +1,122 @@
|
|||
/*
|
||||
Suite - helper class for running collections of tests
|
||||
|
||||
Copyright (C) CinelerraCV
|
||||
2007, Christian Thaeter <ct@pipapo.org>
|
||||
|
||||
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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
* *****************************************************/
|
||||
|
||||
|
||||
//#include <map>
|
||||
//#include <memory>
|
||||
//#include <tr1/memory>
|
||||
//#include <iostream>
|
||||
//#include <sstream>
|
||||
|
||||
#include "common/test/testoption.hpp"
|
||||
#include "common/test/suite.hpp"
|
||||
//#include "common/util.hpp"
|
||||
|
||||
#include "nobugcfg.h"
|
||||
#include "common/error.hpp"
|
||||
|
||||
|
||||
namespace test
|
||||
{
|
||||
// using std::map;
|
||||
// using std::auto_ptr;
|
||||
// using std::tr1::shared_ptr;
|
||||
|
||||
// using util::isnil;
|
||||
|
||||
|
||||
|
||||
/** set up an options parser to use the current commandline.
|
||||
* reconizes the following options
|
||||
* \code
|
||||
* --help
|
||||
* --group <groupID>
|
||||
* \endcode
|
||||
*/
|
||||
TestOption::TestOption (int argc, const char* argv[])
|
||||
: vm(), cmdline()
|
||||
{
|
||||
cmdline.reserve (10);
|
||||
parseOptions (argc,argv);
|
||||
}
|
||||
|
||||
|
||||
/** variant of the ctor taking a "fake" cmdline */
|
||||
TestOption::TestOption (string line)
|
||||
: vm(), cmdline()
|
||||
{
|
||||
cmdline.reserve (10);
|
||||
const char* fakeArg[3] = {"test", line.c_str() };
|
||||
// fakeArg[1] = line.c_str();
|
||||
parseOptions (1,fakeArg);
|
||||
}
|
||||
|
||||
|
||||
/** do the comandline parsing for the ctors */
|
||||
void TestOption::parseOptions (int argc, const char* argv[])
|
||||
{
|
||||
TODO("define options");
|
||||
UNIMPLEMENTED("actual commandline parsing!!");
|
||||
}
|
||||
|
||||
|
||||
/** @return the Tests-Group as given on cmdline, or Suite::ALLGROUP as default
|
||||
*/
|
||||
const string &
|
||||
TestOption::getTestgroup ()
|
||||
{
|
||||
FIXME("actual commandline parsing!!");
|
||||
return Suite::ALLGROUP;
|
||||
}
|
||||
|
||||
string booooh = "boooh!";
|
||||
/** @return ID of a single test to run, empty if not specified
|
||||
*/
|
||||
const string &
|
||||
TestOption::getTestID ()
|
||||
{
|
||||
UNIMPLEMENTED("actual commandline parsing");
|
||||
return booooh;
|
||||
}
|
||||
|
||||
|
||||
/** gather all remaining unknown cmd line tokens into a vector.
|
||||
* @Note: the actual vector remains a member of this object, but isn't const
|
||||
*/
|
||||
vector<string>&
|
||||
TestOption::remainingCmdline ()
|
||||
{
|
||||
UNIMPLEMENTED("get unknown remaining options");
|
||||
return cmdline;
|
||||
}
|
||||
|
||||
|
||||
/** */
|
||||
TestOption::operator string const ()
|
||||
{
|
||||
UNIMPLEMENTED("convert the remaining Cmndline to string");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace test
|
||||
70
src/common/test/testoption.hpp
Normal file
70
src/common/test/testoption.hpp
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
TESTOPTION.hpp - handle cmdline for invoking Testsuite
|
||||
|
||||
Copyright (C) CinelerraCV
|
||||
2007, Christian Thaeter <ct@pipapo.org>
|
||||
|
||||
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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#ifndef TESTHELPER_TESTOPTION_H
|
||||
#define TESTHELPER_TESTOPTION_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <boost/program_options.hpp>
|
||||
|
||||
|
||||
|
||||
namespace test
|
||||
{
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
typedef boost::program_options::variables_map VarMap;
|
||||
|
||||
|
||||
/**
|
||||
* Support for selecting and configuring testcases
|
||||
* via commandline arguments. A preconfigured wrapper
|
||||
* around boost::program_options, with the ability
|
||||
* to tolerate unknown options and get an vector<string>
|
||||
* of everything remaining in the commandline after
|
||||
* parsing the known options.
|
||||
*/
|
||||
class TestOption
|
||||
{
|
||||
public:
|
||||
TestOption (int argc, const char* argv[]);
|
||||
explicit TestOption (string cmdline);
|
||||
const string& getTestgroup ();
|
||||
const string& getTestID ();
|
||||
vector<string>& remainingCmdline ();
|
||||
|
||||
operator string const ();
|
||||
|
||||
private:
|
||||
VarMap vm;
|
||||
vector<string> cmdline;
|
||||
|
||||
void parseOptions (int argc, const char* argv[]);
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // namespace test
|
||||
#endif
|
||||
1
tests/.gitignore
vendored
1
tests/.gitignore
vendored
|
|
@ -1,4 +1,5 @@
|
|||
,*
|
||||
test-*
|
||||
mainsuite
|
||||
errortest
|
||||
plugin-example
|
||||
|
|
|
|||
|
|
@ -10,3 +10,8 @@ out: This is how the world ends...
|
|||
return: 0
|
||||
END
|
||||
|
||||
TEST "Parseoption" TestOption_test <<END
|
||||
out: Testing invocation with cmdline: ...
|
||||
return: 0
|
||||
END
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
* *****************************************************/
|
||||
|
||||
|
||||
#include "helper/run.hpp"
|
||||
#include "common/test/run.hpp"
|
||||
|
||||
|
||||
namespace cinelerra
|
||||
|
|
|
|||
73
tests/components/common/test/testoptiontest.cpp
Normal file
73
tests/components/common/test/testoptiontest.cpp
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
TestOption(Test) - parsing of cmd line options for running Testcases
|
||||
|
||||
Copyright (C) CinelerraCV
|
||||
2007, Christian Thaeter <ct@pipapo.org>
|
||||
|
||||
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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
* *****************************************************/
|
||||
|
||||
|
||||
#include <iostream>
|
||||
#include "common/test/run.hpp"
|
||||
#include "common/test/testoption.hpp"
|
||||
#include "common/util.hpp"
|
||||
|
||||
using util::isnil;
|
||||
|
||||
namespace test
|
||||
{
|
||||
|
||||
class TestOption_test : public Test
|
||||
{
|
||||
virtual void run(Arg arg)
|
||||
{
|
||||
noOptions();
|
||||
help();
|
||||
groupID();
|
||||
singleTest();
|
||||
groupFilter1();
|
||||
groupFilter2();
|
||||
additionalCmd();
|
||||
additionalCmd2();
|
||||
}
|
||||
|
||||
void doIt (const string cmdline)
|
||||
{
|
||||
std::cout << "Testing invocation with cmdline: " << cmdline << "..." << std::endl;
|
||||
|
||||
TestOption optparser (cmdline);
|
||||
const string testID = optparser.getTestID();
|
||||
std::cout << "--> Testgroup=" << optparser.getTestgroup() << std::endl;
|
||||
std::cout << "--> Test-ID =" << (isnil(testID)? testID : "--missing--") << std::endl;
|
||||
std::cout << "--> remaining=" << string(optparser) << std::endl;
|
||||
}
|
||||
|
||||
void noOptions() { doIt (""); }
|
||||
void help() { doIt ("--help"); }
|
||||
void groupID() { doIt ("--group TestGroupID"); }
|
||||
void singleTest() { doIt (" SingleTestID"); }
|
||||
void groupFilter1() { doIt (" SingleTestID --group TestGroupID"); }
|
||||
void groupFilter2() { doIt (" --group TestGroupID SingleTestID "); }
|
||||
void additionalCmd() { doIt (" --group TestGroupID SingleTestID spam eggs"); }
|
||||
void additionalCmd2() { doIt ("\t\tSingleTestID spam --group TestGroupID \t eggs"); }
|
||||
|
||||
};
|
||||
|
||||
LAUNCHER (TestOption_test, "function common");
|
||||
|
||||
} // namespace test
|
||||
|
||||
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
#include <iostream>
|
||||
#include "helper/run.hpp"
|
||||
#include "common/test/run.hpp"
|
||||
|
||||
|
||||
namespace cinelerra
|
||||
|
|
@ -49,6 +49,7 @@ namespace cinelerra
|
|||
/** Register this test class to be invoked in some test groups (suites) */
|
||||
Launch<HelloWorld_test> run_HelloWorld_test("HelloWorld_test","unit common");
|
||||
|
||||
// NOTE: you may use the Macro "LAUNCHER" in run.hpp to simplify this Registration
|
||||
|
||||
} // namespace test
|
||||
|
||||
|
|
@ -21,8 +21,7 @@
|
|||
*/
|
||||
|
||||
|
||||
#include "helper/suite.hpp"
|
||||
|
||||
#include "common/test/suite.hpp"
|
||||
|
||||
/** run all tests or any single test specified in the first
|
||||
* cmd line argument.
|
||||
|
|
|
|||
|
|
@ -747,14 +747,17 @@ config.macros.timeline.handler = function(place,macroName,params,wikifier,paramS
|
|||
}
|
||||
//}}}</pre>
|
||||
</div>
|
||||
<div title="BuildDependenceis" modifier="Ichthyostega" modified="200708140618" created="200708120103" tags="organization buildsys" changecount="5">
|
||||
<div title="BuildDependenceis" modifier="Ichthyostega" modified="200708191952" created="200708120103" tags="organization buildsys" changecount="6">
|
||||
<pre>for __Building__
|
||||
* gcc (4.1), glibc6 (2.3), libstdc++6 (4.1)
|
||||
* [[build system|BuildSystem]] dependencies: SCons (0.96.90), Python (2.3)
|
||||
* NoBug for Logging, Tracing, Asserting (can be obtained from [[Pipapo.org|http://www.pipapo.org/pipawiki/NoBug]])
|
||||
* ~NoBug needs [[valgrind|Valgrind]] (3.2), execinfo.h and libpthread (&rarr; glibc)
|
||||
* std::tr1 &mdash; esp. for the former BOOST::shared_ptr (which is now proposed standard)
|
||||
* BOOST
|
||||
* BOOST ~~(below are the DEBIAN package names)~~
|
||||
** libboost-dev (=1.34.1-2)
|
||||
** libboost-program-options-dev (=1.34.1-2)
|
||||
** libboost-program-options1.34.1 (=1.34.1-2) ''NOTE: binary dependency''
|
||||
//usually, newer versions are OK//
|
||||
|
||||
for __Running__</pre>
|
||||
|
|
|
|||
Loading…
Reference in a new issue