Skip to content

Commit

Permalink
Fix test module for Bazel 8
Browse files Browse the repository at this point in the history
Clean up canonical label usages and fix runfiles references for `--nolegacy_external_runfiles`.
  • Loading branch information
fmeum committed Oct 31, 2024
1 parent d81dda3 commit 856c5e6
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 19 deletions.
1 change: 1 addition & 0 deletions .bazelignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tests
1 change: 1 addition & 0 deletions tests/.bazelrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
common --incompatible_disallow_empty_glob
common --nolegacy_external_runfiles
build --features=layering_check
4 changes: 2 additions & 2 deletions tests/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ sh_test(
name = "file_dependency_test",
srcs = ["file_dependency_test.sh"],
args = [
"$(execpath @llvm_toolchain_llvm//:bin/clang-format)",
"$(rootpath @llvm_toolchain_llvm//:bin/clang-format)",
"$(rootpaths @llvm_toolchain_llvm//:lib)",
],
data = [
Expand All @@ -136,7 +136,7 @@ toolchain(
"@platforms//cpu:arm64",
"@platforms//os:macos",
],
toolchain = "@@rules_foreign_cc~~tools~ninja_1.11.1_mac//:ninja_tool",
toolchain = "@ninja_mac//:ninja_tool",
toolchain_type = "@rules_foreign_cc//toolchains:ninja_toolchain",
)

Expand Down
19 changes: 18 additions & 1 deletion tests/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ bazel_dep(name = "rules_foreign_cc", version = "0.12.0")
bazel_dep(name = "abseil-cpp", version = "20240722.0", repo_name = "com_google_absl")

# As a workaround for https://github.com/bazelbuild/rules_foreign_cc/issues/1018.
rules_foreign_cc_tools = use_extension("@rules_foreign_cc//foreign_cc:extensions.bzl", "tools")
use_repo(rules_foreign_cc_tools, ninja_mac = "ninja_1.12.1_mac")
register_toolchains(
"//:ninja_mac_arm64_toolchain",
)
Expand Down Expand Up @@ -162,7 +164,7 @@ llvm.toolchain_root(
llvm.sysroot(
name = "llvm_toolchain_with_sysroot",
targets = ["linux-x86_64"],
label = "@@org_chromium_sysroot_linux_x64//:sysroot",
label = "@org_chromium_sysroot_linux_x64//:sysroot",
)
use_repo(llvm, "llvm_toolchain_with_sysroot")

Expand Down Expand Up @@ -216,3 +218,18 @@ wasi_sdk_sysroots(name = "wasi_sdk_sysroots")

libclang_rt_wasm32 = use_repo_rule("//wasm:wasi_sdk.bzl", "libclang_rt_wasm32")
libclang_rt_wasm32(name = "libclang_rt_wasm32")

http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
# This sysroot is used by github.com/vsco/bazel-toolchains.
http_archive(
name = "org_chromium_sysroot_linux_x64",
build_file_content = """
filegroup(
name = "sysroot",
srcs = glob(["*/**"]),
visibility = ["//visibility:public"],
)
""",
sha256 = "84656a6df544ecef62169cfe3ab6e41bb4346a62d3ba2a045dc5a0a2ecea94a3",
urls = ["https://commondatastorage.googleapis.com/chrome-linux-sysroot/toolchain/2202c161310ffde63729f29d27fe7bb24a0bc540/debian_stretch_amd64_sysroot.tar.xz"],
)
14 changes: 0 additions & 14 deletions tests/WORKSPACE.bzlmod
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,6 @@ workspace(name = "toolchains_llvm_tests")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

# This sysroot is used by github.com/vsco/bazel-toolchains.
http_archive(
name = "org_chromium_sysroot_linux_x64",
build_file_content = """
filegroup(
name = "sysroot",
srcs = glob(["*/**"]),
visibility = ["//visibility:public"],
)
""",
sha256 = "84656a6df544ecef62169cfe3ab6e41bb4346a62d3ba2a045dc5a0a2ecea94a3",
urls = ["https://commondatastorage.googleapis.com/chrome-linux-sysroot/toolchain/2202c161310ffde63729f29d27fe7bb24a0bc540/debian_stretch_amd64_sysroot.tar.xz"],
)

# Well known repos; present here only for testing.

http_archive(
Expand Down
4 changes: 2 additions & 2 deletions tests/file_dependency_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ fail() {
clang_format_path=$1
libcpp_path=$2

[[ -e ${clang_format_path} ]] || fail "bin/clang-format not found"
[[ -e ${clang_format_path} ]] || fail "bin/clang-format not found at ${clang_format_path}"

[[ -e ${libcpp_path} ]] ||
compgen -G "${libcpp_path}" >/dev/null ||
fail "libc++.a not found"
fail "libc++.a not found at ${libcpp_path}"

echo "SUCCESS!"

0 comments on commit 856c5e6

Please sign in to comment.