Skip to content

Commit ed5b902

Browse files
committed
Updated clippy failure test to use bzlmod
1 parent 76d77cb commit ed5b902

File tree

3 files changed

+26
-10
lines changed

3 files changed

+26
-10
lines changed

.bazelci/presubmit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ tasks:
397397
name: Negative Clippy Tests
398398
platform: ubuntu2004
399399
run_targets:
400-
- "//test/clippy:clippy_failure_test"
400+
- "//test/clippy:clippy_failure_tester"
401401
rustfmt_failure:
402402
name: Negative Rustfmt Tests
403403
platform: ubuntu2004

test/clippy/BUILD.bazel

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ load(
1010
)
1111
load("@rules_shell//shell:sh_binary.bzl", "sh_binary")
1212

13-
package(default_visibility = ["//test:__subpackages__"])
13+
package(default_visibility = ["//test/unit/clippy:__pkg__"])
1414

1515
# Declaration of passing targets.
1616

@@ -167,6 +167,6 @@ rust_clippy(
167167
)
168168

169169
sh_binary(
170-
name = "clippy_failure_test",
171-
srcs = ["clippy_failure_test.sh"],
170+
name = "clippy_failure_tester",
171+
srcs = ["clippy_failure_tester.sh"],
172172
)

test/clippy/clippy_failure_test.sh renamed to test/clippy/clippy_failure_tester.sh

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,32 @@ function test_all() {
6161

6262
mkdir -p "${NEW_WORKSPACE}/test/clippy" && \
6363
cp -r test/clippy/* "${NEW_WORKSPACE}/test/clippy/" && \
64-
cat << EOF > "${NEW_WORKSPACE}/WORKSPACE.bazel"
65-
workspace(name = "rules_rust_test_clippy")
66-
local_repository(
67-
name = "rules_rust",
64+
cat << EOF > "${NEW_WORKSPACE}/MODULE.bazel"
65+
module(name = "rules_rust_test_clippy")
66+
bazel_dep(name = "rules_rust", version = "0.0.0")
67+
local_path_override(
68+
module_name = "rules_rust",
6869
path = "${BUILD_WORKSPACE_DIRECTORY}",
6970
)
70-
load("@rules_rust//rust:repositories.bzl", "rust_repositories")
71-
rust_repositories()
71+
72+
bazel_dep(
73+
name = "bazel_skylib",
74+
version = "1.7.1",
75+
)
76+
bazel_dep(
77+
name = "rules_shell",
78+
version = "0.3.0",
79+
)
80+
81+
rust = use_extension("@rules_rust//rust:extensions.bzl", "rust")
82+
use_repo(rust, "rust_toolchains")
83+
register_toolchains("@rust_toolchains//:all")
7284
EOF
7385

86+
if [[ -f "${BUILD_WORKSPACE_DIRECTORY}/.bazelversion" ]]; then
87+
cp "${BUILD_WORKSPACE_DIRECTORY}/.bazelversion" "${NEW_WORKSPACE}/.bazelversion"
88+
fi
89+
7490
# Drop the 'noclippy' tags
7591
if [ "$(uname)" == "Darwin" ]; then
7692
SEDOPTS=(-i '' -e)

0 commit comments

Comments
 (0)