mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
refactor: Clean up test logging to make it easier to search (#5396)
This PR replaces the word `failed` with `failure` in any test names and renames some test files to fix MSVC warnings, so that it is easier to search through the test output to find tests that failed.
This commit is contained in:
@@ -20,6 +20,7 @@
|
|||||||
#include <test/jtx.h>
|
#include <test/jtx.h>
|
||||||
#include <test/jtx/AMM.h>
|
#include <test/jtx/AMM.h>
|
||||||
#include <test/jtx/AMMTest.h>
|
#include <test/jtx/AMMTest.h>
|
||||||
|
#include <test/jtx/CaptureLogs.h>
|
||||||
#include <test/jtx/amount.h>
|
#include <test/jtx/amount.h>
|
||||||
#include <test/jtx/sendmax.h>
|
#include <test/jtx/sendmax.h>
|
||||||
|
|
||||||
@@ -6079,6 +6080,8 @@ private:
|
|||||||
testcase("Fix changeSpotPriceQuality");
|
testcase("Fix changeSpotPriceQuality");
|
||||||
using namespace jtx;
|
using namespace jtx;
|
||||||
|
|
||||||
|
std::string logs;
|
||||||
|
|
||||||
enum class Status {
|
enum class Status {
|
||||||
SucceedShouldSucceedResize, // Succeed in pre-fix because
|
SucceedShouldSucceedResize, // Succeed in pre-fix because
|
||||||
// error allowance, succeed post-fix
|
// error allowance, succeed post-fix
|
||||||
@@ -6161,7 +6164,7 @@ private:
|
|||||||
boost::smatch match;
|
boost::smatch match;
|
||||||
// tests that succeed should have the same amounts pre-fix and post-fix
|
// tests that succeed should have the same amounts pre-fix and post-fix
|
||||||
std::vector<std::pair<STAmount, STAmount>> successAmounts;
|
std::vector<std::pair<STAmount, STAmount>> successAmounts;
|
||||||
Env env(*this, features);
|
Env env(*this, features, std::make_unique<CaptureLogs>(&logs));
|
||||||
auto rules = env.current()->rules();
|
auto rules = env.current()->rules();
|
||||||
CurrentTransactionRulesGuard rg(rules);
|
CurrentTransactionRulesGuard rg(rules);
|
||||||
for (auto const& t : tests)
|
for (auto const& t : tests)
|
||||||
@@ -6355,6 +6358,8 @@ private:
|
|||||||
using namespace std::chrono;
|
using namespace std::chrono;
|
||||||
FeatureBitset const all{features};
|
FeatureBitset const all{features};
|
||||||
|
|
||||||
|
std::string logs;
|
||||||
|
|
||||||
Account const gatehub{"gatehub"};
|
Account const gatehub{"gatehub"};
|
||||||
Account const bitstamp{"bitstamp"};
|
Account const bitstamp{"bitstamp"};
|
||||||
Account const trader{"trader"};
|
Account const trader{"trader"};
|
||||||
@@ -6583,7 +6588,7 @@ private:
|
|||||||
for (auto const& features :
|
for (auto const& features :
|
||||||
{all - fixAMMOverflowOffer, all | fixAMMOverflowOffer})
|
{all - fixAMMOverflowOffer, all | fixAMMOverflowOffer})
|
||||||
{
|
{
|
||||||
Env env(*this, features);
|
Env env(*this, features, std::make_unique<CaptureLogs>(&logs));
|
||||||
|
|
||||||
env.fund(XRP(5'000), gatehub, bitstamp, trader);
|
env.fund(XRP(5'000), gatehub, bitstamp, trader);
|
||||||
env.close();
|
env.close();
|
||||||
|
|||||||
@@ -828,7 +828,7 @@ struct DepositPreauth_test : public beast::unit_test::suite
|
|||||||
Account const john{"john"};
|
Account const john{"john"};
|
||||||
|
|
||||||
{
|
{
|
||||||
testcase("Payment failed with disabled credentials rule.");
|
testcase("Payment failure with disabled credentials rule.");
|
||||||
|
|
||||||
Env env(*this, supported_amendments() - featureCredentials);
|
Env env(*this, supported_amendments() - featureCredentials);
|
||||||
|
|
||||||
@@ -930,7 +930,7 @@ struct DepositPreauth_test : public beast::unit_test::suite
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
testcase("Payment failed with invalid credentials.");
|
testcase("Payment failure with invalid credentials.");
|
||||||
|
|
||||||
Env env(*this);
|
Env env(*this);
|
||||||
|
|
||||||
@@ -1206,7 +1206,7 @@ struct DepositPreauth_test : public beast::unit_test::suite
|
|||||||
Account const zelda{"zelda"};
|
Account const zelda{"zelda"};
|
||||||
|
|
||||||
{
|
{
|
||||||
testcase("Payment failed with expired credentials.");
|
testcase("Payment failure with expired credentials.");
|
||||||
|
|
||||||
Env env(*this);
|
Env env(*this);
|
||||||
|
|
||||||
@@ -1353,7 +1353,7 @@ struct DepositPreauth_test : public beast::unit_test::suite
|
|||||||
{
|
{
|
||||||
using namespace std::chrono;
|
using namespace std::chrono;
|
||||||
|
|
||||||
testcase("Escrow failed with expired credentials.");
|
testcase("Escrow failure with expired credentials.");
|
||||||
|
|
||||||
Env env(*this);
|
Env env(*this);
|
||||||
|
|
||||||
|
|||||||
@@ -210,8 +210,10 @@ public:
|
|||||||
* @param args collection of features
|
* @param args collection of features
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
Env(beast::unit_test::suite& suite_, FeatureBitset features)
|
Env(beast::unit_test::suite& suite_,
|
||||||
: Env(suite_, envconfig(), features)
|
FeatureBitset features,
|
||||||
|
std::unique_ptr<Logs> logs = nullptr)
|
||||||
|
: Env(suite_, envconfig(), features, std::move(logs))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ public:
|
|||||||
void
|
void
|
||||||
testValid()
|
testValid()
|
||||||
{
|
{
|
||||||
|
testcase("Valid");
|
||||||
using namespace jtx;
|
using namespace jtx;
|
||||||
Account const alice{"alice"};
|
Account const alice{"alice"};
|
||||||
Account const becky{"becky"};
|
Account const becky{"becky"};
|
||||||
@@ -162,6 +163,7 @@ public:
|
|||||||
void
|
void
|
||||||
testErrors()
|
testErrors()
|
||||||
{
|
{
|
||||||
|
testcase("Errors");
|
||||||
using namespace jtx;
|
using namespace jtx;
|
||||||
Account const alice{"alice"};
|
Account const alice{"alice"};
|
||||||
Account const becky{"becky"};
|
Account const becky{"becky"};
|
||||||
@@ -333,6 +335,8 @@ public:
|
|||||||
void
|
void
|
||||||
testCredentials()
|
testCredentials()
|
||||||
{
|
{
|
||||||
|
testcase("Credentials");
|
||||||
|
|
||||||
using namespace jtx;
|
using namespace jtx;
|
||||||
|
|
||||||
const char credType[] = "abcde";
|
const char credType[] = "abcde";
|
||||||
@@ -363,7 +367,7 @@ public:
|
|||||||
|
|
||||||
{
|
{
|
||||||
testcase(
|
testcase(
|
||||||
"deposit_authorized with credentials failed: empty array.");
|
"deposit_authorized with credentials failure: empty array.");
|
||||||
|
|
||||||
auto args = depositAuthArgs(alice, becky, "validated");
|
auto args = depositAuthArgs(alice, becky, "validated");
|
||||||
args[jss::credentials] = Json::arrayValue;
|
args[jss::credentials] = Json::arrayValue;
|
||||||
@@ -376,7 +380,7 @@ public:
|
|||||||
|
|
||||||
{
|
{
|
||||||
testcase(
|
testcase(
|
||||||
"deposit_authorized with credentials failed: not a string "
|
"deposit_authorized with credentials failure: not a string "
|
||||||
"credentials");
|
"credentials");
|
||||||
|
|
||||||
auto args = depositAuthArgs(alice, becky, "validated");
|
auto args = depositAuthArgs(alice, becky, "validated");
|
||||||
@@ -392,7 +396,7 @@ public:
|
|||||||
|
|
||||||
{
|
{
|
||||||
testcase(
|
testcase(
|
||||||
"deposit_authorized with credentials failed: not a hex string "
|
"deposit_authorized with credentials failure: not a hex string "
|
||||||
"credentials");
|
"credentials");
|
||||||
|
|
||||||
auto args = depositAuthArgs(alice, becky, "validated");
|
auto args = depositAuthArgs(alice, becky, "validated");
|
||||||
@@ -412,7 +416,7 @@ public:
|
|||||||
|
|
||||||
{
|
{
|
||||||
testcase(
|
testcase(
|
||||||
"deposit_authorized with credentials failed: not a credential "
|
"deposit_authorized with credentials failure: not a credential "
|
||||||
"index");
|
"index");
|
||||||
|
|
||||||
auto args = depositAuthArgs(
|
auto args = depositAuthArgs(
|
||||||
|
|||||||
@@ -577,6 +577,16 @@ multi_runner_child::on_suite_begin(beast::unit_test::suite_info const& info)
|
|||||||
void
|
void
|
||||||
multi_runner_child::on_suite_end()
|
multi_runner_child::on_suite_end()
|
||||||
{
|
{
|
||||||
|
if (print_log_ || suite_results_.failed > 0)
|
||||||
|
{
|
||||||
|
std::stringstream s;
|
||||||
|
if (num_jobs_ > 1)
|
||||||
|
s << job_index_ << "> ";
|
||||||
|
s << (suite_results_.failed > 0 ? "failed: " : "")
|
||||||
|
<< suite_results_.name << " had " << suite_results_.failed
|
||||||
|
<< " failures." << std::endl;
|
||||||
|
message_queue_send(MessageType::log, s.str());
|
||||||
|
}
|
||||||
results_.add(suite_results_);
|
results_.add(suite_results_);
|
||||||
message_queue_send(MessageType::test_end, suite_results_.name);
|
message_queue_send(MessageType::test_end, suite_results_.name);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user