a) adds a new --synchronicity (-s) setting for "command script add" that allows the user to decide if scripted commands should run synchronously or asynchronously (which can make a difference in how events are handled) b) clears up several error messages c) adds a new --allow-reload (-r) setting for "command script import" that allows the user to reload a module even if it has already been imported before d) allows filename completion for "command script import" (much like what happens for "target create") e) prevents "command script add" from replacing built-in commands with scripted commands f) changes AddUserCommand() to take an std::string instead of a const char* (for performance reasons) plus, it fixes an issue in "type summary add" command handling which caused several test suite errors llvm-svn: 144035
73 lines
2.8 KiB
Python
73 lines
2.8 KiB
Python
"""Test custom import command to import files by path."""
|
|
|
|
import os, sys, time
|
|
import unittest2
|
|
import lldb
|
|
from lldbtest import *
|
|
|
|
class ImportTestCase(TestBase):
|
|
|
|
mydir = os.path.join("functionalities", "command_script", "import")
|
|
|
|
@python_api_test
|
|
def test_import_command(self):
|
|
"""Import some Python scripts by path and test them"""
|
|
self.run_test()
|
|
|
|
def setUp(self):
|
|
# Call super's setUp().
|
|
TestBase.setUp(self)
|
|
|
|
def run_test(self):
|
|
"""Import some Python scripts by path and test them."""
|
|
|
|
# This is the function to remove the custom commands in order to have a
|
|
# clean slate for the next test case.
|
|
def cleanup():
|
|
self.runCmd('command script delete foo2cmd', check=False)
|
|
self.runCmd('command script delete foocmd', check=False)
|
|
self.runCmd('command script delete foobarcmd', check=False)
|
|
self.runCmd('command script delete barcmd', check=False)
|
|
self.runCmd('command script delete barothercmd', check=False)
|
|
|
|
# Execute the cleanup function during test case tear down.
|
|
self.addTearDownHook(cleanup)
|
|
|
|
self.runCmd("command script import ./foo/foo.py")
|
|
self.runCmd("command script import ./foo/foo2.py")
|
|
self.runCmd("command script import ./foo/bar/foobar.py")
|
|
self.runCmd("command script import ./bar/bar.py")
|
|
|
|
self.expect("command script import ./nosuchfile.py",
|
|
error=True, startstr='error: module importing failed')
|
|
self.expect("command script import ./nosuchfolder/",
|
|
error=True, startstr='error: module importing failed')
|
|
self.expect("command script import ./foo/foo.py",
|
|
error=True, startstr='error: module importing failed')
|
|
|
|
self.runCmd("script import dummymodule")
|
|
self.expect("command script import ./dummymodule.py",
|
|
error=True, startstr='error: module importing failed')
|
|
self.runCmd("command script import --allow-reload ./dummymodule.py")
|
|
|
|
self.runCmd("command script add -f foo.foo_function foocmd")
|
|
self.runCmd("command script add -f foobar.foo_function foobarcmd")
|
|
self.runCmd("command script add -f bar.bar_function barcmd")
|
|
self.expect("foocmd hello",
|
|
substrs = ['foo says', 'hello'])
|
|
self.expect("foo2cmd hello",
|
|
substrs = ['foo2 says', 'hello'])
|
|
self.expect("barcmd hello",
|
|
substrs = ['barutil says', 'bar told me', 'hello'])
|
|
self.expect("barothercmd hello",
|
|
substrs = ['barutil says', 'bar told me', 'hello'])
|
|
self.expect("foobarcmd hello",
|
|
substrs = ['foobar says', 'hello'])
|
|
|
|
|
|
if __name__ == '__main__':
|
|
import atexit
|
|
lldb.SBDebugger.Initialize()
|
|
atexit.register(lambda: lldb.SBDebugger.Terminate())
|
|
unittest2.main()
|