diff options
| author | Enrico Granata <egranata@apple.com> | 2012-10-31 00:01:26 +0000 |
|---|---|---|
| committer | Enrico Granata <egranata@apple.com> | 2012-10-31 00:01:26 +0000 |
| commit | 085577f8d0d2f60e3a6b4e4c22d8022d2988e221 (patch) | |
| tree | 44d426e1096cf395e9bef22e8758f76734886297 /lldb/test/functionalities/command_script/import | |
| parent | c280746b8cad81c09da2fbf45f7db75fea2d82ac (diff) | |
| download | bcm5719-llvm-085577f8d0d2f60e3a6b4e4c22d8022d2988e221.tar.gz bcm5719-llvm-085577f8d0d2f60e3a6b4e4c22d8022d2988e221.zip | |
<rdar://problem/12586188> Make ImportError a special case for "command script import", such that the error message for the exception becomes the error for the entire import operation
and silence the backtrace printout
In the process, refactor the Execute* commands in ScriptInterpreter to take an options object, and add a new setting to not mask out errors so that the callers can handle them directly
instead of having the default behavior
llvm-svn: 167067
Diffstat (limited to 'lldb/test/functionalities/command_script/import')
4 files changed, 44 insertions, 0 deletions
diff --git a/lldb/test/functionalities/command_script/import/rdar-12586188/Makefile b/lldb/test/functionalities/command_script/import/rdar-12586188/Makefile new file mode 100644 index 00000000000..7913aaa4b74 --- /dev/null +++ b/lldb/test/functionalities/command_script/import/rdar-12586188/Makefile @@ -0,0 +1,3 @@ +LEVEL = ../../../../make + +include $(LEVEL)/Makefile.rules diff --git a/lldb/test/functionalities/command_script/import/rdar-12586188/TestRdar12586188.py b/lldb/test/functionalities/command_script/import/rdar-12586188/TestRdar12586188.py new file mode 100644 index 00000000000..6e79bb2b577 --- /dev/null +++ b/lldb/test/functionalities/command_script/import/rdar-12586188/TestRdar12586188.py @@ -0,0 +1,33 @@ +"""Check that we handle an ImportError in a special way when command script importing files.""" + +import os, sys, time +import unittest2 +import lldb +from lldbtest import * + +class Rdar12586188TestCase(TestBase): + + mydir = os.path.join("functionalities", "command_script", "import", "rdar-12586188") + + @python_api_test + def test_rdar12586188_command(self): + """Check that we handle an ImportError in a special way when command script importing files.""" + self.run_test() + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + + def run_test(self): + """Check that we handle an ImportError in a special way when command script importing files.""" + + self.expect("command script import ./fail12586188.py --allow-reload", + error=True, substrs = ['error: module importing failed: I do not want to be imported']) + self.expect("command script import ./fail212586188.py --allow-reload", + error=True, substrs = ['error: module importing failed: Python raised an error while importing module']) + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() diff --git a/lldb/test/functionalities/command_script/import/rdar-12586188/fail12586188.py b/lldb/test/functionalities/command_script/import/rdar-12586188/fail12586188.py new file mode 100644 index 00000000000..add85a73f85 --- /dev/null +++ b/lldb/test/functionalities/command_script/import/rdar-12586188/fail12586188.py @@ -0,0 +1,4 @@ +def f(x): + return x + 1 + +raise ImportError("I do not want to be imported") diff --git a/lldb/test/functionalities/command_script/import/rdar-12586188/fail212586188.py b/lldb/test/functionalities/command_script/import/rdar-12586188/fail212586188.py new file mode 100644 index 00000000000..1549a036590 --- /dev/null +++ b/lldb/test/functionalities/command_script/import/rdar-12586188/fail212586188.py @@ -0,0 +1,4 @@ +def f(x): + return x + 1 + +raise ValueError("I do not want to be imported") |

