test: Print all logged errors to stdout during gtests
This makes it easier to figure out test failures caused by errors on the Rust side, for which we generally log the error and then return a simple failure condition (`false` or `nullptr`) which obscures the error on the C++ side. We add similar logic to the Boost test framework, but commented out by default because it results in very verbose test output.
This commit is contained in:
parent
0daa540128
commit
8b68d73802
|
@ -1,4 +1,5 @@
|
||||||
#include "gmock/gmock.h"
|
#include "gmock/gmock.h"
|
||||||
|
#include "init.h"
|
||||||
#include "key.h"
|
#include "key.h"
|
||||||
#include "pubkey.h"
|
#include "pubkey.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
@ -6,6 +7,7 @@
|
||||||
|
|
||||||
#include "librustzcash.h"
|
#include "librustzcash.h"
|
||||||
#include <sodium.h>
|
#include <sodium.h>
|
||||||
|
#include <tracing.h>
|
||||||
|
|
||||||
const std::function<std::string(const char*)> G_TRANSLATION_FUN = nullptr;
|
const std::function<std::string(const char*)> G_TRANSLATION_FUN = nullptr;
|
||||||
|
|
||||||
|
@ -20,6 +22,13 @@ int main(int argc, char **argv) {
|
||||||
assert(sodium_init() != -1);
|
assert(sodium_init() != -1);
|
||||||
ECC_Start();
|
ECC_Start();
|
||||||
|
|
||||||
|
// Log all errors to stdout so we see them in test output.
|
||||||
|
std::string initialFilter = "error";
|
||||||
|
pTracingHandle = tracing_init(
|
||||||
|
nullptr, 0,
|
||||||
|
initialFilter.c_str(),
|
||||||
|
false);
|
||||||
|
|
||||||
testing::InitGoogleMock(&argc, argv);
|
testing::InitGoogleMock(&argc, argv);
|
||||||
|
|
||||||
// The "threadsafe" style is necessary for correct operation of death/exit
|
// The "threadsafe" style is necessary for correct operation of death/exit
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
#include <boost/thread.hpp>
|
#include <boost/thread.hpp>
|
||||||
#include <sodium.h>
|
#include <sodium.h>
|
||||||
|
#include <tracing.h>
|
||||||
|
|
||||||
#include "librustzcash.h"
|
#include "librustzcash.h"
|
||||||
|
|
||||||
|
@ -74,7 +75,18 @@ BasicTestingSetup::BasicTestingSetup(const std::string& chainName)
|
||||||
ECC_Start();
|
ECC_Start();
|
||||||
SetupEnvironment();
|
SetupEnvironment();
|
||||||
SetupNetworking();
|
SetupNetworking();
|
||||||
fPrintToDebugLog = false; // don't want to write to debug.log file
|
|
||||||
|
// Uncomment this to log all errors to stdout so we see them in test output.
|
||||||
|
// We don't enable this by default because several tests intentionally cause
|
||||||
|
// verbose error output (while exercising failure cases).
|
||||||
|
// if (pTracingHandle == nullptr) {
|
||||||
|
// std::string initialFilter = "error";
|
||||||
|
// pTracingHandle = tracing_init(
|
||||||
|
// nullptr, 0,
|
||||||
|
// initialFilter.c_str(),
|
||||||
|
// false);
|
||||||
|
// }
|
||||||
|
|
||||||
fCheckBlockIndex = true;
|
fCheckBlockIndex = true;
|
||||||
SelectParams(chainName);
|
SelectParams(chainName);
|
||||||
noui_connect();
|
noui_connect();
|
||||||
|
|
Loading…
Reference in New Issue