Skip to content

Commit 9beded5

Browse files
author
MarcoFalke
committed
Merge #12719: tests: Add note about test suite naming convention in developer-notes.md
db983be tests: Add lint-tests.sh which checks the test suite naming convention (practicalswift) 5fd864f tests: Rename test suits not following the test suite naming convention (practicalswift) 7b4a296 tests: Add note about test suite naming convention (practicalswift) Pull request description: Changes: * Add note about test suite naming convention * Fix exceptions * Add regression test Rationale: * Consistent naming of test suites makes programmatic test running of specific tests/subsets of tests easier * Explicit is better than implicit Before this commit: ``` $ contrib/devtools/lint-tests.sh The test suite in file src/test/foo_tests.cpp should be named "foo_tests". Please make sure the following test suites follow that convention: src/test/blockchain_tests.cpp:BOOST_FIXTURE_TEST_SUITE(blockchain_difficulty_tests, BasicTestingSetup) src/test/prevector_tests.cpp:BOOST_FIXTURE_TEST_SUITE(PrevectorTests, TestingSetup) src/wallet/test/coinselector_tests.cpp:BOOST_FIXTURE_TEST_SUITE(coin_selection_tests, WalletTestingSetup) src/wallet/test/crypto_tests.cpp:BOOST_FIXTURE_TEST_SUITE(wallet_crypto, BasicTestingSetup) $ ``` After this commit: ``` $ contrib/devtools/lint-tests.sh $ ``` Tree-SHA512: 7258ab9a6b9b8fc1939efadc619e2f2f02cfce8034c7f2e5dc5ecc769aa12e17f6fb8e363817feaf15c026c5b958b2574525b8d2d3f6be69658679bf8ceea9e9
2 parents fa5825d + db983be commit 9beded5

File tree

7 files changed

+27
-6
lines changed

7 files changed

+27
-6
lines changed

contrib/devtools/lint-tests.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
#
3+
# Copyright (c) 2018 The Bitcoin Core developers
4+
# Distributed under the MIT software license, see the accompanying
5+
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
6+
#
7+
# Check the test suite naming convention
8+
9+
NAMING_INCONSISTENCIES=$(git grep -E '^BOOST_FIXTURE_TEST_SUITE\(' -- \
10+
"src/test/**.cpp" "src/wallet/test/**.cpp" | \
11+
grep -vE '/(.*?)\.cpp:BOOST_FIXTURE_TEST_SUITE\(\1, .*\)$')
12+
if [[ ${NAMING_INCONSISTENCIES} != "" ]]; then
13+
echo "The test suite in file src/test/foo_tests.cpp should be named"
14+
echo "\"foo_tests\". Please make sure the following test suites follow"
15+
echo "that convention:"
16+
echo
17+
echo "${NAMING_INCONSISTENCIES}"
18+
exit 1
19+
fi

doc/developer-notes.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ code.
7171
- Constant names are all uppercase, and use `_` to separate words.
7272
- Class names, function names and method names are UpperCamelCase
7373
(PascalCase). Do not prefix class names with `C`.
74+
- Test suite naming convention: The Boost test suite in file
75+
`src/test/foo_tests.cpp` should be named `foo_tests`.
7476

7577
- **Miscellaneous**
7678
- `++i` is preferred over `i++`.

src/test/blockchain_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ void TestDifficulty(uint32_t nbits, double expected_difficulty)
5454
RejectDifficultyMismatch(difficulty, expected_difficulty);
5555
}
5656

57-
BOOST_FIXTURE_TEST_SUITE(blockchain_difficulty_tests, BasicTestingSetup)
57+
BOOST_FIXTURE_TEST_SUITE(blockchain_tests, BasicTestingSetup)
5858

5959
BOOST_AUTO_TEST_CASE(get_difficulty_for_very_low_target)
6060
{

src/test/prevector_tests.cpp

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

1414
#include <boost/test/unit_test.hpp>
1515

16-
BOOST_FIXTURE_TEST_SUITE(PrevectorTests, TestingSetup)
16+
BOOST_FIXTURE_TEST_SUITE(prevector_tests, TestingSetup)
1717

1818
template<unsigned int N, typename T>
1919
class prevector_tester {

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 wallet_crypto
70+
namespace crypto_tests
7171
{
7272
class TestCrypter;
7373
}
7474

7575
/** Encryption/decryption context with key information */
7676
class CCrypter
7777
{
78-
friend class wallet_crypto::TestCrypter; // for test access to chKey/chIV
78+
friend class 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/coinselector_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include <boost/test/unit_test.hpp>
1515
#include <random>
1616

17-
BOOST_FIXTURE_TEST_SUITE(coin_selection_tests, WalletTestingSetup)
17+
BOOST_FIXTURE_TEST_SUITE(coinselector_tests, WalletTestingSetup)
1818

1919
// how many times to run all the tests to have a chance to catch errors that only show up with particular random shuffles
2020
#define RUN_TESTS 100

src/wallet/test/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(wallet_crypto, BasicTestingSetup)
13+
BOOST_FIXTURE_TEST_SUITE(crypto_tests, BasicTestingSetup)
1414

1515
class TestCrypter
1616
{

0 commit comments

Comments
 (0)