From 0ac91f791c2f9ff18ecd6a0390a78f5175cc3aa2 Mon Sep 17 00:00:00 2001 From: Jeremy Stanley Date: Sat, 3 Oct 2020 19:04:58 +0000 Subject: [PATCH] Run different selftests when debug mode is engaged Add two skiplist tuples to the selftest framework, one for tests to remove when debug mode is on, another for tests to remove when debug mode is off. This is not used yet, so the tuples are initially empty. Also enable debug mode in the daemon config fixture so that debug functionality can be tested in the normal selftest run. The default example config (tested with tox -e selftest_config) covers the debug disabled case. --- mudpy/tests/fixtures/test_daemon.yaml | 2 +- mudpy/tests/selftest.py | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/mudpy/tests/fixtures/test_daemon.yaml b/mudpy/tests/fixtures/test_daemon.yaml index 318967a..eb2edcd 100644 --- a/mudpy/tests/fixtures/test_daemon.yaml +++ b/mudpy/tests/fixtures/test_daemon.yaml @@ -52,7 +52,7 @@ _lock: true # Debugging commands are dangerous, and may result in granting # administrative users access to the system account under which the # service runs. Be very sure you trust your admins before enabling! -# .mudpy.limit.debug: true +.mudpy.limit.debug: true .mudpy.limit.password_tries: 3 .mudpy.log.file: var/mudpy.log diff --git a/mudpy/tests/selftest.py b/mudpy/tests/selftest.py index d5b8ac4..0bd2dd9 100644 --- a/mudpy/tests/selftest.py +++ b/mudpy/tests/selftest.py @@ -11,6 +11,8 @@ import sys import telnetlib import time +import yaml + # TODO(fungi) Clean this up once Python 3.5 is no longer supported if sys.version < "3.6": import collections @@ -432,6 +434,12 @@ dialogue = odict(( (final_cleanup, "delete remaining accounts"), )) +debug_tests = ( +) + +nondebug_tests = ( +) + def start_service(config): # Clean up any previously run daemon which didn't terminate @@ -526,6 +534,13 @@ def option_callback(telnet_socket, command, option): telnet_socket.send(telnetlib.IAC + telnetlib.DONT + option) +def check_debug(): + if len(sys.argv) > 1: + config = yaml.safe_load(open(sys.argv[1])) + return config.get(".mudpy.limit.debug", False) + return False + + def main(): captures = ["", "", ""] lusers = [telnetlib.Telnet(), telnetlib.Telnet(), telnetlib.Telnet()] @@ -542,6 +557,12 @@ def main(): luser.open("::1", 4000) luser.set_option_negotiation_callback(option_callback) selected_dialogue = odict(dialogue) + if check_debug(): + for test in nondebug_tests: + del selected_dialogue[test] + else: + for test in debug_tests: + del selected_dialogue[test] for test, description in selected_dialogue.items(): tlog("\nTesting %s..." % description) test_start = time.time() -- 2.11.0