diff --git a/lldb/test/help/TestHelp.py b/lldb/test/help/TestHelp.py index a6db2f6e59fa..201941dccaf6 100644 --- a/lldb/test/help/TestHelp.py +++ b/lldb/test/help/TestHelp.py @@ -18,12 +18,47 @@ class HelpCommandTestCase(TestBase): 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("(.*)", 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("CFBundleVersion") != -1: + # Found our match. The next line contains our version + # string, for example: + # + # 38 + 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."""