Skip to content

Commit 4c26918

Browse files
authored
Merge pull request #10691 from hzeller/feature-20260619-fix-git-dep
Fix non-hermeticity of formatting/lint tests.
2 parents e845b3c + 7a35271 commit 4c26918

7 files changed

Lines changed: 62 additions & 16 deletions

File tree

BUILD.bazel

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -548,10 +548,14 @@ build_test(
548548
sh_test(
549549
name = "lint_tcl_test",
550550
srcs = ["//bazel:tcl_lint_test.sh"],
551-
args = ["$(rootpath //bazel:tclint)"],
551+
args = [
552+
"$(rootpath //bazel:tclint)",
553+
"$(rootpath @git)",
554+
],
552555
data = [
553556
"tclint.toml",
554557
"//bazel:tclint",
558+
"@git",
555559
],
556560
tags = ["local"],
557561
)
@@ -562,10 +566,14 @@ sh_test(
562566
sh_test(
563567
name = "fmt_tcl_test",
564568
srcs = ["//bazel:tcl_fmt_test.sh"],
565-
args = ["$(rootpath //bazel:tclfmt)"],
569+
args = [
570+
"$(rootpath //bazel:tclfmt)",
571+
"$(rootpath @git)",
572+
],
566573
data = [
567574
"tclint.toml",
568575
"//bazel:tclfmt",
576+
"@git",
569577
],
570578
tags = ["local"],
571579
)
@@ -589,10 +597,14 @@ sh_binary(
589597
sh_test(
590598
name = "lint_bzl_test",
591599
srcs = ["//bazel:bzl_lint_test.sh"],
592-
args = ["$(rootpath @buildifier_prebuilt//:buildifier)"],
600+
args = [
601+
"$(rootpath @buildifier_prebuilt//:buildifier)",
602+
"$(rootpath @git)",
603+
],
593604
data = [
594605
"MODULE.bazel",
595606
"@buildifier_prebuilt//:buildifier",
607+
"@git",
596608
],
597609
tags = ["local"],
598610
)
@@ -603,10 +615,14 @@ sh_test(
603615
sh_test(
604616
name = "fmt_bzl_test",
605617
srcs = ["//bazel:bzl_fmt_test.sh"],
606-
args = ["$(rootpath @buildifier_prebuilt//:buildifier)"],
618+
args = [
619+
"$(rootpath @buildifier_prebuilt//:buildifier)",
620+
"$(rootpath @git)",
621+
],
607622
data = [
608623
"MODULE.bazel",
609624
"@buildifier_prebuilt//:buildifier",
625+
"@git",
610626
],
611627
tags = ["local"],
612628
)

MODULE.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ bazel_dep(name = "boost.utility", version = BOOST_VERSION)
7676
bazel_dep(name = "cudd", version = "3.0.0.bcr.2")
7777
bazel_dep(name = "eigen", version = "3.4.0.bcr.3")
7878
bazel_dep(name = "fmt", version = "11.2.0.bcr.1")
79+
bazel_dep(name = "git", version = "2.54.0")
7980
bazel_dep(name = "googletest", version = "1.17.0.bcr.2")
8081
bazel_dep(name = "openmp", version = "21.1.5.bcr.1")
8182
bazel_dep(name = "or-tools", version = "9.15")

MODULE.bazel.lock

Lines changed: 11 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bazel/bzl_fmt_test.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,26 @@
33
# Copyright (c) 2025-2026, The OpenROAD Authors
44
#
55
# Check that all Bazel files are properly formatted (no lint warnings).
6+
67
set -euo pipefail
7-
TOOL="$(cd "$(dirname "$1")" && pwd)/$(basename "$1")"
8+
9+
TOOL="$(realpath "$1")"
10+
GIT="$(realpath "$2")"
11+
812
# MODULE.bazel must be in the sh_test `data` deps so it appears as a
913
# runfiles symlink pointing at the real workspace. `readlink` (no -f,
1014
# for macOS portability) resolves the absolute path Bazel wrote.
1115
[ -L MODULE.bazel ] || { echo "MODULE.bazel missing from runfiles" >&2; exit 1; }
1216
WORKSPACE="$(dirname "$(readlink MODULE.bazel)")"
1317
cd "$WORKSPACE"
18+
1419
# `-c submodule.recurse=false` keeps git ls-files from descending into
1520
# submodules (src/sta, third-party/abc, third-party/slang-elab and the
1621
# fmt sub-submodule nested in it) — we never want to reformat files
1722
# owned by another repo. The override is needed because CI sets
1823
# submodule.recurse=true globally.
1924
# Explicit -mode=check -lint=off separates format errors from lint warnings,
2025
# and overrides the repo-root .buildifier.json default (mode: fix).
21-
git -c submodule.recurse=false ls-files \
26+
"${GIT}" -c submodule.recurse=false ls-files \
2227
'*.bazel' '*.bzl' '**/BUILD' 'BUILD' '**/WORKSPACE' 'WORKSPACE' -z \
23-
| xargs -0 "$TOOL" -mode=check -lint=off
28+
| xargs -0 "${TOOL}" -mode=check -lint=off

bazel/bzl_lint_test.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,25 @@
33
# Copyright (c) 2025-2026, The OpenROAD Authors
44
#
55
# Lint all Bazel files using buildifier (check-only, with lint warnings).
6+
67
set -euo pipefail
7-
TOOL="$(cd "$(dirname "$1")" && pwd)/$(basename "$1")"
8+
9+
TOOL="$(realpath "$1")"
10+
GIT="$(realpath "$2")"
11+
812
# MODULE.bazel must be in the sh_test `data` deps so it appears as a
913
# runfiles symlink pointing at the real workspace. `readlink` (no -f,
1014
# for macOS portability) resolves the absolute path Bazel wrote.
1115
[ -L MODULE.bazel ] || { echo "MODULE.bazel missing from runfiles" >&2; exit 1; }
1216
WORKSPACE="$(dirname "$(readlink MODULE.bazel)")"
1317
cd "$WORKSPACE"
18+
1419
# `-c submodule.recurse=false` keeps git ls-files from descending into
1520
# submodules (src/sta, third-party/abc, third-party/slang-elab and the
1621
# fmt sub-submodule nested in it) — we never want to reformat files
1722
# owned by another repo. The override is needed because CI sets
1823
# submodule.recurse=true globally.
1924
# Explicit -mode=check overrides the repo-root .buildifier.json default.
20-
git -c submodule.recurse=false ls-files \
25+
"${GIT}" -c submodule.recurse=false ls-files \
2126
'*.bazel' '*.bzl' '**/BUILD' 'BUILD' '**/WORKSPACE' 'WORKSPACE' -z \
22-
| xargs -0 "$TOOL" -mode=check -lint=warn
27+
| xargs -0 "${TOOL}" -mode=check -lint=warn

bazel/tcl_fmt_test.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,13 @@
33
# Copyright (c) 2025-2025, The OpenROAD Authors
44
#
55
# Check that all TCL files are properly formatted.
6+
67
set -euo pipefail
7-
TOOL="$(cd "$(dirname "$1")" && pwd)/$(basename "$1")"
8+
9+
TOOL="$(realpath "$1")"
10+
GIT="$(realpath "$2")"
11+
812
WORKSPACE="$(dirname "$(readlink -f tclint.toml)")"
913
cd "$WORKSPACE"
10-
git ls-files '*.tcl' '*.sdc' '*.upf' -z | xargs -0 "$TOOL" --check
14+
15+
"${GIT}" ls-files '*.tcl' '*.sdc' '*.upf' -z | xargs -0 "${TOOL}" --check

bazel/tcl_lint_test.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,13 @@
33
# Copyright (c) 2025-2025, The OpenROAD Authors
44
#
55
# Lint all TCL files using tclint.
6+
67
set -euo pipefail
7-
TOOL="$(cd "$(dirname "$1")" && pwd)/$(basename "$1")"
8+
9+
TOOL="$(realpath "$1")"
10+
GIT="$(realpath "$2")"
11+
812
WORKSPACE="$(dirname "$(readlink -f tclint.toml)")"
913
cd "$WORKSPACE"
10-
git ls-files '*.tcl' '*.sdc' '*.upf' -z | xargs -0 "$TOOL"
14+
15+
"${GIT}" ls-files '*.tcl' '*.sdc' '*.upf' -z | xargs -0 "${TOOL}"

0 commit comments

Comments
 (0)