[Lldb-commits] [lldb] r181472 - Test case added for importing packages
Enrico Granata
egranata at apple.com
Wed May 8 14:26:37 PDT 2013
Author: enrico
Date: Wed May 8 16:26:37 2013
New Revision: 181472
URL: http://llvm.org/viewvc/llvm-project?rev=181472&view=rev
Log:
Test case added for importing packages
Added:
lldb/trunk/test/functionalities/command_script/import/thepackage/
lldb/trunk/test/functionalities/command_script/import/thepackage/TPunitA.py
lldb/trunk/test/functionalities/command_script/import/thepackage/TPunitB.py
lldb/trunk/test/functionalities/command_script/import/thepackage/__init__.py
Modified:
lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp
lldb/trunk/test/functionalities/command_script/import/TestImport.py
Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=181472&r1=181471&r2=181472&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original)
+++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Wed May 8 16:26:37 2013
@@ -2602,13 +2602,8 @@ ScriptInterpreterPython::LoadScriptingMo
Locker::AcquireLock | (init_session ? Locker::InitSession : 0),
Locker::FreeAcquiredLock | (init_session ? Locker::TearDownSession : 0));
- if (target_file.GetFileType() == FileSpec::eFileTypeDirectory)
- {
- // for directories, just import
- basename = pathname;
- }
- else if (target_file.GetFileType() == FileSpec::eFileTypeInvalid ||
- target_file.GetFileType() == FileSpec::eFileTypeUnknown)
+ if (target_file.GetFileType() == FileSpec::eFileTypeInvalid ||
+ target_file.GetFileType() == FileSpec::eFileTypeUnknown)
{
// if not a valid file of any sort, check if it might be a filename still
// dot can't be used but / and \ can, and if either is found, reject
@@ -2619,7 +2614,9 @@ ScriptInterpreterPython::LoadScriptingMo
}
basename = pathname; // not a filename, probably a package of some sort, let it go through
}
- else
+ else if (target_file.GetFileType() == FileSpec::eFileTypeDirectory ||
+ target_file.GetFileType() == FileSpec::eFileTypeRegular ||
+ target_file.GetFileType() == FileSpec::eFileTypeSymbolicLink)
{
const char* directory = target_file.GetDirectory().GetCString();
@@ -2645,6 +2642,11 @@ ScriptInterpreterPython::LoadScriptingMo
basename.resize(basename.length()-4);
}
}
+ else
+ {
+ error.SetErrorString("no known way to import this module specification");
+ return false;
+ }
// check if the module is already import-ed
command_stream.Clear();
Modified: lldb/trunk/test/functionalities/command_script/import/TestImport.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/command_script/import/TestImport.py?rev=181472&r1=181471&r2=181472&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/command_script/import/TestImport.py (original)
+++ lldb/trunk/test/functionalities/command_script/import/TestImport.py Wed May 8 16:26:37 2013
@@ -30,6 +30,8 @@ class ImportTestCase(TestBase):
self.runCmd('command script delete foobarcmd', check=False)
self.runCmd('command script delete barcmd', check=False)
self.runCmd('command script delete barothercmd', check=False)
+ self.runCmd('command script delete TPcommandA', check=False)
+ self.runCmd('command script delete TPcommandB', check=False)
# Execute the cleanup function during test case tear down.
self.addTearDownHook(cleanup)
@@ -46,6 +48,10 @@ class ImportTestCase(TestBase):
self.expect("command script import ./foo/foo.py",
error=True, startstr='error: module importing failed')
+ self.runCmd("command script import --allow-reload ./thepackage")
+ self.expect("TPcommandA",substrs=["hello world A"])
+ self.expect("TPcommandB",substrs=["hello world B"])
+
self.runCmd("script import dummymodule")
self.expect("command script import ./dummymodule.py",
error=True, startstr='error: module importing failed')
Added: lldb/trunk/test/functionalities/command_script/import/thepackage/TPunitA.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/command_script/import/thepackage/TPunitA.py?rev=181472&view=auto
==============================================================================
--- lldb/trunk/test/functionalities/command_script/import/thepackage/TPunitA.py (added)
+++ lldb/trunk/test/functionalities/command_script/import/thepackage/TPunitA.py Wed May 8 16:26:37 2013
@@ -0,0 +1,3 @@
+def command(debugger, command, result, internal_dict):
+ result.PutCString(u"hello world A")
+ return None
Added: lldb/trunk/test/functionalities/command_script/import/thepackage/TPunitB.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/command_script/import/thepackage/TPunitB.py?rev=181472&view=auto
==============================================================================
--- lldb/trunk/test/functionalities/command_script/import/thepackage/TPunitB.py (added)
+++ lldb/trunk/test/functionalities/command_script/import/thepackage/TPunitB.py Wed May 8 16:26:37 2013
@@ -0,0 +1,3 @@
+def command(debugger, command, result, internal_dict):
+ result.PutCString(u"hello world B")
+ return None
Added: lldb/trunk/test/functionalities/command_script/import/thepackage/__init__.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/command_script/import/thepackage/__init__.py?rev=181472&view=auto
==============================================================================
--- lldb/trunk/test/functionalities/command_script/import/thepackage/__init__.py (added)
+++ lldb/trunk/test/functionalities/command_script/import/thepackage/__init__.py Wed May 8 16:26:37 2013
@@ -0,0 +1,6 @@
+import TPunitA
+import TPunitB
+
+def __lldb_init_module(debugger,*args):
+ debugger.HandleCommand("command script add -f thepackage.TPunitA.command TPcommandA")
+ debugger.HandleCommand("command script add -f thepackage.TPunitB.command TPcommandB")
More information about the lldb-commits
mailing list