Skip to content

Commit

Permalink
Add repository_utils_test.bzl (#846)
Browse files Browse the repository at this point in the history
* Add repository_utils_test.bzl

* Add produce_tool_path tests

* Buildifier
  • Loading branch information
hlopko committed Jul 20, 2021
1 parent e10ab21 commit 19acfd8
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
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,
)

0 comments on commit 19acfd8

Please sign in to comment.