Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions test/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
)
2 changes: 2 additions & 0 deletions test/interpreter_options_repo/.plzconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[Plugin "python"]
Target = //plugins:python
16 changes: 16 additions & 0 deletions test/interpreter_options_repo/BUILD_FILE
Original file line number Diff line number Diff line change
@@ -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"],
)
2 changes: 2 additions & 0 deletions test/interpreter_options_repo/binary.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
if __name__ == "__main__":
print("Executed binary.py")
4 changes: 4 additions & 0 deletions test/interpreter_options_repo/plugins/BUILD_FILE
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
plugin_repo(
name = "python",
revision = "e2e",
)
2 changes: 2 additions & 0 deletions test/interpreter_options_repo/plzmodule.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
if __name__ == "__main__":
print("Executed plzmodule.py")