Commits

Brett Cannon committed 921434a

Properly clean up the 'build' directory from test runs.

Comments (0)

Files changed (2)

         print('Running coverage ...')
         regrtest_path = os.path.join(CPython.directory, 'Lib', 'test',
                                     'regrtest.py')
-        subprocess.check_call([executable, self.directory, 'run', '--pylib',
-                               regrtest_path])
-        # Clean up from the test run
-        os.rmdir('build')
+        try:
+            subprocess.check_call([executable, self.directory, 'run', '--pylib',
+                                   regrtest_path])
+        finally:
+            # Clean up from the test run
+            os.rmdir('build')
         # Generate the HTML report
         print('Generating report ...')
         subprocess.call([executable, 'coveragepy', 'html', '-i', '--omit',
     if cmd is None:
         print('CPython is not built')
         sys.exit(1)
-    subprocess.call([cmd, '-W', 'default', '-bb', '-E', '-m', 'test', '-r',
-                     '-w', '-u', 'all', '-j',
-                     str(multiprocessing.cpu_count())])
+    try:
+        subprocess.call([cmd, '-W', 'default', '-bb', '-E', '-m', 'test', '-r',
+                         '-w', '-u', 'all', '-j',
+                         str(multiprocessing.cpu_count())])
+    finally:
+        os.rmdir('build')
 
 
 if __name__ == '__main__':