From 2c18000b934722c69e23a2d0ad181767d5266ac9 Mon Sep 17 00:00:00 2001 From: William Blevins Date: Fri, 23 Sep 2016 00:43:00 -0400 Subject: Allowed for multiple fixture dirs and added default global directory. --- QMTest/TestCmd.py | 25 ++++++++++++++++--------- QMTest/TestSCons.py | 2 +- runtest.py | 8 +++++--- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/QMTest/TestCmd.py b/QMTest/TestCmd.py index bff0d6a..109c83a 100644 --- a/QMTest/TestCmd.py +++ b/QMTest/TestCmd.py @@ -924,7 +924,7 @@ class TestCmd(object): self.condition = 'no_result' self.workdir_set(workdir) self.subdir(subdir) - self.script_srcdir = None + self.fixture_dirs = [] def __del__(self): self.cleanup() @@ -1248,8 +1248,13 @@ class TestCmd(object): assumed to be under the temporary working directory, it gets created automatically, if it does not already exist. """ - if srcdir and self.script_srcdir and not os.path.isabs(srcdir): - spath = os.path.join(self.script_srcdir, srcdir) + + if srcdir and self.fixture_dirs and not os.path.isabs(srcdir): + for dir in self.fixture_dirs: + spath = os.path.join(self.fixture_dirs, srcdir) + if os.path.isdir(spath): + continue + else: spath = srcdir if dstdir: @@ -1285,13 +1290,15 @@ class TestCmd(object): automatically, if it does not already exist. """ srcpath, srctail = os.path.split(srcfile) - if srcpath: - if self.script_srcdir and not os.path.isabs(srcpath): - spath = os.path.join(self.script_srcdir, srcfile) - else: - spath = srcfile + + if srcpath and (not self.fixture_dirs or os.path.isabs(srcpath)): + spath = srcfile else: - spath = os.path.join(self.script_srcdir, srcfile) + for dir in self.fixture_dirs: + spath = os.path.join(self.fixture_dirs, srcfile) + if os.path.isfile(spath): + continue + if not dstfile: if srctail: dpath = os.path.join(self.workdir, srctail) diff --git a/QMTest/TestSCons.py b/QMTest/TestSCons.py index 0d5dc90..f02ddd8 100644 --- a/QMTest/TestSCons.py +++ b/QMTest/TestSCons.py @@ -268,7 +268,7 @@ class TestSCons(TestCommon): SCons.Node.FS.default_fs = SCons.Node.FS.FS() try: - self.script_srcdir = os.environ['PYTHON_SCRIPT_DIR'] + self.fixture_dirs = os.environ['FIXTURE_DIRS'].split(':') except KeyError: pass diff --git a/runtest.py b/runtest.py index 0950bbe..dec8f9f 100755 --- a/runtest.py +++ b/runtest.py @@ -786,10 +786,12 @@ def run_test(t, io_lock, async=True): if not suppress_stdout and not suppress_stderr: sys.stdout.write(header) head, tail = os.path.split(t.abspath) + fixture_dirs = [] if head: - os.environ['PYTHON_SCRIPT_DIR'] = head - else: - os.environ['PYTHON_SCRIPT_DIR'] = '' + fixture_dirs.append(head) + fixture_dirs.append(os.path.join(os.path.split(os.path.abspath(__file__))[0], 'fixture')) + os.environ['PYTHON_SCRIPT_DIR'] = ':'.join(fixture_dirs) + test_start_time = time_func() if execute_tests: t.execute() -- cgit v0.12