[lldb] Add assertState function to the API test suite
authorJonas Devlieghere <jonas@devlieghere.com>
Wed, 8 Jun 2022 22:57:41 +0000 (15:57 -0700)
committerJonas Devlieghere <jonas@devlieghere.com>
Wed, 8 Jun 2022 23:16:38 +0000 (16:16 -0700)
commitce825e46743be3e402820484bef639d12deefc2a
tree0896b46e420b5ff9ea2d68337da79366e9a82b14
parent5ead1f13a2d8ca33e9e93c06acee941a857905c6
[lldb] Add assertState function to the API test suite

Add a function to make it easier to debug a test failure caused by an
unexpected state.

Currently, tests are using assertEqual which results in a cryptic error
message: "AssertionError: 5 != 10". Even when a test provides a message
to make it clear why a particular state is expected, you still have to
figure out which of the two was the expected state, and what the other
value corresponds to.

We have a function in lldbutil that helps you convert the state number
into a user readable string. This patch adds a wrapper around
assertEqual specifically for comparing states and reporting better error
messages.

The aforementioned error message now looks like this: "AssertionError:
stopped (5) != exited (10)". If the user provided a message, that
continues to get printed as well.

Differential revision: https://reviews.llvm.org/D127355
24 files changed:
lldb/packages/Python/lldbsuite/test/lldbtest.py
lldb/test/API/commands/process/launch-with-shellexpand/TestLaunchWithShellExpand.py
lldb/test/API/commands/watchpoints/step_over_watchpoint/TestStepOverWatchpoint.py
lldb/test/API/functionalities/breakpoint/consecutive_breakpoints/TestConsecutiveBreakpoints.py
lldb/test/API/functionalities/breakpoint/move_nearest/TestMoveNearest.py
lldb/test/API/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py
lldb/test/API/functionalities/completion/TestCompletion.py
lldb/test/API/functionalities/dynamic_value_child_count/TestDynamicValueChildCount.py
lldb/test/API/functionalities/launch_stop_at_entry/TestStopAtEntry.py
lldb/test/API/functionalities/return-value/TestReturnValue.py
lldb/test/API/lang/cpp/dynamic-value/TestDynamicValue.py
lldb/test/API/lang/cpp/gmodules/TestWithModuleDebugging.py
lldb/test/API/lang/objc/ivar-IMP/TestObjCiVarIMP.py
lldb/test/API/lang/objc/objc-baseclass-sbtype/TestObjCBaseClassSBType.py
lldb/test/API/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py
lldb/test/API/lang/objc/objc-property/TestObjCProperty.py
lldb/test/API/linux/add-symbols/TestTargetSymbolsAddCommand.py
lldb/test/API/linux/mix-dwo-and-regular-objects/TestMixedDwarfBinary.py
lldb/test/API/macosx/add-dsym/TestAddDsymDownload.py
lldb/test/API/macosx/add-dsym/TestAddDsymMidExecutionCommand.py
lldb/test/API/python_api/class_members/TestSBTypeClassMembers.py
lldb/test/API/python_api/objc_type/TestObjCType.py
lldb/test/API/python_api/value/change_values/TestChangeValueAPI.py
lldb/test/API/python_api/value/empty_class/TestValueAPIEmptyClass.py