diff --git a/tools/run.py b/tools/run.py index 35653dc30cf..c79630c96ee 100755 --- a/tools/run.py +++ b/tools/run.py @@ -285,8 +285,9 @@ class BrowserArchitecture(Architecture): return 1 def Cleanup(self): - shutil.rmtree(self.temp_dir) - self.temp_dir = None + if self.temp_dir: + shutil.rmtree(self.temp_dir) + self.temp_dir = None class ChromiumArchitecture(BrowserArchitecture): diff --git a/tools/test.py b/tools/test.py index 769cca19feb..6492d306a22 100755 --- a/tools/test.py +++ b/tools/test.py @@ -1469,6 +1469,11 @@ def Main(): def DoSkip(case): return testing.SKIP in case.outcomes or testing.SLOW in case.outcomes cases_to_run = [ c for c in all_cases if not DoSkip(c) ] + # Creating test cases may generate temporary files. Make sure + # Skipped tests clean up these files. + for c in all_cases: + if DoSkip(c): c.case.Cleanup() + if len(cases_to_run) == 0: print "No tests to run." return 0 diff --git a/tools/testing/test_case.py b/tools/testing/test_case.py index 62e99093574..eb8828d70ce 100644 --- a/tools/testing/test_case.py +++ b/tools/testing/test_case.py @@ -51,6 +51,11 @@ class StandardTestCase(test.TestCase): def GetSource(self): return file(self.filename).read() + def Cleanup(self): + # TODO(ngeoffray): We run out of space on the build bots for these tests if + # the temp directories are not removed right after running the test. + if not self.context.keep_temporary_files: self.run_arch.Cleanup() + class MultiTestCase(StandardTestCase): @@ -77,7 +82,7 @@ class BrowserTestCase(StandardTestCase): super(BrowserTestCase, self).__init__(context, path, filename, mode, arch) self.fatal_static_type_errors = fatal_static_type_errors - + def Run(self): command = self.run_arch.GetCompileCommand(self.fatal_static_type_errors) if command != None: @@ -92,8 +97,6 @@ class BrowserTestCase(StandardTestCase): # If errors were found, fail fast and show compile errors: if test_output.output.exit_code != 0: - if not self.context.keep_temporary_files: - self.run_arch.Cleanup() return test_output command = self.run_arch.GetRunCommand(); @@ -103,16 +106,11 @@ class BrowserTestCase(StandardTestCase): if self.run_arch.HasFailed(test_output.output.stdout): test_output.output.exit_code = 1 - # TODO(ngeoffray): We run out of space on the build bots for these tests if - # the temp directories are not removed right after running the test. - if not self.context.keep_temporary_files: - self.run_arch.Cleanup() - return test_output class CompilationTestCase(test.TestCase): - """ Run the dartc compiler on a given top level dart file """ + """ Run the dartc compiler on a given top level dart file """ def __init__(self, path, context, filename, mode, arch): super(CompilationTestCase, self).__init__(context, path) self.filename = filename @@ -131,7 +129,7 @@ class CompilationTestCase(test.TestCase): def GetCommand(self): cmd = self.context.GetDartC(self.mode, self.arch); cmd += self.context.flags - cmd += ['-check-only', + cmd += ['-check-only', '-fatal-type-errors', '-Werror', '-out', self.temp_dir,