summaryrefslogtreecommitdiffstats
path: root/lldb/test/Shell/ScriptInterpreter/Lua
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2020-01-10 10:21:15 -0800
committerJonas Devlieghere <jonas@devlieghere.com>2020-01-10 10:22:30 -0800
commit572b9f468ad6844795fec29a7e671ba64d82e8c2 (patch)
treeb4a42d7b487a422ffbfed2cdc76df5543587f051 /lldb/test/Shell/ScriptInterpreter/Lua
parentef239972614cc3c67006f9c298fcfa841818dc77 (diff)
downloadbcm5719-llvm-572b9f468ad6844795fec29a7e671ba64d82e8c2.tar.gz
bcm5719-llvm-572b9f468ad6844795fec29a7e671ba64d82e8c2.zip
[lldb/Lua] Support loading Lua modules
Implements the command script import command for Lua. Differential revision: https://reviews.llvm.org/D71825
Diffstat (limited to 'lldb/test/Shell/ScriptInterpreter/Lua')
-rw-r--r--lldb/test/Shell/ScriptInterpreter/Lua/Inputs/testmodule.lua7
-rw-r--r--lldb/test/Shell/ScriptInterpreter/Lua/command_script_import.test13
2 files changed, 20 insertions, 0 deletions
diff --git a/lldb/test/Shell/ScriptInterpreter/Lua/Inputs/testmodule.lua b/lldb/test/Shell/ScriptInterpreter/Lua/Inputs/testmodule.lua
new file mode 100644
index 00000000000..fcf4eb05bd2
--- /dev/null
+++ b/lldb/test/Shell/ScriptInterpreter/Lua/Inputs/testmodule.lua
@@ -0,0 +1,7 @@
+local mymodule = {}
+
+function mymodule.foo()
+ print("Hello World!")
+end
+
+return mymodule
diff --git a/lldb/test/Shell/ScriptInterpreter/Lua/command_script_import.test b/lldb/test/Shell/ScriptInterpreter/Lua/command_script_import.test
new file mode 100644
index 00000000000..6a0692d33ef
--- /dev/null
+++ b/lldb/test/Shell/ScriptInterpreter/Lua/command_script_import.test
@@ -0,0 +1,13 @@
+# REQUIRES: lua
+# RUN: %lldb --script-language lua -o 'command script import %S/Inputs/testmodule.lua' -o 'script testmodule.foo()' 2>&1 | FileCheck %s
+# CHECK: Hello World!
+
+# RUN: mkdir -p %t
+# RUN: cp %S/Inputs/testmodule.lua %t/testmodule.notlua
+# RUN: %lldb --script-language lua -o 'command script import %t/testmodule.notlua' -o 'script testmodule.foo()' 2>&1 | FileCheck %s --check-prefix EXTENSION
+# EXTENSION: error: module importing failed: lua failed to import '{{.*}}testmodule.notlua': invalid extension
+# EXTENSION-NOT: Hello World!
+
+# RUN: %lldb --script-language lua -o 'command script import %S/Inputs/bogus' -o 'script testmodule.foo()' 2>&1 | FileCheck %s --check-prefix NONEXISTING
+# NONEXISTING: error: module importing failed: lua failed to import '{{.*}}bogus': invalid path
+# NONEXISTING-NOT: Hello World!
OpenPOWER on IntegriCloud