another attempt to get tests to link on windows

This commit is contained in:
Arvid Norberg 2013-08-27 07:02:46 +00:00
parent 503ebc91bd
commit f2aca363ad
3 changed files with 24 additions and 24 deletions

View File

@ -138,13 +138,13 @@ int main()
}
catch (std::exception const& e)
{
std::cerr << "Terminated with exception: \"" << e.what() << "\"\n";
tests_failure = true;
char buf[200];
snprintf(buf, sizeof(buf), "Terminated with exception: \"%s\"", e.what());
report_failure(buf, __FILE__, __LINE__);
}
catch (...)
{
std::cerr << "Terminated with unknown exception\n";
tests_failure = true;
report_failure("Terminated with unknown exception", __FILE__, __LINE__);
}
#endif
@ -158,21 +158,11 @@ int main()
fflush(stdout);
fflush(stderr);
if (tests_failure == 0)
{
remove_all(test_dir, ec);
if (ec)
fprintf(stderr, "failed to remove test dir: %s\n", ec.message().c_str());
}
else
{
for (std::vector<std::string>::iterator i = failure_strings.begin()
, end(failure_strings.end()); i != end; ++i)
{
fputs(i->c_str(), stderr);
}
fprintf(stderr, "\n\n\x1b[41m == %d TEST(S) FAILED ==\x1b[0m\n\n\n", tests_failure);
}
return tests_failure;
remove_all(test_dir, ec);
if (ec)
fprintf(stderr, "failed to remove test dir: %s\n", ec.message().c_str());
return print_failures();
}

View File

@ -66,8 +66,8 @@ POSSIBILITY OF SUCH DAMAGE.
using namespace libtorrent;
int tests_failure = 0;
std::vector<std::string> failure_strings;
static int tests_failure = 0;
static std::vector<std::string> failure_strings;
void report_failure(char const* err, char const* file, int line)
{
@ -78,6 +78,17 @@ void report_failure(char const* err, char const* file, int line)
++tests_failure;
}
int print_failures()
{
for (std::vector<std::string>::iterator i = failure_strings.begin()
, end(failure_strings.end()); i != end; ++i)
{
fputs(i->c_str(), stderr);
}
fprintf(stderr, "\n\n\x1b[41m == %d TEST(S) FAILED ==\x1b[0m\n\n\n", tests_failure);
return tests_failure;
}
std::auto_ptr<alert> wait_for_alert(session& ses, int type)
{
std::auto_ptr<alert> ret;

View File

@ -44,8 +44,7 @@ namespace libtorrent
struct session_status;
}
extern EXPORT int tests_failure;
extern EXPORT std::vector<std::string> failure_strings;
int EXPORT print_failures();
int EXPORT load_file(std::string const& filename, std::vector<char>& v, libtorrent::error_code& ec, int limit = 8000000);