1"""Tests for `load_arbitrary_tool`"""
2
3load("//rust:repositories.bzl", "load_arbitrary_tool")
4load("//rust/platform:triple.bzl", "get_host_triple")
5load("//rust/platform:triple_mappings.bzl", "system_to_binary_ext")
6
7def _load_arbitrary_tool_test_impl(repository_ctx):
8    host_triple = get_host_triple(repository_ctx)
9    cargo_bin = "bin/cargo" + system_to_binary_ext(host_triple.system)
10
11    # Download cargo
12    load_arbitrary_tool(
13        ctx = repository_ctx,
14        tool_name = "cargo",
15        tool_subdirectories = ["cargo"],
16        version = "1.53.0",
17        iso_date = None,
18        target_triple = host_triple,
19    )
20
21    repo_path = repository_ctx.path(".")
22    repository_ctx.file(
23        "{}/BUILD.bazel".format(repo_path),
24        content = "exports_files([\"{}\"])".format(cargo_bin),
25    )
26
27_load_arbitrary_tool_test = repository_rule(
28    implementation = _load_arbitrary_tool_test_impl,
29    doc = (
30        "A test repository rule ensuring `load_arbitrary_tool` functions " +
31        "without requiring any attributes on a repository rule"
32    ),
33)
34
35def load_arbitrary_tool_test():
36    """Define the a test repository for ensuring `load_arbitrary_tool` has no attribute requirements"""
37    _load_arbitrary_tool_test(
38        name = "rules_rust_test_load_arbitrary_tool",
39    )
40    return [struct(repo = "rules_rust_test_load_arbitrary_tool", is_dev_dep = True)]
41