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 {
class NFToken_test : public beast::unit_test::suite
class NFToken0_test : public beast::unit_test::suite
{
FeatureBitset const disallowIncoming{featureDisallowIncoming};
@@ -6835,23 +6835,74 @@ class NFToken_test : public beast::unit_test::suite
public:
void
run() override
run(std::uint32_t instance, bool last = false)
{
using namespace test::jtx;
FeatureBitset const all{supported_amendments()};
FeatureBitset const fixNFTDir{fixNFTokenDirV1};
static FeatureBitset const all{supported_amendments()};
static FeatureBitset const fixNFTDir{fixNFTokenDirV1};
testWithFeats(
all - fixNFTDir - fixNonFungibleTokensV1_2 - fixNFTokenRemint);
testWithFeats(
static std::array<FeatureBitset, 5> const feats{
all - fixNFTDir - fixNonFungibleTokensV1_2 - fixNFTokenRemint,
all - disallowIncoming - fixNonFungibleTokensV1_2 -
fixNFTokenRemint);
testWithFeats(all - fixNonFungibleTokensV1_2 - fixNFTokenRemint);
testWithFeats(all - fixNFTokenRemint);
testWithFeats(all);
fixNFTokenRemint,
all - fixNonFungibleTokensV1_2 - fixNFTokenRemint,
all - fixNFTokenRemint,
all};
if (BEAST_EXPECT(instance < feats.size()))
{
testWithFeats(feats[instance]);
}
BEAST_EXPECT(!last || instance == feats.size() - 1);
}
void
run() override
{
run(0);
}
};
BEAST_DEFINE_TESTSUITE_PRIO(NFToken, tx, ripple, 2);
class NFToken1_test : public NFToken0_test
{
void
run() override
{
NFToken0_test::run(1);
}
};
class NFToken2_test : public NFToken0_test
{
void
run() override
{
NFToken0_test::run(2);
}
};
class NFToken3_test : public NFToken0_test
{
void
run() override
{
NFToken0_test::run(3);
}
};
class NFToken4_test : public NFToken0_test
{
void
run() override
{
NFToken0_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);
} // namespace ripple