[all-commits] [llvm/llvm-project] b3a0c4: [lldb] Replace assertTrue(a == b, "msg") with asse...

Raphael Isemann via All-commits all-commits at lists.llvm.org
Thu Feb 13 06:01:21 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: b3a0c4d7dcfa252be17ef5f5b63ffaaa83e01a2b
      https://github.com/llvm/llvm-project/commit/b3a0c4d7dcfa252be17ef5f5b63ffaaa83e01a2b
  Author: Raphael Isemann <teemperor at gmail.com>
  Date:   2020-02-13 (Thu, 13 Feb 2020)

  Changed paths:
    M lldb/test/API/commands/disassemble/basic/TestFrameDisassemble.py
    M lldb/test/API/commands/expression/call-restarts/TestCallThatRestarts.py
    M lldb/test/API/commands/expression/call-throws/TestCallThatThrows.py
    M lldb/test/API/commands/expression/fixits/TestFixIts.py
    M lldb/test/API/commands/expression/issue_11588/Test11588.py
    M lldb/test/API/commands/expression/save_jit_objects/TestSaveJITObjects.py
    M lldb/test/API/commands/expression/test/TestExprs.py
    M lldb/test/API/commands/expression/timeout/TestCallWithTimeout.py
    M lldb/test/API/commands/frame/language/TestGuessLanguage.py
    M lldb/test/API/commands/frame/var/TestFrameVar.py
    M lldb/test/API/commands/process/launch-with-shellexpand/TestLaunchWithShellExpand.py
    M lldb/test/API/commands/register/register/intel_xtended_registers/mpx_bound_violation/TestBoundViolation.py
    M lldb/test/API/commands/watchpoints/step_over_watchpoint/TestStepOverWatchpoint.py
    M lldb/test/API/commands/watchpoints/watchpoint_disable/TestWatchpointDisable.py
    M lldb/test/API/functionalities/breakpoint/address_breakpoints/TestAddressBreakpoints.py
    M lldb/test/API/functionalities/breakpoint/address_breakpoints/TestBadAddressBreakpoints.py
    M lldb/test/API/functionalities/breakpoint/breakpoint_hit_count/TestBreakpointHitCount.py
    M lldb/test/API/functionalities/breakpoint/breakpoint_ids/TestBreakpointIDs.py
    M lldb/test/API/functionalities/breakpoint/breakpoint_locations/TestBreakpointLocations.py
    M lldb/test/API/functionalities/breakpoint/breakpoint_names/TestBreakpointNames.py
    M lldb/test/API/functionalities/breakpoint/consecutive_breakpoints/TestConsecutiveBreakpoints.py
    M lldb/test/API/functionalities/breakpoint/cpp_exception/TestCPPExceptionBreakpoint.py
    M lldb/test/API/functionalities/breakpoint/source_regexp/TestSourceRegexBreakpoints.py
    M lldb/test/API/functionalities/data-formatter/format-propagation/TestFormatPropagation.py
    M lldb/test/API/functionalities/dynamic_value_child_count/TestDynamicValueChildCount.py
    M lldb/test/API/functionalities/memory/cache/TestMemoryCache.py
    M lldb/test/API/functionalities/memory/read/TestMemoryRead.py
    M lldb/test/API/functionalities/mtc/simple/TestMTCSimple.py
    M lldb/test/API/functionalities/plugins/python_os_plugin/TestPythonOSPlugin.py
    M lldb/test/API/functionalities/process_group/TestChangeProcessGroup.py
    M lldb/test/API/functionalities/return-value/TestReturnValue.py
    M lldb/test/API/functionalities/signal/TestSendSignal.py
    M lldb/test/API/functionalities/source-map/TestTargetSourceMap.py
    M lldb/test/API/functionalities/step-avoids-no-debug/TestStepNoDebug.py
    M lldb/test/API/functionalities/tsan/thread_numbers/TestTsanThreadNumbers.py
    M lldb/test/API/functionalities/ubsan/basic/TestUbsanBasic.py
    M lldb/test/API/functionalities/value_md5_crash/TestValueMD5Crash.py
    M lldb/test/API/functionalities/var_path/TestVarPath.py
    M lldb/test/API/lang/c/array_types/TestArrayTypes.py
    M lldb/test/API/lang/cpp/dynamic-value/TestDynamicValue.py
    M lldb/test/API/lang/cpp/exceptions/TestCPPExceptionBreakpoints.py
    M lldb/test/API/lang/cpp/global_variables/TestCPPGlobalVariables.py
    M lldb/test/API/lang/cpp/gmodules/TestWithModuleDebugging.py
    M lldb/test/API/lang/cpp/stl/TestSTL.py
    M lldb/test/API/lang/cpp/template/TestTemplateArgs.py
    M lldb/test/API/lang/objc/global_ptrs/TestGlobalObjects.py
    M lldb/test/API/lang/objc/ivar-IMP/TestObjCiVarIMP.py
    M lldb/test/API/lang/objc/objc-baseclass-sbtype/TestObjCBaseClassSBType.py
    M lldb/test/API/lang/objc/objc-builtin-types/TestObjCBuiltinTypes.py
    M lldb/test/API/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py
    M lldb/test/API/lang/objc/objc-ivar-offsets/TestObjCIvarOffsets.py
    M lldb/test/API/lang/objc/objc-ivar-stripped/TestObjCIvarStripped.py
    M lldb/test/API/lang/objc/objc-property/TestObjCProperty.py
    M lldb/test/API/lang/objc/objc-static-method-stripped/TestObjCStaticMethodStripped.py
    M lldb/test/API/lang/objc/objc-static-method/TestObjCStaticMethod.py
    M lldb/test/API/lang/objc/objc-struct-argument/TestObjCStructArgument.py
    M lldb/test/API/lang/objc/objc-struct-return/TestObjCStructReturn.py
    M lldb/test/API/lang/objc/objc-super/TestObjCSuper.py
    M lldb/test/API/linux/add-symbols/TestTargetSymbolsAddCommand.py
    M lldb/test/API/linux/mix-dwo-and-regular-objects/TestMixedDwarfBinary.py
    M lldb/test/API/macosx/add-dsym/TestAddDsymMidExecutionCommand.py
    M lldb/test/API/macosx/find-app-in-bundle/TestFindAppInBundle.py
    M lldb/test/API/macosx/find-dsym/bundle-with-dot-in-filename/TestBundleWithDotInFilename.py
    M lldb/test/API/macosx/find-dsym/deep-bundle/TestDeepBundle.py
    M lldb/test/API/macosx/thread-names/TestInterruptThreadNames.py
    M lldb/test/API/macosx/universal/TestUniversal.py
    M lldb/test/API/python_api/class_members/TestSBTypeClassMembers.py
    M lldb/test/API/python_api/findvalue_duplist/TestSBFrameFindValue.py
    M lldb/test/API/python_api/name_lookup/TestNameLookup.py
    M lldb/test/API/python_api/objc_type/TestObjCType.py
    M lldb/test/API/python_api/sbvalue_persist/TestSBValuePersist.py
    M lldb/test/API/python_api/value/change_values/TestChangeValueAPI.py
    M lldb/test/API/python_api/value/empty_class/TestValueAPIEmptyClass.py
    M lldb/test/API/tools/lldb-server/TestGdbRemoteThreadsInStopReply.py
    M lldb/test/API/tools/lldb-server/register-reading/TestGdbRemoteGPacket.py
    M lldb/test/API/tools/lldb-vscode/attach/TestVSCode_attach.py
    M lldb/test/API/tools/lldb-vscode/breakpoint/TestVSCode_setBreakpoints.py
    M lldb/test/API/tools/lldb-vscode/breakpoint/TestVSCode_setFunctionBreakpoints.py
    M lldb/test/API/tools/lldb-vscode/launch/TestVSCode_launch.py
    M lldb/test/API/tools/lldb-vscode/stackTrace/TestVSCode_stackTrace.py

  Log Message:
  -----------
  [lldb] Replace assertTrue(a == b, "msg") with assertEquals(a, b, "msg") in the test suite

Summary:
The error message from the construct `assertTrue(a == b, "msg") ` are nearly always completely useless for actually debugging the issue.
This patch is just replacing this construct (and similar ones like `assertTrue(a != b, ...)` with the proper call to assertEqual or assertNotEquals.

This patch was mostly written by a shell script with some manual verification afterwards:
```
lang=python
import sys

def sanitize_line(line):
  if line.strip().startswith("self.assertTrue(") and " == " in line:
    line = line.replace("self.assertTrue(", "self.assertEquals(")
    line = line.replace(" == ", ", ", 1)
  if line.strip().startswith("self.assertTrue(") and " != " in line:
    line = line.replace("self.assertTrue(", "self.assertNotEqual(")
    line = line.replace(" != ", ", ", 1)
  return line

for a in sys.argv[1:]:
  with open(a, "r") as f:
    lines = f.readlines()
  with open(a, "w") as f:
    for line in lines:
      f.write(sanitize_line(line))
```

Reviewers: labath, JDevlieghere

Reviewed By: labath

Subscribers: abidh, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D74475




More information about the All-commits mailing list