diff options
author | Sean Callanan <scallanan@apple.com> | 2016-03-08 18:58:48 +0000 |
---|---|---|
committer | Sean Callanan <scallanan@apple.com> | 2016-03-08 18:58:48 +0000 |
commit | bbde9083ad0fa26e38a6d56598c6d877ecf234b2 (patch) | |
tree | 6a974ac3d3102dc334e40a97260e90dfc0aa9b88 /lldb/packages/Python/lldbsuite/test/lldbtest.py | |
parent | 2d5e95c00d84856859f673539b608844cd8a69b2 (diff) | |
download | bcm5719-llvm-bbde9083ad0fa26e38a6d56598c6d877ecf234b2.tar.gz bcm5719-llvm-bbde9083ad0fa26e38a6d56598c6d877ecf234b2.zip |
Made self.expect() errors a little more readable in the testsuite.
self.expect() had two problems:
- If there was a substrs argument, then it overwrote the variable containing
the command to run with the last substr. That meant nonsense command text in
testsuite errors.
- The actual output is not printed, which makes fixing testsuite failures a bit
annoying (you end up having to use the -tv arguments to dotest).
This fixes both of these issues. We could do even better, pretty-printing the
criteria for "correct" output, but this at least makes dealing with errors a bit
better.
llvm-svn: 262950
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/lldbtest.py')
-rw-r--r-- | lldb/packages/Python/lldbsuite/test/lldbtest.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py index ac315fe8155..09287e77de6 100644 --- a/lldb/packages/Python/lldbsuite/test/lldbtest.py +++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py @@ -191,10 +191,11 @@ def COMPLETION_MSG(str_before, str_after): '''A generic message generator for the completion mechanism.''' return "'%s' successfully completes to '%s'" % (str_before, str_after) -def EXP_MSG(str, exe): +def EXP_MSG(str, actual, exe): '''A generic "'%s' returns expected result" message generator if exe. Otherwise, it generates "'%s' matches expected result" message.''' - return "'%s' %s expected result" % (str, 'returns' if exe else 'matches') + + return "'%s' %s expected result, got '%s'" % (str, 'returns' if exe else 'matches', actual.strip()) def SETTING_MSG(setting): '''A generic "Value of setting '%s' is correct" message generator.''' @@ -1808,7 +1809,7 @@ class TestBase(Base): break self.assertTrue(matched if matching else not matched, - msg if msg else EXP_MSG(str, exe)) + msg if msg else EXP_MSG(str, output, exe)) return match_object @@ -1882,10 +1883,10 @@ class TestBase(Base): # Look for sub strings, if specified. keepgoing = matched if matching else not matched if substrs and keepgoing: - for str in substrs: - matched = output.find(str) != -1 + for substr in substrs: + matched = output.find(substr) != -1 with recording(self, trace) as sbuf: - print("%s sub string: %s" % (heading, str), file=sbuf) + print("%s sub string: %s" % (heading, substr), file=sbuf) print("Matched" if matched else "Not matched", file=sbuf) keepgoing = matched if matching else not matched if not keepgoing: @@ -1905,7 +1906,7 @@ class TestBase(Base): break self.assertTrue(matched if matching else not matched, - msg if msg else EXP_MSG(str, exe)) + msg if msg else EXP_MSG(str, output, exe)) def invoke(self, obj, name, trace=False): """Use reflection to call a method dynamically with no argument.""" |