Skip to content

Commit 3a29ff5

Browse files
committed
Merge bitcoin/bitcoin#30463: qa: Functional test improvements
a8e3af1 qa: Do not assume running `feature_asmap.py` from source directory (Hennadii Stepanov) 9bf7ca6 qa: Consider `cache` and `config.ini` relative to invocation directory (Hennadii Stepanov) a047344 scripted-diff: Add `__file__` argument to `BitcoinTestFramework.init()` (Hennadii Stepanov) Pull request description: This PR includes changes split from bitcoin/bitcoin#30454. They improve the functional test framework, allowing users to [run individual functional tests](hebasto/bitcoin#146) from the build directory in the new CMake-based build system. This functionality is not available for out-of-source builds using the current Autotools-based build system, which always requires write permissions for the source directory. Nevertheless, this PR can be tested as suggested in bitcoin/bitcoin#30463 (comment): 1. Make an out-of-source build: ``` $ ./autogen.sh $ mkdir ../build && cd ../build $ ../bitcoin/configure $ make ``` 2. Create a symlink in the build directory to a functional test: ``` $ ln --symbolic ../../../bitcoin/test/functional/wallet_disable.py ./test/functional/ ``` 3. Run this symlink: ``` $ ./test/functional/wallet_disable.py ``` The last command fails on the master branch: ``` Traceback (most recent call last): File "/home/hebasto/git/build/./test/functional/wallet_disable.py", line 31, in <module> DisableWalletTest().main() ^^^^^^^^^^^^^^^^^^^ File "/home/hebasto/git/bitcoin/test/functional/test_framework/test_framework.py", line 106, in __init__ self.parse_args() File "/home/hebasto/git/bitcoin/test/functional/test_framework/test_framework.py", line 210, in parse_args config.read_file(open(self.options.configfile)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FileNotFoundError: [Errno 2] No such file or directory: '/home/hebasto/git/bitcoin/test/config.ini' ``` and succeeds with this PR. ACKs for top commit: maflcko: tested ACK a8e3af1 🎨 glozow: ACK a8e3af1, tested with the steps in op stickies-v: ACK a8e3af1 Tree-SHA512: 899e4efc09edec13ea3f5b47825d03173fb21d3569c360deda7fa6a56b99b4d24e09ad4f0883bad1ee926b1c706e47ba07c6a6160c63c07c82b3cf4ae5816e91
2 parents a1b8a91 + a8e3af1 commit 3a29ff5

File tree

247 files changed

+254
-253
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

247 files changed

+254
-253
lines changed

test/functional/create_cache.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ def run_test(self):
2424
pass
2525

2626
if __name__ == '__main__':
27-
CreateCache().main()
27+
CreateCache(__file__).main()

test/functional/example_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,4 +225,4 @@ def run_test(self):
225225

226226

227227
if __name__ == '__main__':
228-
ExampleTest().main()
228+
ExampleTest(__file__).main()

test/functional/feature_abortnode.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@ def run_test(self):
4242

4343

4444
if __name__ == '__main__':
45-
AbortNodeTest().main()
45+
AbortNodeTest(__file__).main()

test/functional/feature_addrman.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,4 +160,4 @@ def run_test(self):
160160

161161

162162
if __name__ == "__main__":
163-
AddrmanTest().main()
163+
AddrmanTest(__file__).main()

test/functional/feature_anchors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,4 +141,4 @@ def run_test(self):
141141

142142

143143
if __name__ == "__main__":
144-
AnchorsTest().main()
144+
AnchorsTest(__file__).main()

test/functional/feature_asmap.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
from test_framework.util import assert_equal
3131

3232
DEFAULT_ASMAP_FILENAME = 'ip_asn.map' # defined in src/init.cpp
33-
ASMAP = '../../src/test/data/asmap.raw' # path to unit test skeleton asmap
33+
ASMAP = 'src/test/data/asmap.raw' # path to unit test skeleton asmap
3434
VERSION = 'fec61fa21a9f46f3b17bdcd660d7f4cd90b966aad3aec593c99b35f0aca15853'
3535

3636
def expected_messages(filename):
@@ -133,7 +133,8 @@ def run_test(self):
133133
self.node = self.nodes[0]
134134
self.datadir = self.node.chain_path
135135
self.default_asmap = os.path.join(self.datadir, DEFAULT_ASMAP_FILENAME)
136-
self.asmap_raw = os.path.join(os.path.dirname(os.path.realpath(__file__)), ASMAP)
136+
base_dir = self.config["environment"]["SRCDIR"]
137+
self.asmap_raw = os.path.join(base_dir, ASMAP)
137138

138139
self.test_without_asmap_arg()
139140
self.test_asmap_with_absolute_path()
@@ -146,4 +147,4 @@ def run_test(self):
146147

147148

148149
if __name__ == '__main__':
149-
AsmapTest().main()
150+
AsmapTest(__file__).main()

test/functional/feature_assumeutxo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,4 +581,4 @@ class Block:
581581
chain_tx: int
582582

583583
if __name__ == '__main__':
584-
AssumeutxoTest().main()
584+
AssumeutxoTest(__file__).main()

test/functional/feature_assumevalid.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,4 +172,4 @@ def run_test(self):
172172

173173

174174
if __name__ == '__main__':
175-
AssumeValidTest().main()
175+
AssumeValidTest(__file__).main()

test/functional/feature_bind_extra.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,4 @@ def run_test(self):
8888
assert_equal(binds, set(expected_services))
8989

9090
if __name__ == '__main__':
91-
BindExtraTest().main()
91+
BindExtraTest(__file__).main()

test/functional/feature_bind_port_discover.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,4 @@ def run_test(self):
7575
assert found_addr1
7676

7777
if __name__ == '__main__':
78-
BindPortDiscoverTest().main()
78+
BindPortDiscoverTest(__file__).main()

0 commit comments

Comments
 (0)