Skip to content

Commit 73e754b

Browse files
committed
Merge bitcoin/bitcoin#33001: test: Do not pass tests on unhandled exceptions
faa3e68 test: Log KeyboardInterrupt as exception (MarcoFalke) fa30b34 test: Do not pass tests on unhandled exceptions (MarcoFalke) Pull request description: Currently the functional tests are problematic, because they pass, even if they encounter an unhanded exception. Fix this by handling all exceptions: Catch `BaseException` as fallback and mark it as failure. Can be tested via: ```diff diff --git a/test/functional/wallet_disable.py b/test/functional/wallet_disable.py index da6e5d4..ecc41fb041 100755 --- a/test/functional/wallet_disable.py +++ b/test/functional/wallet_disable.py @@ -19,6 +19,7 @@ class DisableWalletTest (BitcoinTestFramework): self.wallet_names = [] def run_test (self): + import sys;sys.exit("fatal error") # Make sure wallet is really disabled assert_raises_rpc_error(-32601, 'Method not found', self.nodes[0].getwalletinfo) x = self.nodes[0].validateaddress('3J98t1WpEZ73CNmQviecrnyiWrnqRhWNLy') ``` Previously, the test would pass. With this patch, it would fail. ACKs for top commit: enirox001: Looks good to me—ACK faa3e68 stickies-v: re-ACK faa3e68 pablomartin4btc: tACK faa3e68 Tree-SHA512: 11ecd5201982e2c776e48d98834b17c15a415306a95524bc702daeba20a316aac797748e9592be8db575597804f149ee7ef104416037cc9e5891758625810e2d
2 parents cfb859e + faa3e68 commit 73e754b

File tree

1 file changed

+3
-15
lines changed

1 file changed

+3
-15
lines changed

test/functional/test_framework/test_framework.py

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -194,26 +194,14 @@ def main(self):
194194
else:
195195
self.run_test()
196196

197-
except JSONRPCException:
198-
self.log.exception("JSONRPC error")
199-
self.success = TestStatus.FAILED
200197
except SkipTest as e:
201198
self.log.warning("Test Skipped: %s" % e.message)
202199
self.success = TestStatus.SKIPPED
203-
except AssertionError:
204-
self.log.exception("Assertion failed")
205-
self.success = TestStatus.FAILED
206-
except KeyError:
207-
self.log.exception("Key error")
208-
self.success = TestStatus.FAILED
209200
except subprocess.CalledProcessError as e:
210-
self.log.exception("Called Process failed with '{}'".format(e.output))
211-
self.success = TestStatus.FAILED
212-
except Exception:
213-
self.log.exception("Unexpected exception caught during testing")
201+
self.log.exception(f"Called Process failed with stdout='{e.stdout}'; stderr='{e.stderr}';")
214202
self.success = TestStatus.FAILED
215-
except KeyboardInterrupt:
216-
self.log.warning("Exiting after keyboard interrupt")
203+
except BaseException:
204+
self.log.exception("Unexpected exception")
217205
self.success = TestStatus.FAILED
218206
finally:
219207
exit_code = self.shutdown()

0 commit comments

Comments
 (0)