Skip to content

Commit d71446d

Browse files
authored
Merge pull request #10249 from oharboe/fix-lint
bazel: fix bzl lint tests and surface suppressed external-path warnings
2 parents d6fd6df + 288a1ac commit d71446d

4 files changed

Lines changed: 14 additions & 5 deletions

File tree

BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,7 @@ sh_binary(
573573
"$(rootpath @buildifier_prebuilt//:buildifier)",
574574
],
575575
data = [
576+
"MODULE.bazel",
576577
"tclint.toml",
577578
"//bazel:bzl_lint_test.sh",
578579
"//bazel:bzl_tidy.sh",

bazel/bison.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def correct_bison_env_for_action(env, bison):
2929

3030
bison_env["BISON_PKGDATADIR"] = bison_env["BISON_PKGDATADIR"].replace(
3131
bison_runfiles_dir,
32-
"external/{}".format(bison.owner.workspace_name),
32+
"external/{}".format(bison.owner.workspace_name), # buildifier: disable=external-path
3333
)
3434
bison_env["M4"] = bison_env["M4"].replace(
3535
bison_runfiles_dir,

bazel/bzl_fmt_test.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@
44
#
55
# Check that all Bazel files are properly formatted (no lint warnings).
66
set -euo pipefail
7-
TOOL="$(readlink -f "$1")"
8-
WORKSPACE="$(dirname "$(readlink -f MODULE.bazel)")"
7+
TOOL="$(cd "$(dirname "$1")" && pwd)/$(basename "$1")"
8+
# MODULE.bazel must be in the sh_test `data` deps so it appears as a
9+
# runfiles symlink pointing at the real workspace. `readlink` (no -f,
10+
# for macOS portability) resolves the absolute path Bazel wrote.
11+
[ -L MODULE.bazel ] || { echo "MODULE.bazel missing from runfiles" >&2; exit 1; }
12+
WORKSPACE="$(dirname "$(readlink MODULE.bazel)")"
913
cd "$WORKSPACE"
1014
# `git ls-files` skips submodule contents (src/sta, third-party/abc).
1115
# Explicit -mode=check -lint=off separates format errors from lint warnings,

bazel/bzl_lint_test.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@
44
#
55
# Lint all Bazel files using buildifier (check-only, with lint warnings).
66
set -euo pipefail
7-
TOOL="$(readlink -f "$1")"
8-
WORKSPACE="$(dirname "$(readlink -f MODULE.bazel)")"
7+
TOOL="$(cd "$(dirname "$1")" && pwd)/$(basename "$1")"
8+
# MODULE.bazel must be in the sh_test `data` deps so it appears as a
9+
# runfiles symlink pointing at the real workspace. `readlink` (no -f,
10+
# for macOS portability) resolves the absolute path Bazel wrote.
11+
[ -L MODULE.bazel ] || { echo "MODULE.bazel missing from runfiles" >&2; exit 1; }
12+
WORKSPACE="$(dirname "$(readlink MODULE.bazel)")"
913
cd "$WORKSPACE"
1014
# `git ls-files` skips submodule contents (src/sta, third-party/abc), so
1115
# we never try to reformat files owned by another repo.

0 commit comments

Comments
 (0)