From 097020495fe84c98f4b80489e88c1b1dc6faa49f Mon Sep 17 00:00:00 2001 From: Jeremy Stanley Date: Sun, 15 Aug 2021 15:16:07 +0000 Subject: [PATCH] Fail selftest if anything is written to stderr The new ResourceWarning exceptions in Python 3.8 are ignored since they're raised during garbage collection, which makes them easy to miss even with PYTHONWARNINGS=error in our testing. Luckily, their tracebacks are written to stderr, and we normally expect nothing will be written to stderr on successful runs of the selftest script. As a simple solution to avoid similar situations in the future, cause the selftest run to fail if anything at all gets written to the service's stderr. --- mudpy/tests/selftest.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mudpy/tests/selftest.py b/mudpy/tests/selftest.py index c0bfc3c..f8caf35 100644 --- a/mudpy/tests/selftest.py +++ b/mudpy/tests/selftest.py @@ -519,6 +519,13 @@ def stop_service(service): with open("capture_stderr.log", "w") as serviceerr: serviceerr.write(stderr.decode("utf-8")) + # Error if anything was written on stderr as this may indicate ignored + # exceptions (e.g. ResourceWarning during garbage collection) + if stderr: + tlog("\nERROR: something was written to stderr, see " + "capture_stderr.log for details.") + success = False + return success -- 2.11.0