Match unit tests on start of test name (#4634)

* For example, without this change, to run the TxQ tests, must specify
  `--unittest=TxQ1,TxQ2` on the command line. With this change, can use
  `--unittest=TxQ`, and both will be run.
* An exact match will prevent any further partial matching.
* This could have some side effects for different tests with a common
  name beginning. For example, NFToken, NFTokenBurn, NFTokenDir. This
  might be useful. If not, the shorter-named test(s) can be renamed. For
  example, NFToken to NFTokens.
* Split the NFToken, NFTokenBurn, and Offer test classes. Potentially speeds
  up parallel tests by a factor of 5.
This commit is contained in:
Ed Hennis
2023-09-14 16:19:15 -04:00
committed by GitHub
parent ce570c166d
commit 5427321260
4 changed files with 197 additions and 37 deletions

View File

@@ -27,7 +27,7 @@
namespace ripple {
namespace test {
class Offer_test : public beast::unit_test::suite
class Offer0_test : public beast::unit_test::suite
{
XRPAmount
reserve(jtx::Env& env, std::uint32_t count)
@@ -5145,25 +5145,76 @@ public:
}
void
run() override
run(std::uint32_t instance, bool last = false)
{
using namespace jtx;
FeatureBitset const all{supported_amendments()};
FeatureBitset const flowCross{featureFlowCross};
FeatureBitset const takerDryOffer{fixTakerDryOfferRemoval};
FeatureBitset const rmSmallIncreasedQOffers{fixRmSmallIncreasedQOffers};
FeatureBitset const immediateOfferKilled{featureImmediateOfferKilled};
static FeatureBitset const all{supported_amendments()};
static FeatureBitset const flowCross{featureFlowCross};
static FeatureBitset const takerDryOffer{fixTakerDryOfferRemoval};
static FeatureBitset const rmSmallIncreasedQOffers{
fixRmSmallIncreasedQOffers};
static FeatureBitset const immediateOfferKilled{
featureImmediateOfferKilled};
testAll(all - takerDryOffer - immediateOfferKilled);
testAll(all - flowCross - takerDryOffer - immediateOfferKilled);
testAll(all - flowCross - immediateOfferKilled);
testAll(all - rmSmallIncreasedQOffers - immediateOfferKilled);
testAll(all);
static std::array<FeatureBitset, 5> const feats{
all - takerDryOffer - immediateOfferKilled,
all - flowCross - takerDryOffer - immediateOfferKilled,
all - flowCross - immediateOfferKilled,
all - rmSmallIncreasedQOffers - immediateOfferKilled,
all};
if (BEAST_EXPECT(instance < feats.size()))
{
testAll(feats[instance]);
}
BEAST_EXPECT(!last || instance == feats.size() - 1);
}
void
run() override
{
run(0);
testFalseAssert();
}
};
class Offer_manual_test : public Offer_test
class Offer1_test : public Offer0_test
{
void
run() override
{
Offer0_test::run(1);
}
};
class Offer2_test : public Offer0_test
{
void
run() override
{
Offer0_test::run(2);
}
};
class Offer3_test : public Offer0_test
{
void
run() override
{
Offer0_test::run(3);
}
};
class Offer4_test : public Offer0_test
{
void
run() override
{
Offer0_test::run(4, true);
}
};
class Offer_manual_test : public Offer0_test
{
void
run() override
@@ -5184,7 +5235,11 @@ class Offer_manual_test : public Offer_test
}
};
BEAST_DEFINE_TESTSUITE_PRIO(Offer, tx, ripple, 4);
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_MANUAL_PRIO(Offer_manual, tx, ripple, 20);
} // namespace test