Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix test module for Bazel 8 #410

Merged
merged 2 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest]
# TODO: Test with Bazel 8 after https://github.com/bazelbuild/bazel/pull/24154 has been released.
bazel_version: [7.0.0, latest] # Minimum supported Bazel version is 7.0.0.
bzlmod: [true, false]
runs-on: ${{ matrix.os }}
Expand Down
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!"