Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13115321
D2532.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Subscribers
None
D2532.diff
View Options
diff --git a/doc/developer-notes.md b/doc/developer-notes.md
--- a/doc/developer-notes.md
+++ b/doc/developer-notes.md
@@ -497,6 +497,12 @@
should not interact with the user. That's where View classes come in. The converse also
holds: try to not directly access core data structures from Views.
+Unit Tests
+-----------
+ - Test suite naming convention: The Boost test suite in file
+ `src/test/foo_tests.cpp` should be named `foo_tests`. Test suite names must
+ be unique.
+
Subtrees
----------
diff --git a/test/lint/lint-tests.sh b/test/lint/lint-tests.sh
new file mode 100755
--- /dev/null
+++ b/test/lint/lint-tests.sh
@@ -0,0 +1,41 @@
+#!/usr/bin/env bash
+#
+# Copyright (c) 2018 The Bitcoin Core developers
+# Copyright (c) 2019 The Bitcoin developers
+# Distributed under the MIT software license, see the accompanying
+# file COPYING or http://www.opensource.org/licenses/mit-license.php.
+#
+# Check the test suite naming conventions
+
+EXIT_CODE=0
+
+TOPDIR=${TOPDIR:-$(git rev-parse --show-toplevel)}
+
+NAMING_INCONSISTENCIES=$(git grep -E '^BOOST_FIXTURE_TEST_SUITE\(' -- \
+ "${TOPDIR}/src/test/**.cpp" \
+ "${TOPDIR}/src/rpc/test/**.cpp" \
+ "${TOPDIR}/src/wallet/test/**.cpp" | \
+ grep -vE '/(.*?)\.cpp:BOOST_FIXTURE_TEST_SUITE\(\1, .*\)$')
+if [[ ${NAMING_INCONSISTENCIES} != "" ]]; then
+ echo "The test suite in file src/test/foo_tests.cpp should be named"
+ echo "\"foo_tests\". Please make sure the following test suites follow"
+ echo "that convention:"
+ echo
+ echo "${NAMING_INCONSISTENCIES}"
+ EXIT_CODE=1
+fi
+
+TEST_SUITE_NAME_COLLISIONS=$(git grep -E '^BOOST_FIXTURE_TEST_SUITE\(' -- \
+ "${TOPDIR}/src/test/**.cpp" \
+ "${TOPDIR}/src/rpc/test/**.cpp" \
+ "${TOPDIR}/src/wallet/test/**.cpp" | cut -f2 -d'(' | cut -f1 -d, | \
+ sort | uniq -d)
+if [[ ${TEST_SUITE_NAME_COLLISIONS} != "" ]]; then
+ echo "Test suite names must be unique. The following test suite names"
+ echo "appear to be used more than once:"
+ echo
+ echo "${TEST_SUITE_NAME_COLLISIONS}"
+ EXIT_CODE=1
+fi
+
+exit ${EXIT_CODE}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Mar 1, 10:49 (12 h, 12 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5184659
Default Alt Text
D2532.diff (2 KB)
Attached To
D2532: Add a linter to enfore unit tests file name/boost name match and unicity
Event Timeline
Log In to Comment