[Lldb-commits] [lldb] r122930 - /lldb/trunk/test/help/TestHelp.py

Johnny Chen johnny.chen at apple.com
Wed Jan 5 16:03:01 PST 2011


Author: johnny
Date: Wed Jan  5 18:03:01 2011
New Revision: 122930

URL: http://llvm.org/viewvc/llvm-project?rev=122930&view=rev
Log:
Modify test_help_version() test case to be more precise in matching the version
number string as found in the resources/LLDB-info.plist file.

Modified:
    lldb/trunk/test/help/TestHelp.py

Modified: lldb/trunk/test/help/TestHelp.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/help/TestHelp.py?rev=122930&r1=122929&r2=122930&view=diff
==============================================================================
--- lldb/trunk/test/help/TestHelp.py (original)
+++ lldb/trunk/test/help/TestHelp.py Wed Jan  5 18:03:01 2011
@@ -18,12 +18,47 @@
         self.expect("help",
             startstr = 'The following is a list of built-in, permanent debugger commands')
 
+    def version_number_string(self):
+        """Helper function to find the version number string of lldb."""
+        plist = os.path.join(os.getcwd(), os.pardir, os.pardir, "resources", "LLDB-info.plist")
+        try:
+            CFBundleVersionSegFound = False
+            with open(plist, 'r') as f:
+                for line in f:
+                    if CFBundleVersionSegFound:
+                        version_line = line.strip()
+                        import re
+                        m = re.match("<string>(.*)</string>", version_line)
+                        if m:
+                            version = m.group(1)
+                            return version
+                        else:
+                            # Unsuccessful, let's juts break out of the for loop.
+                            break
+
+                    if line.find("<key>CFBundleVersion</key>") != -1:
+                        # Found our match.  The next line contains our version
+                        # string, for example:
+                        # 
+                        #     <string>38</string>
+                        CFBundleVersionSegFound = True
+
+        except:
+            # Just fallthrough...
+            print "Unexpected error:", sys.exc_info()[0]
+            pass
+
+        # Use None to signify that we are not able to grok the version number.
+        return None
+
+
     def test_help_version(self):
         """Test 'help version' and 'version' commands."""
         self.expect("help version",
             substrs = ['Show version of LLDB debugger.'])
+        version_str = self.version_number_string()
         self.expect("version",
-            patterns = ['LLDB-[0-9]+'])
+            patterns = ['LLDB-' + (version_str if version_str else '[0-9]+')])
 
     def test_help_should_not_hang_emacsshell(self):
         """Command 'settings set term-width 0' should not hang the help command."""





More information about the lldb-commits mailing list