Fix TestCommandScript: return an error if target executable is not set
The test invokes the 'targetname' test command before setting a
target executable, which caused Python to raise TypeError: cannot
concatenate 'str' and 'NoneType' objects.
llvm.org/pr23686
llvm-svn: 238425
diff --git a/lldb/test/functionalities/command_script/welcome.py b/lldb/test/functionalities/command_script/welcome.py
index c6d4ddc..f7e6a7e 100644
--- a/lldb/test/functionalities/command_script/welcome.py
+++ b/lldb/test/functionalities/command_script/welcome.py
@@ -16,11 +16,15 @@
pass
def __call__(self, debugger, args, exe_ctx, result):
- target = debugger.GetSelectedTarget()
- file = target.GetExecutable()
- print >>result, ('Current target ' + file.GetFilename())
if args == 'fail':
result.SetError('a test for error in command')
+ return
+ target = debugger.GetSelectedTarget()
+ file = target.GetExecutable()
+ if file:
+ print >>result, ('Current target ' + file.GetFilename())
+ else:
+ result.SetError('target.GetExecutable() failed')
def get_flags(self):
return lldb.eCommandRequiresTarget