Skip to content

Commit 4a75d01

Browse files
committed
Add test cases
1 parent 6c90153 commit 4a75d01

File tree

30 files changed

+94
-0
lines changed

30 files changed

+94
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# gazelle:python_generate_pyi_srcs true
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test")
2+
3+
# gazelle:python_generate_pyi_srcs true
4+
5+
py_library(
6+
name = "directive_python_generate_pyi_srcs",
7+
srcs = [
8+
"__init__.py",
9+
"bar.py",
10+
"baz.py",
11+
"foo.py",
12+
],
13+
pyi_srcs = [
14+
"baz.pyi",
15+
"foo.pyi",
16+
],
17+
visibility = ["//:__subpackages__"],
18+
)
19+
20+
py_binary(
21+
name = "directive_python_generate_pyi_srcs_bin",
22+
srcs = ["__main__.py"],
23+
main = "__main__.py",
24+
pyi_srcs = ["__main__.pyi"],
25+
visibility = ["//:__subpackages__"],
26+
)
27+
28+
py_test(
29+
name = "directive_python_generate_pyi_srcs_test",
30+
srcs = [
31+
"__test__.py",
32+
"foo_test.py",
33+
],
34+
main = "__test__.py",
35+
pyi_srcs = ["foo_test.pyi"],
36+
)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Directive: python_generate_pyi_srcs
2+
3+
Test that the `python_generate_pyi_srcs` directive will add `pyi_srcs` to
4+
generated targets and that it can be toggled on/off on a per-package basis.
5+
6+
The root of the test case asserts that the default generation mode (package)
7+
will compile multiple .pyi files into a single py_* target.
8+
9+
The `per_file` directory asserts that the `file` generation mode will attach
10+
a single .pyi file to a given target.
11+
12+
Lastly, the `per_file/turn_off` directory asserts that we can turn off the
13+
directive for subpackages. It continues with per-file generation mode.

gazelle/python/testdata/directive_python_generate_pyi_srcs/WORKSPACE

Whitespace-only changes.

gazelle/python/testdata/directive_python_generate_pyi_srcs/__init__.py

Whitespace-only changes.

gazelle/python/testdata/directive_python_generate_pyi_srcs/__main__.py

Whitespace-only changes.

gazelle/python/testdata/directive_python_generate_pyi_srcs/__main__.pyi

Whitespace-only changes.

gazelle/python/testdata/directive_python_generate_pyi_srcs/__test__.py

Whitespace-only changes.

gazelle/python/testdata/directive_python_generate_pyi_srcs/bar.py

Whitespace-only changes.

gazelle/python/testdata/directive_python_generate_pyi_srcs/baz.py

Whitespace-only changes.

0 commit comments

Comments
 (0)