# HG changeset patch # User Zachary T Welch zach@mandolincreekfarm.com # Fake Node ID ce229849be37b442a3b1be0217b3e4994d469787
Fix minor bugs in run_tests (#2343, #2347)
This patch contains two fixes for the run_tests.
The first change resolves problems when running the script without a path component in its name (either as 'python run_tests' or with PATH="./tests:${PATH}"). Now, we do not try to change directory unless there is a path component.
The second problem was that the logs directory will not exist in a clean working copy of the repository. It was being created after the logger module was called. That is resolved by moving the directory creation step to occur before the initialization of the logger module options.
diff --git a/tests/run_tests b/tests/run_tests index 689fe92..bc54136 100755 --- a/tests/run_tests +++ b/tests/run_tests @@ -25,9 +25,11 @@ import time from optparse import OptionParser from serial import Serial
-# change to the tests directory -scriptdir = os.path.dirname(sys.argv[0]) -os.chdir(scriptdir) +if __name__ == "__main__": + # change to the tests directory + scriptdir = os.path.dirname(sys.argv[0]) + if scriptdir: + os.chdir(scriptdir)
sys.path.insert(0, "../")
@@ -40,7 +42,10 @@ class LoggerOpts(object): log_file = os.path.join('logs', 'debug.log') log_level = logging.DEBUG
-logger.handle_options(LoggerOpts()) +if __name__ == "__main__": + if not os.path.exists("logs"): + os.mkdir("logs") + logger.handle_options(LoggerOpts())
from chirp import CHIRP_VERSION from chirp.drivers import * @@ -1021,8 +1026,6 @@ class TestRunner: self._test_out = test_out if not os.path.exists("tmp"): os.mkdir("tmp") - if not os.path.exists("logs"): - os.mkdir("logs")
def _make_list(self): run_list = []