Skip to content

Commit d1142be

Browse files
committed
add depset characterization tests
1 parent 507985b commit d1142be

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

tests/venv_site_packages_libs/BUILD.bazel

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
load("//python:py_library.bzl", "py_library")
22
load("//tests/support:py_reconfig.bzl", "py_reconfig_test")
33
load("//tests/support:support.bzl", "SUPPORTS_BOOTSTRAP_SCRIPT")
4+
load(":depset_tests.bzl", "depset_test_suite")
5+
6+
depset_test_suite(
7+
name = "depset_tests",
8+
)
49

510
py_library(
611
name = "user_lib",
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
""
2+
3+
load("@rules_testing//lib:test_suite.bzl", "test_suite")
4+
5+
_tests = []
6+
7+
def _test_simple(env):
8+
c1 = depset(
9+
["c1"],
10+
order = "topological",
11+
)
12+
c2 = depset(
13+
["c2"],
14+
order = "topological",
15+
)
16+
b = depset(
17+
["b"],
18+
transitive = [c1],
19+
order = "topological",
20+
)
21+
a1 = depset(
22+
["A"],
23+
transitive = [c2, b],
24+
order = "topological",
25+
)
26+
a2 = depset(
27+
["A"],
28+
transitive = [b, c2],
29+
order = "topological",
30+
)
31+
32+
got1 = a1.to_list()
33+
got2 = a2.to_list()
34+
35+
env.expect.that_collection(got1).contains_exactly(
36+
["A", "c2", "b", "c1"],
37+
).in_order()
38+
env.expect.that_collection(got2).contains_exactly(
39+
["A", "b", "c1", "c2"],
40+
).in_order()
41+
42+
_tests.append(_test_simple)
43+
44+
def depset_test_suite(name):
45+
"""Create the test suite.
46+
47+
Args:
48+
name: the name of the test suite
49+
"""
50+
test_suite(name = name, basic_tests = _tests)

0 commit comments

Comments
 (0)