|
| 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