Skip to content

Commit d6f10b2

Browse files
committed
Merge #12895: tests: Add note about test suite name uniqueness requirement to developer notes
d1b622b tests: Add check for test suite name uniqueness in lint-tests.sh (practicalswift) dc8067b tests: Add note about uniqueness requirement for test suite names (practicalswift) 3ebfb2d tests: Avoid test suite name collision in wallet crypto_tests (MarcoFalke) Pull request description: * Add documentation: Add note about test suite name uniqueness requirement in developer notes * Add regression test: Update `lint-tests.sh` to make it check also for test suite name uniqueness Context: #12894 (`tests: Avoid test suite name collision in wallet crypto_tests`) Tree-SHA512: 3c8502db069ef3d753f534976a86a997b12bac539e808a7285193bf81c9dd8c1b06821c3dd1bdf870ab87722b02c8aa9574c62ace70c2a1b8091785cb8c9aace
2 parents 048ac83 + d1b622b commit d6f10b2

File tree

5 files changed

+23
-7
lines changed

5 files changed

+23
-7
lines changed

contrib/devtools/lint-tests.sh

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
# Distributed under the MIT software license, see the accompanying
55
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
66
#
7-
# Check the test suite naming convention
7+
# Check the test suite naming conventions
8+
9+
EXIT_CODE=0
810

911
NAMING_INCONSISTENCIES=$(git grep -E '^BOOST_FIXTURE_TEST_SUITE\(' -- \
1012
"src/test/**.cpp" "src/wallet/test/**.cpp" | \
@@ -15,5 +17,18 @@ if [[ ${NAMING_INCONSISTENCIES} != "" ]]; then
1517
echo "that convention:"
1618
echo
1719
echo "${NAMING_INCONSISTENCIES}"
18-
exit 1
20+
EXIT_CODE=1
1921
fi
22+
23+
TEST_SUITE_NAME_COLLISSIONS=$(git grep -E '^BOOST_FIXTURE_TEST_SUITE\(' -- \
24+
"src/test/**.cpp" "src/wallet/test/**.cpp" | cut -f2 -d'(' | cut -f1 -d, | \
25+
sort | uniq -d)
26+
if [[ ${TEST_SUITE_NAME_COLLISSIONS} != "" ]]; then
27+
echo "Test suite names must be unique. The following test suite names"
28+
echo "appear to be used more than once:"
29+
echo
30+
echo "${TEST_SUITE_NAME_COLLISSIONS}"
31+
EXIT_CODE=1
32+
fi
33+
34+
exit ${EXIT_CODE}

doc/developer-notes.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ code.
7272
- Class names, function names and method names are UpperCamelCase
7373
(PascalCase). Do not prefix class names with `C`.
7474
- Test suite naming convention: The Boost test suite in file
75-
`src/test/foo_tests.cpp` should be named `foo_tests`.
75+
`src/test/foo_tests.cpp` should be named `foo_tests`. Test suite names
76+
must be unique.
7677

7778
- **Miscellaneous**
7879
- `++i` is preferred over `i++`.

src/Makefile.test.include

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ BITCOIN_TESTS += \
9494
wallet/test/wallet_test_fixture.h \
9595
wallet/test/accounting_tests.cpp \
9696
wallet/test/wallet_tests.cpp \
97-
wallet/test/crypto_tests.cpp \
97+
wallet/test/wallet_crypto_tests.cpp \
9898
wallet/test/coinselector_tests.cpp
9999
endif
100100

src/wallet/crypter.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,15 @@ class CMasterKey
6767

6868
typedef std::vector<unsigned char, secure_allocator<unsigned char> > CKeyingMaterial;
6969

70-
namespace crypto_tests
70+
namespace wallet_crypto_tests
7171
{
7272
class TestCrypter;
7373
}
7474

7575
/** Encryption/decryption context with key information */
7676
class CCrypter
7777
{
78-
friend class crypto_tests::TestCrypter; // for test access to chKey/chIV
78+
friend class wallet_crypto_tests::TestCrypter; // for test access to chKey/chIV
7979
private:
8080
std::vector<unsigned char, secure_allocator<unsigned char>> vchKey;
8181
std::vector<unsigned char, secure_allocator<unsigned char>> vchIV;

src/wallet/test/crypto_tests.cpp renamed to src/wallet/test/wallet_crypto_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#include <boost/test/unit_test.hpp>
1212

13-
BOOST_FIXTURE_TEST_SUITE(crypto_tests, BasicTestingSetup)
13+
BOOST_FIXTURE_TEST_SUITE(wallet_crypto_tests, BasicTestingSetup)
1414

1515
class TestCrypter
1616
{

0 commit comments

Comments
 (0)