Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update help message about unit test-suite pattern matching #4846

Merged
merged 9 commits into from
Jan 20, 2024
13 changes: 13 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,19 @@ pip3 install pre-commit
pre-commit install
```

## Unit Tests
To execute all unit tests: (Caution: This takes ~10 minutes on M1 MacOS)

```rippled --unittest```
ximinez marked this conversation as resolved.
Show resolved Hide resolved

To run a specific set of test suites:

```
rippled --unittest TestSuiteName
```
Note: here all tests with prefix TestSuiteName will be run, so if
TestSuiteName and TestSuiteName1 both exist, then both tests will run.
ximinez marked this conversation as resolved.
Show resolved Hide resolved

## Avoid

1. Proliferation of nearly identical code.
Expand Down
10 changes: 5 additions & 5 deletions src/ripple/app/main/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,11 +429,11 @@ run(int argc, char** argv)
"including suite/case name (at start) and test log messages.")(
"unittest,u",
po::value<std::string>()->implicit_value(""),
"Perform unit tests. The optional argument specifies one or "
"more comma-separated selectors. Each selector specifies a suite name, "
"full-name (lib.module.suite), module, or library "
"(checked in that "
"order).")(
"Perform unit tests. The optional argument "
"will be matched against the beginning of every test-suite name. If "
"there is an exact match, only that test-suite is executed. "
"Otherwise, all test suites with a matching prefix will be executed"
".")(
ximinez marked this conversation as resolved.
Show resolved Hide resolved
"unittest-arg",
po::value<std::string>()->implicit_value(""),
"Supplies an argument string to unit tests. If provided, this argument "
Expand Down
22 changes: 11 additions & 11 deletions src/test/app/NFTokenBurn_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

namespace ripple {

class NFTokenBurn0_test : public beast::unit_test::suite
class NFTokenBurnBaseUtil_test : public beast::unit_test::suite
{
// Helper function that returns the owner count of an account root.
static std::uint32_t
Expand Down Expand Up @@ -815,39 +815,39 @@ class NFTokenBurn0_test : public beast::unit_test::suite
}
};

class NFTokenBurn1_test : public NFTokenBurn0_test
class NFTokenBurnWOfixFungTokens_test : public NFTokenBurnBaseUtil_test
{
public:
void
run() override
{
NFTokenBurn0_test::run(1);
NFTokenBurnBaseUtil_test::run(1);
}
};

class NFTokenBurn2_test : public NFTokenBurn0_test
class NFTokenBurnWOFixTokenRemint_test : public NFTokenBurnBaseUtil_test
{
public:
void
run() override
{
NFTokenBurn0_test::run(2);
NFTokenBurnBaseUtil_test::run(2);
}
};

class NFTokenBurn3_test : public NFTokenBurn0_test
class NFTokenBurnAllFeatures_test : public NFTokenBurnBaseUtil_test
{
public:
void
run() override
{
NFTokenBurn0_test::run(3, true);
NFTokenBurnBaseUtil_test::run(3, true);
}
};

BEAST_DEFINE_TESTSUITE_PRIO(NFTokenBurn0, tx, ripple, 3);
BEAST_DEFINE_TESTSUITE_PRIO(NFTokenBurn1, tx, ripple, 3);
BEAST_DEFINE_TESTSUITE_PRIO(NFTokenBurn2, tx, ripple, 3);
BEAST_DEFINE_TESTSUITE_PRIO(NFTokenBurn3, tx, ripple, 3);
BEAST_DEFINE_TESTSUITE_PRIO(NFTokenBurnBaseUtil, tx, ripple, 3);
BEAST_DEFINE_TESTSUITE_PRIO(NFTokenBurnWOfixFungTokens, tx, ripple, 3);
BEAST_DEFINE_TESTSUITE_PRIO(NFTokenBurnWOFixTokenRemint, tx, ripple, 3);
BEAST_DEFINE_TESTSUITE_PRIO(NFTokenBurnAllFeatures, tx, ripple, 3);

} // namespace ripple
28 changes: 14 additions & 14 deletions src/test/app/NFToken_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

namespace ripple {

class NFToken0_test : public beast::unit_test::suite
class NFTokenBaseUtil_test : public beast::unit_test::suite
{
FeatureBitset const disallowIncoming{featureDisallowIncoming};

Expand Down Expand Up @@ -6863,46 +6863,46 @@ class NFToken0_test : public beast::unit_test::suite
}
};

class NFToken1_test : public NFToken0_test
class NFTokenDisallowIncoming_test : public NFTokenBaseUtil_test
{
void
run() override
{
NFToken0_test::run(1);
NFTokenBaseUtil_test::run(1);
}
};

class NFToken2_test : public NFToken0_test
class NFTokenWOfixV1_test : public NFTokenBaseUtil_test
{
void
run() override
{
NFToken0_test::run(2);
NFTokenBaseUtil_test::run(2);
}
};

class NFToken3_test : public NFToken0_test
class NFTokenWOTokenRemint_test : public NFTokenBaseUtil_test
{
void
run() override
{
NFToken0_test::run(3);
NFTokenBaseUtil_test::run(3);
}
};

class NFToken4_test : public NFToken0_test
class NFTokenAllFeatures_test : public NFTokenBaseUtil_test
{
void
run() override
{
NFToken0_test::run(4, true);
NFTokenBaseUtil_test::run(4, true);
}
};

BEAST_DEFINE_TESTSUITE_PRIO(NFToken0, tx, ripple, 2);
BEAST_DEFINE_TESTSUITE_PRIO(NFToken1, tx, ripple, 2);
BEAST_DEFINE_TESTSUITE_PRIO(NFToken2, tx, ripple, 2);
BEAST_DEFINE_TESTSUITE_PRIO(NFToken3, tx, ripple, 2);
BEAST_DEFINE_TESTSUITE_PRIO(NFToken4, tx, ripple, 2);
BEAST_DEFINE_TESTSUITE_PRIO(NFTokenBaseUtil, tx, ripple, 2);
BEAST_DEFINE_TESTSUITE_PRIO(NFTokenDisallowIncoming, tx, ripple, 2);
BEAST_DEFINE_TESTSUITE_PRIO(NFTokenWOfixV1, tx, ripple, 2);
BEAST_DEFINE_TESTSUITE_PRIO(NFTokenWOTokenRemint, tx, ripple, 2);
BEAST_DEFINE_TESTSUITE_PRIO(NFTokenAllFeatures, tx, ripple, 2);

} // namespace ripple
36 changes: 18 additions & 18 deletions src/test/app/Offer_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
namespace ripple {
namespace test {

class Offer0_test : public beast::unit_test::suite
class OfferBaseUtil_test : public beast::unit_test::suite
{
XRPAmount
reserve(jtx::Env& env, std::uint32_t count)
Expand Down Expand Up @@ -5371,52 +5371,52 @@ class Offer0_test : public beast::unit_test::suite
}
};

class Offer1_test : public Offer0_test
class OfferWOFlowCross_test : public OfferBaseUtil_test
{
void
run() override
{
Offer0_test::run(1);
OfferBaseUtil_test::run(1);
}
};

class Offer2_test : public Offer0_test
class OfferWTakerDryOffer_test : public OfferBaseUtil_test
{
void
run() override
{
Offer0_test::run(2);
OfferBaseUtil_test::run(2);
}
};

class Offer3_test : public Offer0_test
class OfferWOSmallQOffers_test : public OfferBaseUtil_test
{
void
run() override
{
Offer0_test::run(3);
OfferBaseUtil_test::run(3);
}
};

class Offer4_test : public Offer0_test
class OfferWOFillOrKill_test : public OfferBaseUtil_test
{
void
run() override
{
Offer0_test::run(4);
OfferBaseUtil_test::run(4);
}
};

class Offer5_test : public Offer0_test
class OfferAllFeatures_test : public OfferBaseUtil_test
{
void
run() override
{
Offer0_test::run(5, true);
OfferBaseUtil_test::run(5, true);
}
};

class Offer_manual_test : public Offer0_test
class Offer_manual_test : public OfferBaseUtil_test
{
void
run() override
Expand All @@ -5439,12 +5439,12 @@ class Offer_manual_test : public Offer0_test
}
};

BEAST_DEFINE_TESTSUITE_PRIO(Offer0, tx, ripple, 4);
BEAST_DEFINE_TESTSUITE_PRIO(Offer1, tx, ripple, 4);
BEAST_DEFINE_TESTSUITE_PRIO(Offer2, tx, ripple, 4);
BEAST_DEFINE_TESTSUITE_PRIO(Offer3, tx, ripple, 4);
BEAST_DEFINE_TESTSUITE_PRIO(Offer4, tx, ripple, 4);
BEAST_DEFINE_TESTSUITE_PRIO(Offer5, tx, ripple, 4);
BEAST_DEFINE_TESTSUITE_PRIO(OfferBaseUtil, tx, ripple, 4);
BEAST_DEFINE_TESTSUITE_PRIO(OfferWOFlowCross, tx, ripple, 4);
BEAST_DEFINE_TESTSUITE_PRIO(OfferWTakerDryOffer, tx, ripple, 4);
BEAST_DEFINE_TESTSUITE_PRIO(OfferWOSmallQOffers, tx, ripple, 4);
BEAST_DEFINE_TESTSUITE_PRIO(OfferWOFillOrKill, tx, ripple, 4);
BEAST_DEFINE_TESTSUITE_PRIO(OfferAllFeatures, tx, ripple, 4);
BEAST_DEFINE_TESTSUITE_MANUAL_PRIO(Offer_manual, tx, ripple, 20);

} // namespace test
Expand Down
12 changes: 6 additions & 6 deletions src/test/app/TxQ_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace ripple {

namespace test {

class TxQ1_test : public beast::unit_test::suite
class TxQPosNegFlows_test : public beast::unit_test::suite
{
void
checkMetrics(
Expand Down Expand Up @@ -4949,7 +4949,7 @@ class TxQ1_test : public beast::unit_test::suite
}

void
run2()
runMetaInfo()
{
testAcctInQueueButEmpty();
testRPC();
Expand All @@ -4970,17 +4970,17 @@ class TxQ1_test : public beast::unit_test::suite
}
};

class TxQ2_test : public TxQ1_test
class TxQMetaInfo_test : public TxQPosNegFlows_test
{
void
run() override
{
run2();
runMetaInfo();
}
};

BEAST_DEFINE_TESTSUITE_PRIO(TxQ1, app, ripple, 1);
BEAST_DEFINE_TESTSUITE_PRIO(TxQ2, app, ripple, 1);
BEAST_DEFINE_TESTSUITE_PRIO(TxQPosNegFlows, app, ripple, 1);
BEAST_DEFINE_TESTSUITE_PRIO(TxQMetaInfo, app, ripple, 1);

} // namespace test
} // namespace ripple