[Lldb-commits] [lldb] r225407 - Fix inlined test cases so they print out the correct command to run when they fail instead of printing out incorrect information.

Greg Clayton gclayton at apple.com
Wed Jan 7 14:25:50 PST 2015


Author: gclayton
Date: Wed Jan  7 16:25:50 2015
New Revision: 225407

URL: http://llvm.org/viewvc/llvm-project?rev=225407&view=rev
Log:
Fix inlined test cases so they print out the correct command to run when they fail instead of printing out incorrect information.

To fix this I added a new method to TestBase:

    def getRerunArgs(self):
        return " -f %s.%s" % (self.__class__.__name__, self._testMethodName)
        
The InlineTest which inherits from TestBase then overrides this function with a custom version which does the right thing.


Modified:
    lldb/trunk/test/lldbinline.py
    lldb/trunk/test/lldbtest.py

Modified: lldb/trunk/test/lldbinline.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbinline.py?rev=225407&r1=225406&r2=225407&view=diff
==============================================================================
--- lldb/trunk/test/lldbinline.py (original)
+++ lldb/trunk/test/lldbinline.py Wed Jan  7 16:25:50 2015
@@ -66,63 +66,63 @@ class CommandParser:
                 test.execute_user_command(breakpoint['command'])
                 return
 
-def BuildMakefile(mydir):
-    if os.path.exists("Makefile"):
-        return
-
-    categories = {}
-
-    for f in os.listdir(os.getcwd()):
-        t = source_type(f)
-        if t:
-            if t in categories.keys():
-                categories[t].append(f)
-            else:
-                categories[t] = [f]
-
-    makefile = open("Makefile", 'w+')
-
-    level = os.sep.join([".."] * len(mydir.split(os.sep))) + os.sep + "make"
-
-    makefile.write("LEVEL = " + level + "\n")
-   
-    for t in categories.keys():
-        line = t + " := " + " ".join(categories[t])
-        makefile.write(line + "\n")
-
-    if ('OBJCXX_SOURCES' in categories.keys()) or ('OBJC_SOURCES' in categories.keys()):
-        makefile.write("LDFLAGS = $(CFLAGS) -lobjc -framework Foundation\n")
-
-    if ('CXX_SOURCES' in categories.keys()):
-        makefile.write("CXXFLAGS += -std=c++11\n")
-
-    makefile.write("include $(LEVEL)/Makefile.rules\n")
-    makefile.flush()
-    makefile.close()
-
-def CleanMakefile():
-    # Do nothing for now, since the Makefile on disk could be checked into the repo.
-    pass
-
 class InlineTest(TestBase):
     # Internal implementation
 
-    @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
-    def buildDsymWithImplicitMakefile(self):
-        BuildMakefile(self.mydir)
-        self.buildDsym()
+    def getRerunArgs(self):
+        # The -N option says to NOT run a if it matches the option argument, so
+        # if we are using dSYM we say to NOT run dwarf (-N dwarf) and vice versa.
+        if self.using_dsym:
+            return "-N dwarf %s" % (self.mydir)
+        else:
+            return "-N dsym %s" % (self.mydir)
+        
+    def BuildMakefile(self):
+        if os.path.exists("Makefile"):
+            return
+
+        categories = {}
+
+        for f in os.listdir(os.getcwd()):
+            t = source_type(f)
+            if t:
+                if t in categories.keys():
+                    categories[t].append(f)
+                else:
+                    categories[t] = [f]
+
+        makefile = open("Makefile", 'w+')
+
+        level = os.sep.join([".."] * len(self.mydir.split(os.sep))) + os.sep + "make"
+
+        makefile.write("LEVEL = " + level + "\n")
+
+        for t in categories.keys():
+            line = t + " := " + " ".join(categories[t])
+            makefile.write(line + "\n")
+
+        if ('OBJCXX_SOURCES' in categories.keys()) or ('OBJC_SOURCES' in categories.keys()):
+            makefile.write("LDFLAGS = $(CFLAGS) -lobjc -framework Foundation\n")
+
+        if ('CXX_SOURCES' in categories.keys()):
+            makefile.write("CXXFLAGS += -std=c++11\n")
+
+        makefile.write("include $(LEVEL)/Makefile.rules\n")
+        makefile.flush()
+        makefile.close()
 
-    def buildDwarfWithImplicitMakefile(self):
-        BuildMakefile(self.mydir)
-        self.buildDwarf()
 
     @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
     def __test_with_dsym(self):
-        self.buildDsymWithImplicitMakefile()
+        self.using_dsym = True
+        self.BuildMakefile()
+        self.buildDsym()
         self.do_test()
 
     def __test_with_dwarf(self):
-        self.buildDwarfWithImplicitMakefile()
+        self.using_dsym = False
+        self.BuildMakefile()
+        self.buildDwarf()
         self.do_test()
 
     def execute_user_command(self, __command):
@@ -146,9 +146,6 @@ class InlineTest(TestBase):
             parser.handle_breakpoint(self, breakpoint_id)
             process.Continue()
 
-    @classmethod
-    def classCleanup(cls):
-        CleanMakefile()
 
     # Utilities for testcases
 

Modified: lldb/trunk/test/lldbtest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=225407&r1=225406&r2=225407&view=diff
==============================================================================
--- lldb/trunk/test/lldbtest.py (original)
+++ lldb/trunk/test/lldbtest.py Wed Jan  7 16:25:50 2015
@@ -1167,6 +1167,9 @@ class Base(unittest2.TestCase):
             else:
                 print >> sbuf, "unexpected success (problem id:" + str(bugnumber) + ")"	
 
+    def getRerunArgs(self):
+        return " -f %s.%s" % (self.__class__.__name__, self._testMethodName)
+        
     def dumpSessionInfo(self):
         """
         Dump the debugger interactions leading to a test error/failure.  This
@@ -1229,10 +1232,9 @@ class Base(unittest2.TestCase):
             print >> f, "Session info generated @", datetime.datetime.now().ctime()
             print >> f, self.session.getvalue()
             print >> f, "To rerun this test, issue the following command from the 'test' directory:\n"
-            print >> f, "./dotest.py %s -v %s -f %s.%s" % (self.getRunOptions(),
-                                                           ('+b' if benchmarks else '-t'),
-                                                           self.__class__.__name__,
-                                                           self._testMethodName)
+            print >> f, "./dotest.py %s -v %s %s" % (self.getRunOptions(),
+                                                     ('+b' if benchmarks else '-t'),
+                                                     self.getRerunArgs())
 
     # ====================================================
     # Config. methods supported through a plugin interface





More information about the lldb-commits mailing list