From 72155e67410c55f5f2a92e0fafac7f70711d0b2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Doktor?= Date: Tue, 24 Mar 2015 18:03:30 +0100 Subject: [PATCH] avocado.test: Always get unique name in get_tagged_name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When no tag is supplied get_tagged_name() generates unique name. On the other hand when tag is supplied, it silently reuses existing path. This patch adds check for these cases and use $name.$tag.$number in case $name.$tag exists. This should avoid clashes when executing multiple tests with the same name with multiplexation. Signed-off-by: Lukáš Doktor --- avocado/test.py | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/avocado/test.py b/avocado/test.py index b96f4eda..3b00967e 100644 --- a/avocado/test.py +++ b/avocado/test.py @@ -291,28 +291,23 @@ class Test(unittest.TestCase): """ Get a test tagged name. - If a test tag is defined, just return name.tag. If tag is absent, - it'll try to find a tag that is not already taken (so there are no - clashes in the results directory). + Combines name + tag (if present) to obtain unique name. When associated + directory already exists, appends ".$number" until unused name + is generated to avoid clashes. :param logdir: Log directory being in use for result storage. - :return: String `test.tag`. + :return: Unique test name """ + name = self.name if self.tag is not None: - return "%s.%s" % (self.name, self.tag) - + name += ".%s" % self.tag tag = 0 - if tag == 0: - tagged_name = self.name - else: - tagged_name = "%s.%s" % (self.name, tag) - test_logdir = os.path.join(logdir, tagged_name) - while os.path.isdir(test_logdir): + tagged_name = name + while os.path.isdir(os.path.join(logdir, tagged_name)): tag += 1 - tagged_name = "%s.%s" % (self.name, tag) - test_logdir = os.path.join(logdir, tagged_name) - self.tag = str(tag) + tagged_name = "%s.%s" % (name, tag) + self.tag = "%s.%s" % (self.tag, tag) if self.tag else str(tag) return tagged_name -- GitLab