diff options
-rw-r--r-- | meta/lib/oeqa/selftest/base.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/meta/lib/oeqa/selftest/base.py b/meta/lib/oeqa/selftest/base.py index 25ca84bd66..fc880e9d26 100644 --- a/meta/lib/oeqa/selftest/base.py +++ b/meta/lib/oeqa/selftest/base.py | |||
@@ -9,6 +9,7 @@ | |||
9 | import unittest | 9 | import unittest |
10 | import os | 10 | import os |
11 | import sys | 11 | import sys |
12 | import shutil | ||
12 | import logging | 13 | import logging |
13 | import errno | 14 | import errno |
14 | 15 | ||
@@ -26,6 +27,7 @@ class oeSelfTest(unittest.TestCase): | |||
26 | self.testinc_path = os.path.join(self.builddir, "conf/selftest.inc") | 27 | self.testinc_path = os.path.join(self.builddir, "conf/selftest.inc") |
27 | self.testlayer_path = oeSelfTest.testlayer_path | 28 | self.testlayer_path = oeSelfTest.testlayer_path |
28 | self._extra_tear_down_commands = [] | 29 | self._extra_tear_down_commands = [] |
30 | self._track_for_cleanup = [] | ||
29 | super(oeSelfTest, self).__init__(methodName) | 31 | super(oeSelfTest, self).__init__(methodName) |
30 | 32 | ||
31 | def setUp(self): | 33 | def setUp(self): |
@@ -60,6 +62,15 @@ class oeSelfTest(unittest.TestCase): | |||
60 | self.log.warning("tearDown commands have failed: %s" % ', '.join(map(str, failed_extra_commands))) | 62 | self.log.warning("tearDown commands have failed: %s" % ', '.join(map(str, failed_extra_commands))) |
61 | self.log.debug("Trying to move on.") | 63 | self.log.debug("Trying to move on.") |
62 | self._extra_tear_down_commands = [] | 64 | self._extra_tear_down_commands = [] |
65 | |||
66 | if self._track_for_cleanup: | ||
67 | for path in self._track_for_cleanup: | ||
68 | if os.path.isdir(path): | ||
69 | shutil.rmtree(path) | ||
70 | if os.path.isfile(path): | ||
71 | os.remove(path) | ||
72 | self._track_for_cleanup = [] | ||
73 | |||
63 | self.tearDownLocal() | 74 | self.tearDownLocal() |
64 | 75 | ||
65 | def tearDownLocal(self): | 76 | def tearDownLocal(self): |
@@ -69,6 +80,10 @@ class oeSelfTest(unittest.TestCase): | |||
69 | def add_command_to_tearDown(self, command): | 80 | def add_command_to_tearDown(self, command): |
70 | self.log.debug("Adding command '%s' to tearDown for this test." % command) | 81 | self.log.debug("Adding command '%s' to tearDown for this test." % command) |
71 | self._extra_tear_down_commands.append(command) | 82 | self._extra_tear_down_commands.append(command) |
83 | # add test specific files or directories to be removed in the tearDown method | ||
84 | def track_for_cleanup(self, path): | ||
85 | self.log.debug("Adding path '%s' to be cleaned up when test is over" % path) | ||
86 | self._track_for_cleanup.append(path) | ||
72 | 87 | ||
73 | # write to <builddir>/conf/selftest.inc | 88 | # write to <builddir>/conf/selftest.inc |
74 | def write_config(self, data): | 89 | def write_config(self, data): |