diff --git a/test/BUILD b/test/BUILD index 216d6e2..108ddae 100644 --- a/test/BUILD +++ b/test/BUILD @@ -202,3 +202,14 @@ python_test( ], labels = ["manual"], ) + +plugin_e2e_test( + name = "interpreter_options_test", + repo = "interpreter_options_repo", + test_cmd = [ + "plz run //:binary > binary", + ], + expected_output = { + "binary": "Executed plzmodule.py", + }, +) diff --git a/test/interpreter_options_repo/.plzconfig b/test/interpreter_options_repo/.plzconfig new file mode 100644 index 0000000..2ffad3a --- /dev/null +++ b/test/interpreter_options_repo/.plzconfig @@ -0,0 +1,2 @@ +[Plugin "python"] +Target = //plugins:python diff --git a/test/interpreter_options_repo/BUILD_FILE b/test/interpreter_options_repo/BUILD_FILE new file mode 100644 index 0000000..94913ca --- /dev/null +++ b/test/interpreter_options_repo/BUILD_FILE @@ -0,0 +1,16 @@ +subinclude("///python//build_defs:python") + +package( + # If InterpreterOptions is being honoured, the Python interpreter should execute plzmodule.py + # as the __main__ module instead of main.py, causing "Executed plzmodule.py" to be printed on + # stdout rather than "Executed binary.py". + python = { + "interpreter_options": ["-m", "plzmodule"], + }, +) + +python_binary( + name = "binary", + main = "binary.py", + srcs = ["plzmodule.py"], +) diff --git a/test/interpreter_options_repo/binary.py b/test/interpreter_options_repo/binary.py new file mode 100644 index 0000000..c16be82 --- /dev/null +++ b/test/interpreter_options_repo/binary.py @@ -0,0 +1,2 @@ +if __name__ == "__main__": + print("Executed binary.py") diff --git a/test/interpreter_options_repo/plugins/BUILD_FILE b/test/interpreter_options_repo/plugins/BUILD_FILE new file mode 100644 index 0000000..bd8b3fd --- /dev/null +++ b/test/interpreter_options_repo/plugins/BUILD_FILE @@ -0,0 +1,4 @@ +plugin_repo( + name = "python", + revision = "e2e", +) diff --git a/test/interpreter_options_repo/plzmodule.py b/test/interpreter_options_repo/plzmodule.py new file mode 100644 index 0000000..4e61a7d --- /dev/null +++ b/test/interpreter_options_repo/plzmodule.py @@ -0,0 +1,2 @@ +if __name__ == "__main__": + print("Executed plzmodule.py")