aboutsummaryrefslogtreecommitdiff
path: root/examples/bzlmod/tests/BUILD.bazel
blob: ce7079c56048340adb3c55108a134c34074c4f53 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
load("@python_versions//3.10:defs.bzl", py_binary_3_10 = "py_binary", py_test_3_10 = "py_test")
load("@python_versions//3.11:defs.bzl", py_binary_3_11 = "py_binary", py_test_3_11 = "py_test")
load("@python_versions//3.9:defs.bzl", py_binary_3_9 = "py_binary", py_test_3_9 = "py_test")
load("@rules_python//python:defs.bzl", "py_binary", "py_test")

py_binary(
    name = "version_default",
    srcs = ["version.py"],
    main = "version.py",
)

py_binary_3_9(
    name = "version_3_9",
    srcs = ["version.py"],
    main = "version.py",
)

py_binary_3_10(
    name = "version_3_10",
    srcs = ["version.py"],
    main = "version.py",
)

py_binary_3_11(
    name = "version_3_11",
    srcs = ["version.py"],
    main = "version.py",
)

# This is a work in progress and the commented
# tests will not work  until we can support
# multiple pips with bzlmod.

py_test(
    name = "my_lib_default_test",
    srcs = ["my_lib_test.py"],
    main = "my_lib_test.py",
    deps = ["//libs/my_lib"],
)

py_test_3_9(
    name = "my_lib_3_9_test",
    srcs = ["my_lib_test.py"],
    main = "my_lib_test.py",
    deps = ["//libs/my_lib"],
)

py_test_3_10(
    name = "my_lib_3_10_test",
    srcs = ["my_lib_test.py"],
    main = "my_lib_test.py",
    deps = ["//libs/my_lib"],
)

py_test(
    name = "version_default_test",
    srcs = ["version_test.py"],
    env = {"VERSION_CHECK": "3.9"},  # The default defined in the WORKSPACE.
    main = "version_test.py",
)

py_test_3_9(
    name = "version_3_9_test",
    srcs = ["version_test.py"],
    env = {"VERSION_CHECK": "3.9"},
    main = "version_test.py",
)

py_test_3_10(
    name = "version_3_10_test",
    srcs = ["version_test.py"],
    env = {"VERSION_CHECK": "3.10"},
    main = "version_test.py",
)

py_test_3_11(
    name = "version_3_11_test",
    srcs = ["version_test.py"],
    env = {"VERSION_CHECK": "3.11"},
    main = "version_test.py",
)

py_test(
    name = "version_default_takes_3_10_subprocess_test",
    srcs = ["cross_version_test.py"],
    data = [":version_3_10"],
    env = {
        "SUBPROCESS_VERSION_CHECK": "3.10",
        "SUBPROCESS_VERSION_PY_BINARY": "$(rootpath :version_3_10)",
        "VERSION_CHECK": "3.9",
    },
    main = "cross_version_test.py",
)

py_test_3_10(
    name = "version_3_10_takes_3_9_subprocess_test",
    srcs = ["cross_version_test.py"],
    data = [":version_3_9"],
    env = {
        "SUBPROCESS_VERSION_CHECK": "3.9",
        "SUBPROCESS_VERSION_PY_BINARY": "$(rootpath :version_3_9)",
        "VERSION_CHECK": "3.10",
    },
    main = "cross_version_test.py",
)

sh_test(
    name = "version_test_binary_default",
    srcs = ["version_test.sh"],
    data = [":version_default"],
    env = {
        "VERSION_CHECK": "3.9",  # The default defined in the WORKSPACE.
        "VERSION_PY_BINARY": "$(rootpath :version_default)",
    },
)

sh_test(
    name = "version_test_binary_3_9",
    srcs = ["version_test.sh"],
    data = [":version_3_9"],
    env = {
        "VERSION_CHECK": "3.9",
        "VERSION_PY_BINARY": "$(rootpath :version_3_9)",
    },
)

sh_test(
    name = "version_test_binary_3_10",
    srcs = ["version_test.sh"],
    data = [":version_3_10"],
    env = {
        "VERSION_CHECK": "3.10",
        "VERSION_PY_BINARY": "$(rootpath :version_3_10)",
    },
)