Skip to content

Commit 28be57c

Browse files
authored
Fix test module for Bazel 8 (#410)
Clean up canonical label usages and fix runfiles references for `--nolegacy_external_runfiles`.
1 parent d81dda3 commit 28be57c

File tree

7 files changed

+25
-19
lines changed

7 files changed

+25
-19
lines changed

.bazelignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
tests

.github/workflows/tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ jobs:
2828
fail-fast: false
2929
matrix:
3030
os: [macos-latest, ubuntu-latest]
31+
# TODO: Test with Bazel 8 after https://github.com/bazelbuild/bazel/pull/24154 has been released.
3132
bazel_version: [7.0.0, latest] # Minimum supported Bazel version is 7.0.0.
3233
bzlmod: [true, false]
3334
runs-on: ${{ matrix.os }}

tests/.bazelrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
common --incompatible_disallow_empty_glob
2+
common --nolegacy_external_runfiles
23
build --features=layering_check

tests/BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ sh_test(
120120
name = "file_dependency_test",
121121
srcs = ["file_dependency_test.sh"],
122122
args = [
123-
"$(execpath @llvm_toolchain_llvm//:bin/clang-format)",
123+
"$(rootpath @llvm_toolchain_llvm//:bin/clang-format)",
124124
"$(rootpaths @llvm_toolchain_llvm//:lib)",
125125
],
126126
data = [
@@ -136,7 +136,7 @@ toolchain(
136136
"@platforms//cpu:arm64",
137137
"@platforms//os:macos",
138138
],
139-
toolchain = "@@rules_foreign_cc~~tools~ninja_1.11.1_mac//:ninja_tool",
139+
toolchain = "@ninja_mac//:ninja_tool",
140140
toolchain_type = "@rules_foreign_cc//toolchains:ninja_toolchain",
141141
)
142142

tests/MODULE.bazel

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ bazel_dep(name = "rules_foreign_cc", version = "0.12.0")
2929
bazel_dep(name = "abseil-cpp", version = "20240722.0", repo_name = "com_google_absl")
3030

3131
# As a workaround for https://github.com/bazelbuild/rules_foreign_cc/issues/1018.
32+
rules_foreign_cc_tools = use_extension("@rules_foreign_cc//foreign_cc:extensions.bzl", "tools")
33+
use_repo(rules_foreign_cc_tools, ninja_mac = "ninja_1.12.1_mac")
3234
register_toolchains(
3335
"//:ninja_mac_arm64_toolchain",
3436
)
@@ -162,7 +164,7 @@ llvm.toolchain_root(
162164
llvm.sysroot(
163165
name = "llvm_toolchain_with_sysroot",
164166
targets = ["linux-x86_64"],
165-
label = "@@org_chromium_sysroot_linux_x64//:sysroot",
167+
label = "@org_chromium_sysroot_linux_x64//:sysroot",
166168
)
167169
use_repo(llvm, "llvm_toolchain_with_sysroot")
168170

@@ -216,3 +218,18 @@ wasi_sdk_sysroots(name = "wasi_sdk_sysroots")
216218

217219
libclang_rt_wasm32 = use_repo_rule("//wasm:wasi_sdk.bzl", "libclang_rt_wasm32")
218220
libclang_rt_wasm32(name = "libclang_rt_wasm32")
221+
222+
http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
223+
# This sysroot is used by github.com/vsco/bazel-toolchains.
224+
http_archive(
225+
name = "org_chromium_sysroot_linux_x64",
226+
build_file_content = """
227+
filegroup(
228+
name = "sysroot",
229+
srcs = glob(["*/**"]),
230+
visibility = ["//visibility:public"],
231+
)
232+
""",
233+
sha256 = "84656a6df544ecef62169cfe3ab6e41bb4346a62d3ba2a045dc5a0a2ecea94a3",
234+
urls = ["https://commondatastorage.googleapis.com/chrome-linux-sysroot/toolchain/2202c161310ffde63729f29d27fe7bb24a0bc540/debian_stretch_amd64_sysroot.tar.xz"],
235+
)

tests/WORKSPACE.bzlmod

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,6 @@ workspace(name = "toolchains_llvm_tests")
22

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

5-
# This sysroot is used by github.com/vsco/bazel-toolchains.
6-
http_archive(
7-
name = "org_chromium_sysroot_linux_x64",
8-
build_file_content = """
9-
filegroup(
10-
name = "sysroot",
11-
srcs = glob(["*/**"]),
12-
visibility = ["//visibility:public"],
13-
)
14-
""",
15-
sha256 = "84656a6df544ecef62169cfe3ab6e41bb4346a62d3ba2a045dc5a0a2ecea94a3",
16-
urls = ["https://commondatastorage.googleapis.com/chrome-linux-sysroot/toolchain/2202c161310ffde63729f29d27fe7bb24a0bc540/debian_stretch_amd64_sysroot.tar.xz"],
17-
)
18-
195
# Well known repos; present here only for testing.
206

217
http_archive(

tests/file_dependency_test.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ fail() {
2121
clang_format_path=$1
2222
libcpp_path=$2
2323

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

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

3030
echo "SUCCESS!"

0 commit comments

Comments
 (0)