From 4f36972414879cbd0fe9d50a6a283f4207042c51 Mon Sep 17 00:00:00 2001 From: Steve Kuznetsov Date: Mon, 9 Jan 2017 09:56:48 -0500 Subject: [PATCH] Clean up artifacts before test runs, not after When tests fail, artifacts from that tests are necessary to properly debug the failure and determine how to fix the test. This is impossible when artifacts are immediately removed after the test is finished. Instead, the tests should remove old artifacts before the test run begins. Signed-off-by: Steve Kuznetsov --- runtests.py | 10 ++++++++-- test/functional/fixture.py | 1 - 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/runtests.py b/runtests.py index 4a2e639..bca3420 100755 --- a/runtests.py +++ b/runtests.py @@ -15,9 +15,10 @@ """ Executes all tests. """ - -import sys import os +import shutil +import sys +import tempfile # Make sure we run from the source, this is tricky because the functional # tests need to find both the location of the 'tito' executable script, @@ -39,4 +40,9 @@ if __name__ == '__main__': print("Using nose %s" % nose.__version__[0:3]) print("Running tito tests against: %s" % SRC_DIR) + # Make sure no older test directories exist + for dir in os.listdir(tempfile.gettempdir()): + if dir.endswith('-titotest'): + shutil.rmtree(os.path.join(tempfile.gettempdir(), dir)) + nose.main() diff --git a/test/functional/fixture.py b/test/functional/fixture.py index fb19632..53fc824 100644 --- a/test/functional/fixture.py +++ b/test/functional/fixture.py @@ -128,7 +128,6 @@ class TitoGitTestFixture(unittest.TestCase): def tearDown(self): run_command('chmod -R u+rw %s' % self.repo_dir) - shutil.rmtree(self.repo_dir) pass def write_file(self, path, contents):