Skip to content

Commit 19acfd8

Browse files
authored
Add repository_utils_test.bzl (#846)
* Add repository_utils_test.bzl * Add produce_tool_path tests * Buildifier
1 parent e10ab21 commit 19acfd8

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
load(":repository_utils_test.bzl", "repository_utils_test_suite")
2+
3+
############################ UNIT TESTS #############################
4+
repository_utils_test_suite(name = "repository_utils_test_suite")
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
"""Unit tests for repository_utils.bzl."""
2+
3+
load("@bazel_skylib//lib:unittest.bzl", "asserts", "unittest")
4+
5+
# buildifier: disable=bzl-visibility
6+
load("//rust/private:repository_utils.bzl", "produce_tool_path", "produce_tool_suburl")
7+
8+
def _produce_tool_suburl_test_impl(ctx):
9+
env = unittest.begin(ctx)
10+
asserts.equals(
11+
env,
12+
"2020-05-22/rust-std-nightly-x86_64-unknown-linux-gnu",
13+
produce_tool_suburl(
14+
iso_date = "2020-05-22",
15+
tool_name = "rust-std",
16+
version = "nightly",
17+
target_triple = "x86_64-unknown-linux-gnu",
18+
),
19+
)
20+
asserts.equals(
21+
env,
22+
"rust-std-nightly-x86_64-unknown-linux-gnu",
23+
produce_tool_suburl(
24+
tool_name = "rust-std",
25+
version = "nightly",
26+
target_triple = "x86_64-unknown-linux-gnu",
27+
),
28+
)
29+
return unittest.end(env)
30+
31+
def _produce_tool_path_test_impl(ctx):
32+
env = unittest.begin(ctx)
33+
asserts.equals(
34+
env,
35+
"rust-std-nightly-x86_64-unknown-linux-gnu",
36+
produce_tool_path(
37+
tool_name = "rust-std",
38+
version = "nightly",
39+
target_triple = "x86_64-unknown-linux-gnu",
40+
),
41+
)
42+
return unittest.end(env)
43+
44+
produce_tool_suburl_test = unittest.make(_produce_tool_suburl_test_impl)
45+
produce_tool_path_test = unittest.make(_produce_tool_path_test_impl)
46+
47+
def repository_utils_test_suite(name):
48+
unittest.suite(
49+
name,
50+
produce_tool_suburl_test,
51+
produce_tool_path_test,
52+
)

0 commit comments

Comments
 (0)