This revision was automatically updated to reflect the committed changes.
Closed by commit rL327703: [dotest] Clean up test folder clean-up (authored by 
labath, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D44526?vs=138579&id=138681#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D44526

Files:
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/comp_dir_symlink/TestCompDirSymLink.py
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/command_script_immediate_output/TestCommandScriptImmediateOutput.py
  lldb/trunk/packages/Python/lldbsuite/test/functionalities/exec/TestExec.py
  
lldb/trunk/packages/Python/lldbsuite/test/linux/add-symbols/TestTargetSymbolsAddCommand.py
  
lldb/trunk/packages/Python/lldbsuite/test/linux/sepdebugsymlink/TestTargetSymbolsSepDebugSymlink.py
  lldb/trunk/packages/Python/lldbsuite/test/lldbinline.py
  lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py
  
lldb/trunk/packages/Python/lldbsuite/test/macosx/add-dsym/TestAddDsymMidExecutionCommand.py
  lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_base.py
  lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_darwin.py
  lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_freebsd.py
  lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_linux.py
  lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_netbsd.py
  lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_win32.py
  lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py
  lldb/trunk/packages/Python/lldbsuite/test/warnings/uuid/TestAddDsymCommand.py
  lldb/trunk/test/CMakeLists.txt

Index: lldb/trunk/test/CMakeLists.txt
===================================================================
--- lldb/trunk/test/CMakeLists.txt
+++ lldb/trunk/test/CMakeLists.txt
@@ -6,8 +6,6 @@
     )
 
   add_custom_target(${name}
-    # Clear the test directory first.
-    COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/lldb-test-build.noindex
     COMMAND ${PYTHON_TEST_COMMAND} ${ARG_DEFAULT_ARGS}
     COMMENT "${comment}"
     DEPENDS ${LLDB_TEST_DEPS}
Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/exec/TestExec.py
===================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/exec/TestExec.py
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/exec/TestExec.py
@@ -41,7 +41,6 @@
         self.do_test(True)
 
     def do_test(self, skip_exec):
-        self.makeBuildDir()
         exe = self.getBuildArtifact("a.out")
         if self.getArchitecture() == 'x86_64':
             source = self.getSourcePath("main.cpp")
Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/command_script_immediate_output/TestCommandScriptImmediateOutput.py
===================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/command_script_immediate_output/TestCommandScriptImmediateOutput.py
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/command_script_immediate_output/TestCommandScriptImmediateOutput.py
@@ -30,7 +30,6 @@
     @expectedFailureAll(oslist=["freebsd"], bugnumber="llvm.org/pr26139")
     def test_command_script_immediate_output_console(self):
         """Test that LLDB correctly allows scripted commands to set immediate output to the console."""
-        self.makeBuildDir()
         self.launch(timeout=10)
 
         script = os.path.join(self.getSourceDir(), 'custom_command.py')
@@ -53,7 +52,6 @@
     @expectedFailureAll(oslist=["freebsd"], bugnumber="llvm.org/pr26139")
     def test_command_script_immediate_output_file(self):
         """Test that LLDB correctly allows scripted commands to set immediate output to a file."""
-        self.makeBuildDir()
         self.launch(timeout=10)
 
         test_files = {self.getBuildArtifact('read.txt'): 'r',
Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/comp_dir_symlink/TestCompDirSymLink.py
===================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/comp_dir_symlink/TestCompDirSymLink.py
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/comp_dir_symlink/TestCompDirSymLink.py
@@ -64,16 +64,15 @@
             self.line)
 
     def create_src_symlink(self):
-        self.makeBuildDir()
         pwd_symlink = self.getBuildArtifact('pwd_symlink')
         if os.path.exists(pwd_symlink):
             os.unlink(pwd_symlink)
         os.symlink(self.getBuildDir(), pwd_symlink)
         self.addTearDownHook(lambda: os.remove(pwd_symlink))
         return pwd_symlink
 
     def doBuild(self, pwd_symlink):
-        self.build(None, None, {'PWD': pwd_symlink}, True)
+        self.build(None, None, {'PWD': pwd_symlink})
 
         exe = self.getBuildArtifact(_EXE_NAME)
         self.runCmd('file ' + exe, CURRENT_EXECUTABLE_SET)
Index: lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py
===================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py
+++ lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py
@@ -27,7 +27,6 @@
             raise("mydir is empty")
 
         Base.setUp(self)
-        self.makeBuildDir()
         self.buildDefault()
         self.child_prompt = "(gdb)"
         self.myexe = self.getBuildArtifact("a.out")
Index: lldb/trunk/packages/Python/lldbsuite/test/warnings/uuid/TestAddDsymCommand.py
===================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/warnings/uuid/TestAddDsymCommand.py
+++ lldb/trunk/packages/Python/lldbsuite/test/warnings/uuid/TestAddDsymCommand.py
@@ -28,14 +28,14 @@
 
         # Call the program generator to produce main.cpp, version 1.
         self.generate_main_cpp(version=1)
-        self.buildDefault(clean=True, dictionary={'MAKE_DSYM':'YES'})
+        self.buildDefault(dictionary={'MAKE_DSYM':'YES'})
 
         # Insert some delay and then call the program generator to produce
         # main.cpp, version 2.
         time.sleep(5)
         self.generate_main_cpp(version=101)
         # Now call make again, but this time don't generate the dSYM.
-        self.buildDefault(clean=False, dictionary={'MAKE_DSYM':'NO'})
+        self.buildDefault(dictionary={'MAKE_DSYM':'NO'})
 
         self.exe_name = 'a.out'
         self.do_add_dsym_with_error(self.exe_name)
@@ -46,7 +46,7 @@
 
         # Call the program generator to produce main.cpp, version 1.
         self.generate_main_cpp(version=1)
-        self.buildDefault(clean=True, dictionary={'MAKE_DSYM':'YES'})
+        self.buildDefault(dictionary={'MAKE_DSYM':'YES'})
 
         self.exe_name = 'a.out'
         self.do_add_dsym_with_success(self.exe_name)
@@ -57,7 +57,7 @@
 
         # Call the program generator to produce main.cpp, version 1.
         self.generate_main_cpp(version=1)
-        self.buildDefault(clean=True, dictionary={'MAKE_DSYM':'YES'})
+        self.buildDefault(dictionary={'MAKE_DSYM':'YES'})
 
         self.exe_name = 'a.out'
         self.do_add_dsym_with_dSYM_bundle(self.exe_name)
@@ -72,7 +72,6 @@
             '%ADD_EXTRA_CODE%',
             'printf("This is version %d\\n");' %
             version)
-        self.makeBuildDir()
         src = os.path.join(self.getBuildDir(), self.source)
         with open(src, 'w') as f:
             f.write(new_content)
Index: lldb/trunk/packages/Python/lldbsuite/test/lldbinline.py
===================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/lldbinline.py
+++ lldb/trunk/packages/Python/lldbsuite/test/lldbinline.py
@@ -97,7 +97,6 @@
             return "-N dsym " + self.mydir
 
     def BuildMakefile(self):
-        self.makeBuildDir()
         makefilePath = self.getBuildArtifact("Makefile")
         if os.path.exists(makefilePath):
             return
Index: lldb/trunk/packages/Python/lldbsuite/test/linux/sepdebugsymlink/TestTargetSymbolsSepDebugSymlink.py
===================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/linux/sepdebugsymlink/TestTargetSymbolsSepDebugSymlink.py
+++ lldb/trunk/packages/Python/lldbsuite/test/linux/sepdebugsymlink/TestTargetSymbolsSepDebugSymlink.py
@@ -17,7 +17,7 @@
     @skipIf(hostoslist=["windows"])
     @skipIfRemote # llvm.org/pr36237
     def test_target_symbols_sepdebug_symlink_case(self):
-        self.build(clean=True)
+        self.build()
         exe = self.getBuildArtifact("dirsymlink/stripped.symlink")
 
         lldbutil.run_to_name_breakpoint(self, "main", exe_name = exe)
Index: lldb/trunk/packages/Python/lldbsuite/test/linux/add-symbols/TestTargetSymbolsAddCommand.py
===================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/linux/add-symbols/TestTargetSymbolsAddCommand.py
+++ lldb/trunk/packages/Python/lldbsuite/test/linux/add-symbols/TestTargetSymbolsAddCommand.py
@@ -22,7 +22,7 @@
         """Test that 'target symbols add' can load the symbols
         even if gnu.build-id and gnu_debuglink are not present in the module.
         Similar to test_add_dsym_mid_execution test for macos."""
-        self.build(clean=True)
+        self.build()
         exe = self.getBuildArtifact("stripped.out")
 
         self.target = self.dbg.CreateTarget(exe)
Index: lldb/trunk/packages/Python/lldbsuite/test/macosx/add-dsym/TestAddDsymMidExecutionCommand.py
===================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/macosx/add-dsym/TestAddDsymMidExecutionCommand.py
+++ lldb/trunk/packages/Python/lldbsuite/test/macosx/add-dsym/TestAddDsymMidExecutionCommand.py
@@ -25,7 +25,7 @@
     @no_debug_info_test  # Prevent the genaration of the dwarf version of this test
     def test_add_dsym_mid_execution(self):
         """Test that add-dsym mid-execution loads the symbols at the right place for a slid binary."""
-        self.buildDefault(clean=True, dictionary={'MAKE_DSYM':'YES'})
+        self.buildDefault(dictionary={'MAKE_DSYM':'YES'})
         exe = self.getBuildArtifact("a.out")
 
         self.target = self.dbg.CreateTarget(exe)
Index: lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_darwin.py
===================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_darwin.py
+++ lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_darwin.py
@@ -10,14 +10,10 @@
         architecture=None,
         compiler=None,
         dictionary=None,
-        clean=True,
         testdir=None,
         testname=None):
     """Build the binaries with dsym debug info."""
     commands = []
-    if clean:
-        commands.append(getMake(testdir, testname) +
-                        ["clean", getCmdLine(dictionary)])
     commands.append(getMake(testdir, testname) +
                     ["MAKE_DSYM=YES",
                      getArchSpec(architecture),
Index: lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_win32.py
===================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_win32.py
+++ lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_win32.py
@@ -6,6 +6,5 @@
         architecture=None,
         compiler=None,
         dictionary=None,
-        clean=True,
         testdir=None):
     return False
Index: lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_netbsd.py
===================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_netbsd.py
+++ lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_netbsd.py
@@ -6,6 +6,5 @@
         architecture=None,
         compiler=None,
         dictionary=None,
-        clean=True,
         testdir=None):
     return False
Index: lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_linux.py
===================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_linux.py
+++ lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_linux.py
@@ -6,6 +6,5 @@
         architecture=None,
         compiler=None,
         dictionary=None,
-        clean=True,
         testdir=None):
     return False
Index: lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_freebsd.py
===================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_freebsd.py
+++ lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_freebsd.py
@@ -6,6 +6,5 @@
         architecture=None,
         compiler=None,
         dictionary=None,
-        clean=True,
         testdir=None):
     return False
Index: lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_base.py
===================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_base.py
+++ lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_base.py
@@ -140,13 +140,10 @@
         architecture=None,
         compiler=None,
         dictionary=None,
-        clean=True,
         testdir=None,
         testname=None):
     """Build the binaries the default way."""
     commands = []
-    if clean:
-        commands.append(getMake(testdir, testname) + ["clean", getCmdLine(dictionary)])
     commands.append(getMake(testdir, testname) + ["all", getArchSpec(architecture),
                      getCCSpec(compiler), getCmdLine(dictionary)])
 
@@ -161,14 +158,10 @@
         architecture=None,
         compiler=None,
         dictionary=None,
-        clean=True,
         testdir=None,
         testname=None):
     """Build the binaries with dwarf debug info."""
     commands = []
-    if clean:
-        commands.append(getMake(testdir, testname) +
-                        ["clean", getCmdLine(dictionary)])
     commands.append(getMake(testdir, testname) +
                     ["MAKE_DSYM=NO", getArchSpec(architecture),
                      getCCSpec(compiler), getCmdLine(dictionary)])
@@ -183,14 +176,10 @@
         architecture=None,
         compiler=None,
         dictionary=None,
-        clean=True,
         testdir=None,
         testname=None):
     """Build the binaries with dwarf debug info."""
     commands = []
-    if clean:
-        commands.append(getMake(testdir, testname) +
-                        ["clean", getCmdLine(dictionary)])
     commands.append(getMake(testdir, testname) +
                     ["MAKE_DSYM=NO", "MAKE_DWO=YES",
                      getArchSpec(architecture),
@@ -207,14 +196,10 @@
         architecture=None,
         compiler=None,
         dictionary=None,
-        clean=True,
         testdir=None,
         testname=None):
     """Build the binaries with dwarf debug info."""
     commands = []
-    if clean:
-        commands.append(getMake(testdir, testname) +
-                        ["clean", getCmdLine(dictionary)])
     commands.append(getMake(testdir, testname) +
                     ["MAKE_DSYM=NO",
                      "MAKE_GMODULES=YES",
Index: lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py
===================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py
@@ -44,6 +44,7 @@
 import io
 import os.path
 import re
+import shutil
 import signal
 from subprocess import *
 import sys
@@ -697,17 +698,18 @@
 
     def getBuildDir(self):
         """Return the full path to the current test."""
-        variant = self.getDebugInfo()
-        if variant is None:
-            variant = 'default'
         return os.path.join(os.environ["LLDB_BUILD"], self.mydir,
                             self.getBuildDirBasename())
     
      
     def makeBuildDir(self):
-        """Create the test-specific working directory."""
+        """Create the test-specific working directory, deleting any previous
+        contents."""
         # See also dotest.py which sets up ${LLDB_BUILD}.
-        lldbutil.mkdir_p(self.getBuildDir())
+        bdir = self.getBuildDir()
+        if os.path.isdir(bdir):
+            shutil.rmtree(bdir)
+        lldbutil.mkdir_p(bdir)
  
     def getBuildArtifact(self, name="a.out"):
         """Return absolute path to an artifact in the test's build directory."""
@@ -1490,26 +1492,23 @@
             self,
             architecture=None,
             compiler=None,
-            dictionary=None,
-            clean=True):
+            dictionary=None):
         """Platform specific way to build the default binaries."""
         testdir = self.mydir
         testname = self.getBuildDirBasename()
         if self.getDebugInfo():
             raise Exception("buildDefault tests must set NO_DEBUG_INFO_TESTCASE")
         module = builder_module()
-        self.makeBuildDir()
         dictionary = lldbplatformutil.finalize_build_dictionary(dictionary)
         if not module.buildDefault(self, architecture, compiler,
-                                   dictionary, clean, testdir, testname):
+                                   dictionary, testdir, testname):
             raise Exception("Don't know how to build default binary")
 
     def buildDsym(
             self,
             architecture=None,
             compiler=None,
-            dictionary=None,
-            clean=True):
+            dictionary=None):
         """Platform specific way to build binaries with dsym info."""
         testdir = self.mydir
         testname = self.getBuildDirBasename()
@@ -1519,15 +1518,14 @@
         module = builder_module()
         dictionary = lldbplatformutil.finalize_build_dictionary(dictionary)
         if not module.buildDsym(self, architecture, compiler,
-                                dictionary, clean, testdir, testname):
+                                dictionary, testdir, testname):
             raise Exception("Don't know how to build binary with dsym")
 
     def buildDwarf(
             self,
             architecture=None,
             compiler=None,
-            dictionary=None,
-            clean=True):
+            dictionary=None):
         """Platform specific way to build binaries with dwarf maps."""
         testdir = self.mydir
         testname = self.getBuildDirBasename()
@@ -1537,15 +1535,14 @@
         module = builder_module()
         dictionary = lldbplatformutil.finalize_build_dictionary(dictionary)
         if not module.buildDwarf(self, architecture, compiler,
-                                   dictionary, clean, testdir, testname):
+                                   dictionary, testdir, testname):
             raise Exception("Don't know how to build binary with dwarf")
 
     def buildDwo(
             self,
             architecture=None,
             compiler=None,
-            dictionary=None,
-            clean=True):
+            dictionary=None):
         """Platform specific way to build binaries with dwarf maps."""
         testdir = self.mydir
         testname = self.getBuildDirBasename()
@@ -1555,15 +1552,14 @@
         module = builder_module()
         dictionary = lldbplatformutil.finalize_build_dictionary(dictionary)
         if not module.buildDwo(self, architecture, compiler,
-                                   dictionary, clean, testdir, testname):
+                                   dictionary, testdir, testname):
             raise Exception("Don't know how to build binary with dwo")
 
     def buildGModules(
             self,
             architecture=None,
             compiler=None,
-            dictionary=None,
-            clean=True):
+            dictionary=None):
         """Platform specific way to build binaries with gmodules info."""
         testdir = self.mydir
         testname = self.getBuildDirBasename()
@@ -1573,7 +1569,7 @@
         module = builder_module()
         dictionary = lldbplatformutil.finalize_build_dictionary(dictionary)
         if not module.buildGModules(self, architecture, compiler,
-                                    dictionary, clean, testdir, testname):
+                                    dictionary, testdir, testname):
             raise Exception("Don't know how to build binary with gmodules")
 
     def buildGo(self):
@@ -1869,7 +1865,6 @@
     timeWaitNextLaunch = 1.0
 
     def generateSource(self, source):
-        self.makeBuildDir()
         template = source + '.template'
         temp = os.path.join(self.getSourceDir(), template)
         with open(temp, 'r') as f:
@@ -2297,26 +2292,21 @@
             self,
             architecture=None,
             compiler=None,
-            dictionary=None,
-            clean=True):
+            dictionary=None):
         """Platform specific way to build the default binaries."""
         module = builder_module()
-        self.makeBuildDir()
 
         dictionary = lldbplatformutil.finalize_build_dictionary(dictionary)
         if self.getDebugInfo() is None:
-            return self.buildDefault(architecture, compiler, dictionary,
-                                     clean)
+            return self.buildDefault(architecture, compiler, dictionary)
         elif self.getDebugInfo() == "dsym":
-            return self.buildDsym(architecture, compiler, dictionary, clean)
+            return self.buildDsym(architecture, compiler, dictionary)
         elif self.getDebugInfo() == "dwarf":
-            return self.buildDwarf(architecture, compiler, dictionary, clean)
+            return self.buildDwarf(architecture, compiler, dictionary)
         elif self.getDebugInfo() == "dwo":
-            return self.buildDwo(architecture, compiler, dictionary,
-                                 clean)
+            return self.buildDwo(architecture, compiler, dictionary)
         elif self.getDebugInfo() == "gmodules":
-            return self.buildGModules(architecture, compiler, dictionary,
-                                      clean)
+            return self.buildGModules(architecture, compiler, dictionary)
         else:
             self.fail("Can't build for debug info: %s" % self.getDebugInfo())
 
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to