mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-09-11 21:20:39 +02:00
Duplicate Boost test suite names are already rejected by CMake when the suites are registered as CTest tests. Follow-up to https://github.com/bitcoin/bitcoin/pull/35451#discussion_r3403672298. Co-authored-by: maflcko <6399679+maflcko@users.noreply.github.com>
51 lines
1.3 KiB
Python
Executable File
51 lines
1.3 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
#
|
|
# Copyright (c) 2018-present The Bitcoin Core 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
|
|
"""
|
|
|
|
import re
|
|
import subprocess
|
|
import sys
|
|
|
|
|
|
def grep_boost_test_suites():
|
|
command = [
|
|
"git",
|
|
"grep",
|
|
"-E",
|
|
r"^(BOOST_FIXTURE_TEST_SUITE|BOOST_AUTO_TEST_SUITE)\(",
|
|
"--",
|
|
"src/ipc/test/**.cpp",
|
|
"src/test/**.cpp",
|
|
"src/wallet/test/**.cpp",
|
|
]
|
|
return subprocess.check_output(command, text=True)
|
|
|
|
|
|
def main():
|
|
test_suite_list = grep_boost_test_suites().splitlines()
|
|
not_matching = [
|
|
x
|
|
for x in test_suite_list
|
|
if re.search(r"/(.*?)\.cpp:(?:BOOST_FIXTURE_TEST_SUITE|BOOST_AUTO_TEST_SUITE)\(\1(_[a-z0-9]+)?[,)]", x) is None
|
|
]
|
|
if len(not_matching) > 0:
|
|
not_matching = "\n".join(not_matching)
|
|
error_msg = (
|
|
"The test suite in file src/test/foo_tests.cpp should be named\n"
|
|
'`foo_tests`, or if there are multiple test suites, `foo_tests_bar`.\n'
|
|
'Please make sure the following test suites follow that convention:\n\n'
|
|
f"{not_matching}\n"
|
|
)
|
|
print(error_msg)
|
|
sys.exit(1)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|