Skip to content

Commit

Permalink
Updated clippy failure test to use bzlmod
Browse files Browse the repository at this point in the history
  • Loading branch information
UebelAndre committed Dec 21, 2024
1 parent 7e504a5 commit a368920
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ tasks:
name: Negative Clippy Tests
platform: ubuntu2004
run_targets:
- "//test/clippy:clippy_failure_test"
- "//test/clippy:clippy_failure_tester"
rustfmt_failure:
name: Negative Rustfmt Tests
platform: ubuntu2004
Expand Down
6 changes: 2 additions & 4 deletions test/clippy/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ load(
)
load("@rules_shell//shell:sh_binary.bzl", "sh_binary")

package(default_visibility = ["//test:__subpackages__"])

# Declaration of passing targets.

rust_binary(
Expand Down Expand Up @@ -167,6 +165,6 @@ rust_clippy(
)

sh_binary(
name = "clippy_failure_test",
srcs = ["clippy_failure_test.sh"],
name = "clippy_failure_tester",
srcs = ["clippy_failure_tester.sh"],
)
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,32 @@ function test_all() {

mkdir -p "${NEW_WORKSPACE}/test/clippy" && \
cp -r test/clippy/* "${NEW_WORKSPACE}/test/clippy/" && \
cat << EOF > "${NEW_WORKSPACE}/WORKSPACE.bazel"
workspace(name = "rules_rust_test_clippy")
local_repository(
name = "rules_rust",
cat << EOF > "${NEW_WORKSPACE}/MODULE.bazel"
module(name = "rules_rust_test_clippy")
bazel_dep(name = "rules_rust", version = "0.0.0")
local_path_override(
module_name = "rules_rust",
path = "${BUILD_WORKSPACE_DIRECTORY}",
)
load("@rules_rust//rust:repositories.bzl", "rust_repositories")
rust_repositories()
bazel_dep(
name = "bazel_skylib",
version = "1.7.1",
)
bazel_dep(
name = "rules_shell",
version = "0.3.0",
)
rust = use_extension("@rules_rust//rust:extensions.bzl", "rust")
use_repo(rust, "rust_toolchains")
register_toolchains("@rust_toolchains//:all")
EOF

if [[ -f "${BUILD_WORKSPACE_DIRECTORY}/.bazelversion" ]]; then
cp "${BUILD_WORKSPACE_DIRECTORY}/.bazelversion" "${NEW_WORKSPACE}/.bazelversion"
fi

# Drop the 'noclippy' tags
if [ "$(uname)" == "Darwin" ]; then
SEDOPTS=(-i '' -e)
Expand Down

0 comments on commit a368920

Please sign in to comment.