From 45a7137c6796f33fbf5b8f7cb64e293260d991cb Mon Sep 17 00:00:00 2001 From: Bjoern Michaelsen Date: Fri, 14 Oct 2016 01:04:51 +0200 Subject: tearDown/clean up solenv test tempdir Change-Id: I2fc5497b0aeadbc43e967f338a3b8718995f2a5c --- solenv/qa/python/gbuildtoide.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'solenv/qa') diff --git a/solenv/qa/python/gbuildtoide.py b/solenv/qa/python/gbuildtoide.py index a1b8d1c691c4..11e66a82f286 100644 --- a/solenv/qa/python/gbuildtoide.py +++ b/solenv/qa/python/gbuildtoide.py @@ -16,15 +16,19 @@ import tempfile class CheckGbuildToIde(unittest.TestCase): + def setUp(self): + self.tempwork = tempfile.mkdtemp() + + def tearDown(self): + subprocess.check_call(['rm', '-rf', self.tempwork]) def test_gbuildtoide(self): - tempwork = tempfile.mkdtemp() os.chdir(os.path.join(os.environ['SRCDIR'], 'solenv', 'qa', 'python', 'selftest')) - subprocess.check_call(['make', 'gbuildtoide', 'WORKDIR=%s' % tempwork]) - jsonfiles = os.listdir(os.path.join(tempwork, 'GbuildToIde', 'Library')) + subprocess.check_call(['make', 'gbuildtoide', 'WORKDIR=%s' % self.tempwork]) + jsonfiles = os.listdir(os.path.join(self.tempwork, 'GbuildToIde', 'Library')) gbuildlibs = [] for jsonfilename in jsonfiles: - with open(os.path.join(tempwork, 'GbuildToIde', 'Library', jsonfilename), 'r') as f: + with open(os.path.join(self.tempwork, 'GbuildToIde', 'Library', jsonfilename), 'r') as f: gbuildlibs.append(json.load(f)) foundlibs = set() for lib in gbuildlibs: @@ -43,10 +47,10 @@ class CheckGbuildToIde(unittest.TestCase): self.assertTrue(False) self.assertEqual(foundlibs, set(['gbuildselftest', 'gbuildselftestdep'])) self.assertEqual(len(foundlibs), 2) - jsonfiles = os.listdir(os.path.join(tempwork, 'GbuildToIde', 'Executable')) + jsonfiles = os.listdir(os.path.join(self.tempwork, 'GbuildToIde', 'Executable')) gbuildexes = [] for jsonfilename in jsonfiles: - with open(os.path.join(tempwork, 'GbuildToIde', 'Executable', jsonfilename), 'r') as f: + with open(os.path.join(self.tempwork, 'GbuildToIde', 'Executable', jsonfilename), 'r') as f: gbuildexes.append(json.load(f)) foundexes = set() for exe in gbuildexes: -- cgit