improve error reporting from unit tests
This commit is contained in:
parent
1afc0c6740
commit
27adb1fc44
|
@ -158,12 +158,21 @@ int main()
|
|||
|
||||
fflush(stdout);
|
||||
fflush(stderr);
|
||||
if (!tests_failure)
|
||||
if (tests_failure == 0)
|
||||
{
|
||||
remove_all(test_dir, ec);
|
||||
if (ec)
|
||||
fprintf(stderr, "failed to remove test dir: %s\n", ec.message().c_str());
|
||||
}
|
||||
return tests_failure ? 1 : 0;
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -66,12 +66,16 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
using namespace libtorrent;
|
||||
|
||||
bool tests_failure = false;
|
||||
int tests_failure = 0;
|
||||
std::vector<std::string> failure_strings;
|
||||
|
||||
void report_failure(char const* err, char const* file, int line)
|
||||
{
|
||||
fprintf(stderr, "\n***** %s:%d \"%s\" *****\n\n", file, line, err);
|
||||
tests_failure = true;
|
||||
char buf[500];
|
||||
snprintf(buf, sizeof(buf), "\x1b[41m***** %s:%d \"%s\" *****\x1b[0m\n", file, line, err);
|
||||
fprintf(stderr, "\n%s\n", buf);
|
||||
failure_strings.push_back(buf);
|
||||
++tests_failure;
|
||||
}
|
||||
|
||||
std::auto_ptr<alert> wait_for_alert(session& ses, int type)
|
||||
|
|
|
@ -44,7 +44,8 @@ namespace libtorrent
|
|||
struct session_status;
|
||||
}
|
||||
|
||||
extern EXPORT bool tests_failure;
|
||||
extern EXPORT int tests_failure;
|
||||
extern EXPORT std::vector<std::string> failure_strings;
|
||||
|
||||
int EXPORT load_file(std::string const& filename, std::vector<char>& v, libtorrent::error_code& ec, int limit = 8000000);
|
||||
|
||||
|
|
Loading…
Reference in New Issue