================ @@ -184,53 +184,26 @@ def test_source_locations_from_objc_modules(self): # the first argument are probably stable enough that this test can check for them. self.assertIn("void NSLog(NSString *format", value.GetError().GetCString()) - def test_command_expr_formatting(self): + def test_command_expr_sbdata(self): """Test that the source and caret positions LLDB prints are correct""" self.build() (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint( self, "// Break here", self.main_source_spec ) - frame = thread.GetFrameAtIndex(0) - self.expect("settings set show-inline-diagnostics true") - - def check(input_ref): - self.expect(input_ref[0], error=True, substrs=input_ref[1:]) - - check( - [ - "expression -- a+b", - " ^ ^", - " | error: use of undeclared identifier 'b'", - " error: use of undeclared identifier 'a'", - ] - ) - - check( - [ - "expr -- a", - " ^", - " error: use of undeclared identifier 'a'", - ] - ) - check( - [ - "expr -i 0 -o 0 -- a", - " ^", - " error: use of undeclared identifier 'a'", - ] - ) - - self.expect( - "expression --top-level -- template<typename T> T FOO(T x) { return x/2;}" - ) - check( - [ - 'expression -- FOO("")', - " ^", - " note: in instantiation of function template specialization 'FOO<const char *>' requested here", - "error: <user expression", - "invalid operands to binary expression", - ] - ) - check(["expression --\na\n+\nb", "error: <user", "a", "error: <user", "b"]) + interp = self.dbg.GetCommandInterpreter() + cro = lldb.SBCommandReturnObject() + interp.HandleCommand("expression -- a+b", cro) + diags = cro.GetErrorData() + self.assertEqual(diags.GetValueForKey("version").GetIntegerValue(), 1) + details = diags.GetValueForKey("details") + diag = details.GetItemAtIndex(0) + self.assertEqual(str(diag.GetValueForKey("severity")), "error") + self.assertIn("undeclared identifier 'a'", str(diag.GetValueForKey("message"))) + self.assertIn("user expression", str(diag.GetValueForKey("rendered"))) + sloc = diag.GetValueForKey("source_location") + self.assertIn("user expression", str(sloc.GetValueForKey("file"))) + self.assertFalse(sloc.GetValueForKey("hidden").GetBooleanValue()) + self.assertTrue(sloc.GetValueForKey("in_user_input").GetBooleanValue()) + diag = details.GetItemAtIndex(1) + self.assertIn("undeclared identifier 'b'", str(diag.GetValueForKey("message"))) ---------------- medismailben wrote:
nit: this looks very condensed ... could we add some line returns ? https://github.com/llvm/llvm-project/pull/112109 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits