projects
/
awesomized
/
libmemcached
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
|
github
raw
|
inline
| side by side
m4: fix multiple output
[awesomized/libmemcached]
/
libtest
/
framework.cc
diff --git
a/libtest/framework.cc
b/libtest/framework.cc
index ea7ca66505e79af9811da02b3701f854c772f151..2c9ba74b4aebc346b40856eb51b358a4263077a0 100644
(file)
--- a/
libtest/framework.cc
+++ b/
libtest/framework.cc
@@
-34,21
+34,22
@@
*
*/
*
*/
-#include
<config.h>
+#include
"libtest/yatlcon.h"
#include <libtest/common.h>
#include <libtest/collection.h>
#include <libtest/signal.h>
#include <libtest/common.h>
#include <libtest/collection.h>
#include <libtest/signal.h>
+#include <algorithm>
#include <fnmatch.h>
#include <iostream>
#include <fnmatch.h>
#include <iostream>
-using namespace libtest;
+namespace libtest {
-Framework::Framework(libtest::SignalThread& signal,
+Framework::Framework(libtest::SignalThread& signal_,
+ const std::string& name_,
const std::string& only_run_arg,
const std::string& wildcard_arg) :
const std::string& only_run_arg,
const std::string& wildcard_arg) :
- _collections(NULL),
_total(0),
_success(0),
_skipped(0),
_total(0),
_success(0),
_skipped(0),
@@
-59,13
+60,17
@@
Framework::Framework(libtest::SignalThread& signal,
_runner(NULL),
_socket(false),
_creators_ptr(NULL),
_runner(NULL),
_socket(false),
_creators_ptr(NULL),
- _signal(signal),
+ _signal(signal
_
),
_only_run(only_run_arg),
_only_run(only_run_arg),
- _wildcard(wildcard_arg)
+ _wildcard(wildcard_arg),
+ _name(name_)
{
get_world(this);
{
get_world(this);
+}
- for (collection_st *next= _collections; next and next->name; next++)
+void Framework::collections(collection_st collections_[])
+{
+ for (collection_st *next= collections_; next and next->name; next++)
{
_collection.push_back(new Collection(this, next));
}
{
_collection.push_back(new Collection(this, next));
}
@@
-82,12
+87,8
@@
Framework::~Framework()
delete _runner;
delete _runner;
- for (std::vector<Collection*>::iterator iter= _collection.begin();
- iter != _collection.end();
- iter++)
- {
- delete *iter;
- }
+ std::for_each(_collection.begin(), _collection.end(), DeleteFromVector());
+ _collection.clear();
}
bool Framework::match(const char* arg)
}
bool Framework::match(const char* arg)
@@
-104,46
+105,56
@@
void Framework::exec()
{
for (std::vector<Collection*>::iterator iter= _collection.begin();
iter != _collection.end() and (_signal.is_shutdown() == false);
{
for (std::vector<Collection*>::iterator iter= _collection.begin();
iter != _collection.end() and (_signal.is_shutdown() == false);
-
iter++
)
+
++iter
)
{
{
- if (_only_run.empty() == false and
- fnmatch(_only_run.c_str(), (*iter)->name(), 0))
+ if (*iter)
{
{
- continue;
- }
-
- _total++;
+ if (_only_run.empty() == false and
+ fnmatch(_only_run.c_str(), (*iter)->name(), 0))
+ {
+ continue;
+ }
- try {
- switch ((*iter)->exec())
+ _total++;
+
+ try {
+ switch ((*iter)->exec())
+ {
+ case TEST_FAILURE:
+ _failed++;
+ break;
+
+ case TEST_SKIPPED:
+ _skipped++;
+ break;
+
+ // exec() can return SUCCESS, but that doesn't mean that some tests did
+ // not fail or get skipped.
+ case TEST_SUCCESS:
+ _success++;
+ break;
+ }
+ }
+ catch (const libtest::fatal& e)
{
{
- case TEST_FAILURE:
_failed++;
_failed++;
- break;
-
- case TEST_SKIPPED:
- _skipped++;
- break;
-
- // exec() can return SUCCESS, but that doesn't mean that some tests did
- // not fail or get skipped.
- case TEST_SUCCESS:
- _success++;
- break;
+ stream::cerr(e.file(), e.line(), e.func()) << e.what();
+ }
+ catch (const libtest::disconnected& e)
+ {
+ _failed++;
+ Error << "Unhandled disconnection occurred:" << e.what();
+ throw;
+ }
+ catch (...)
+ {
+ _failed++;
+ throw;
}
}
}
}
- catch (libtest::fatal& e)
- {
- stream::cerr(e.file(), e.line(), e.func()) << e.mesg();
- }
- catch (libtest::disconnected& e)
- {
- Error << "Unhandled disconnection occurred:" << e.what();
- throw;
- }
-
- Outn();
}
}
+
+ void xml(const std::string& testsuites_name, std::ostream& output);
}
uint32_t Framework::sum_total()
}
uint32_t Framework::sum_total()
@@
-151,7
+162,7
@@
uint32_t Framework::sum_total()
uint32_t count= 0;
for (std::vector<Collection*>::iterator iter= _collection.begin();
iter != _collection.end();
uint32_t count= 0;
for (std::vector<Collection*>::iterator iter= _collection.begin();
iter != _collection.end();
-
iter++
)
+
++iter
)
{
count+= (*iter)->total();
}
{
count+= (*iter)->total();
}
@@
-164,7
+175,7
@@
uint32_t Framework::sum_success()
uint32_t count= 0;
for (std::vector<Collection*>::iterator iter= _collection.begin();
iter != _collection.end();
uint32_t count= 0;
for (std::vector<Collection*>::iterator iter= _collection.begin();
iter != _collection.end();
-
iter++
)
+
++iter
)
{
count+= (*iter)->success();
}
{
count+= (*iter)->success();
}
@@
-177,7
+188,7
@@
uint32_t Framework::sum_skipped()
uint32_t count= 0;
for (std::vector<Collection*>::iterator iter= _collection.begin();
iter != _collection.end();
uint32_t count= 0;
for (std::vector<Collection*>::iterator iter= _collection.begin();
iter != _collection.end();
-
iter++
)
+
++iter
)
{
count+= (*iter)->skipped();
}
{
count+= (*iter)->skipped();
}
@@
-190,7
+201,7
@@
uint32_t Framework::sum_failed()
uint32_t count= 0;
for (std::vector<Collection*>::iterator iter= _collection.begin();
iter != _collection.end();
uint32_t count= 0;
for (std::vector<Collection*>::iterator iter= _collection.begin();
iter != _collection.end();
-
iter++
)
+
++iter
)
{
count+= (*iter)->failed();
}
{
count+= (*iter)->failed();
}
@@
-219,3
+230,5
@@
test_return_t Framework::create()
return rc;
}
return rc;
}
+
+} // namespace libtest