From f135ec7ae3d7ca347d7489eb28d30b5db98f49de Mon Sep 17 00:00:00 2001 From: Scott Gasch Date: Thu, 3 Feb 2022 14:41:29 -0800 Subject: [PATCH] Add a "unittest" that runs stuff like reminder and unscramble etc... to just make sure they don't crash. --- tests/run_some_dependencies_test.py | 39 +++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100755 tests/run_some_dependencies_test.py diff --git a/tests/run_some_dependencies_test.py b/tests/run_some_dependencies_test.py new file mode 100755 index 0000000..5a567af --- /dev/null +++ b/tests/run_some_dependencies_test.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python3 + +"""This is a "test" that just runs a few system utilities that have +dependencies on this library in "do nothing" mode and makes sure they +exit cleanly. + +""" + +import logging +import unittest +from typing import Optional + +import bootstrap +import exec_utils +import unittest_utils + +logger = logging.getLogger(__name__) + + +class RunSomeDependenciesTest(unittest.TestCase): + def make_sure_random_utilities_still_seem_to_work(self): + commands = [ + "/home/scott/cron/manage_lights.py -n --run_profiler", + "/home/scott/bin/reminder.py --logging_level=DEBUG >& /dev/null", + "/home/scott/bin/wordle.py --mode=AUTOPLAY --template=trial >& /dev/null", + "/home/scott/bin/tplink.py -a office_lights -c info --audit_import_events >& /dev/null", + "/home/scott/bin/unscramble.py ethyropadratoyzrhoiectmi --trace_memory >& /dev/null", + ] + for command in commands: + try: + ret = exec_utils.cmd_with_timeout(command, 5.0) + self.assertEqual(0, ret) + except Exception as e: + logger.exception(e) + self.fail(f"{command} exited with an unexpected exception: {e}") + + +if __name__ == '__main__': + bootstrap.initialize(unittest.main)() -- 2.47.1