Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add repository_utils_test.bzl #846

Merged
merged 5 commits into from
Jul 20, 2021
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
4 changes: 4 additions & 0 deletions test/unit/repository_utils/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
load(":repository_utils_test.bzl", "repository_utils_test_suite")

############################ UNIT TESTS #############################
repository_utils_test_suite(name = "repository_utils_test_suite")
52 changes: 52 additions & 0 deletions test/unit/repository_utils/repository_utils_test.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
"""Unit tests for repository_utils.bzl."""

load("@bazel_skylib//lib:unittest.bzl", "asserts", "unittest")

# buildifier: disable=bzl-visibility
load("//rust/private:repository_utils.bzl", "produce_tool_path", "produce_tool_suburl")

def _produce_tool_suburl_test_impl(ctx):
env = unittest.begin(ctx)
asserts.equals(
env,
"2020-05-22/rust-std-nightly-x86_64-unknown-linux-gnu",
produce_tool_suburl(
iso_date = "2020-05-22",
tool_name = "rust-std",
version = "nightly",
target_triple = "x86_64-unknown-linux-gnu",
),
)
asserts.equals(
env,
"rust-std-nightly-x86_64-unknown-linux-gnu",
produce_tool_suburl(
tool_name = "rust-std",
version = "nightly",
target_triple = "x86_64-unknown-linux-gnu",
),
)
return unittest.end(env)

def _produce_tool_path_test_impl(ctx):
env = unittest.begin(ctx)
asserts.equals(
env,
"rust-std-nightly-x86_64-unknown-linux-gnu",
produce_tool_path(
tool_name = "rust-std",
version = "nightly",
target_triple = "x86_64-unknown-linux-gnu",
),
)
return unittest.end(env)

produce_tool_suburl_test = unittest.make(_produce_tool_suburl_test_impl)
produce_tool_path_test = unittest.make(_produce_tool_path_test_impl)

def repository_utils_test_suite(name):
unittest.suite(
name,
produce_tool_suburl_test,
produce_tool_path_test,
)