Fix bazel_skylib with Bazel@HEAD (#538)

This commit is contained in:
Yun Peng 2024-09-11 17:16:25 +02:00 committed by GitHub
parent 5c071b5006
commit 01244de9b0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 27 additions and 7 deletions

View File

@ -112,7 +112,21 @@ local_repository(
path = "../ext2", path = "../ext2",
) )
eof eof
cat >"$ws/main/MODULE.bazel" <<'eof'
local_repository = use_repo_rule("@bazel_tools//tools/build_defs/repo:local.bzl", "local_repository")
local_repository(
name = "bzl",
path = "../bzl",
)
local_repository(
name = "ext1",
path = "../ext1",
)
local_repository(
name = "ext2",
path = "../ext2",
)
eof
# @ext1 has source files # @ext1 has source files
touch "$ws/ext1/WORKSPACE" touch "$ws/ext1/WORKSPACE"
echo 'exports_files(["foo.txt"])' >"$ws/ext1/foo/BUILD" echo 'exports_files(["foo.txt"])' >"$ws/ext1/foo/BUILD"
@ -181,17 +195,17 @@ eof
(cd "$ws/main" && \ (cd "$ws/main" && \
bazel test ${flags} //:different1 --test_output=errors 1>"$TEST_log" 2>&1 \ bazel test ${flags} //:different1 --test_output=errors 1>"$TEST_log" 2>&1 \
&& fail "expected failure" || true) && fail "expected failure" || true)
expect_log 'FAIL: files "external/ext1/foo/foo.txt" and "external/ext2/foo/bar.txt" differ' expect_log 'FAIL: files "external/.*ext1/foo/foo.txt" and "external/.*ext2/foo/bar.txt" differ'
(cd "$ws/main" && \ (cd "$ws/main" && \
bazel test ${flags} //:different2 --test_output=errors 1>"$TEST_log" 2>&1 \ bazel test ${flags} //:different2 --test_output=errors 1>"$TEST_log" 2>&1 \
&& fail "expected failure" || true) && fail "expected failure" || true)
expect_log 'FAIL: files "external/ext1/foo/foo.txt" and "ext1/foo/foo.txt" differ' expect_log 'FAIL: files "external/.*ext1/foo/foo.txt" and "ext1/foo/foo.txt" differ'
(cd "$ws/main" && \ (cd "$ws/main" && \
bazel test ${flags} //:different3 --test_output=errors 1>"$TEST_log" 2>&1 \ bazel test ${flags} //:different3 --test_output=errors 1>"$TEST_log" 2>&1 \
&& fail "expected failure" || true) && fail "expected failure" || true)
expect_log 'FAIL: files "ext2/foo/foo.txt" and "external/ext2/foo/foo.txt" differ' expect_log 'FAIL: files "ext2/foo/foo.txt" and "external/.*ext2/foo/foo.txt" differ'
} }
function test_simple_diff_test_with_legacy_external_runfiles() { function test_simple_diff_test_with_legacy_external_runfiles() {

View File

@ -49,13 +49,19 @@ function create_pkg() {
local -r pkg="$1" local -r pkg="$1"
mkdir -p "$pkg" mkdir -p "$pkg"
cd "$pkg" cd "$pkg"
cat > WORKSPACE <<EOF cat > WORKSPACE <<EOF
workspace(name = 'bazel_skylib') workspace(name = 'bazel_skylib')
load("//lib:unittest.bzl", "register_unittest_toolchains") load("//lib:unittest.bzl", "register_unittest_toolchains")
register_unittest_toolchains() register_unittest_toolchains()
EOF
touch WORKSPACE.bzlmod
cat > MODULE.bazel <<EOF
module(name="bazel_skylib_test", repo_name="bazel_skylib")
bazel_dep(name = "platforms", version = "0.0.10")
register_toolchains(
"//toolchains/unittest:cmd_toolchain",
"//toolchains/unittest:bash_toolchain",
)
EOF EOF
# Copy relevant skylib sources into the current workspace. # Copy relevant skylib sources into the current workspace.