xref: /llvm-project/lldb/test/Shell/ScriptInterpreter/Python/command_relative_import.test (revision da0b62dfb3ca597f618b1f88226b440bc7ca3960)
1# RUN: rm -rf %t && mkdir -p %t/foo/bar/baz
2# RUN: split-file %S/Inputs/relative.split %t/foo
3# RUN: split-file %S/Inputs/hello.split %t/foo/bar
4# RUN: mv %t/foo/bar/hello.py %t/foo/bar/baz
5# RUN: echo 'command source %t/foo/bar/hello.in' >> %t/foo/zip.in
6
7# RUN: %lldb --script-language python \
8# RUN:    -o 'command source %t/foo/magritte.in' \
9# RUN:    -o 'command source %t/foo/zip.in' \
10# RUN:    -o 'command source %t/foo/magritte.in' \
11# RUN;    -o 'zip' \
12# RUN:    -o 'hello'
13# RUN     -o 'magritte' 2>&1 | FileCheck %s
14
15# The first time importing 'magritte' fails because we didn't pass -c.
16# CHECK: ModuleNotFoundError: No module named 'magritte'
17# CHECK-NOT: Ceci n'est pas une pipe
18# CHECK: 95126
19# CHECK: Hello, World!
20# The second time importing 'magritte' works, even without passing -c because
21# we added '%t/foo' to the Python path when importing 'zip'.
22# CHECK: Ceci n'est pas une pipe
23
24# Cannot use `-o` here because the driver puts the commands in a file and
25# sources them.
26command script import -c %t/foo/magritte.py
27quit
28# RUN: cat %s | %lldb --script-language python 2>&1 | FileCheck %s --check-prefix ERROR
29# ERROR: error: command script import -c can only be specified from a command file
30