Thanks to visit codestin.com
Credit goes to github.com

Skip to content

test: Use JQ_BIN in sh_test#37

Merged
alexeagle merged 3 commits intobazel-contrib:mainfrom
hofbi:jq-bin-in-sh-test
Oct 14, 2025
Merged

test: Use JQ_BIN in sh_test#37
alexeagle merged 3 commits intobazel-contrib:mainfrom
hofbi:jq-bin-in-sh-test

Conversation

@hofbi
Copy link
Contributor

@hofbi hofbi commented Oct 10, 2025

For now just a reproducer, but we can make this is proper test one I know how to do it

@aspect-workflows
Copy link

aspect-workflows bot commented Oct 10, 2025

Test (Bazel 7.x) (Test)

All tests were cache hits

12 tests (100.0%) were fully cached saving 708ms.


Test (Bazel 8.x) (Test)

1 test target passed

Targets
//jq/tests:check_stamped [k8-fastbuild] 77ms

Total test execution time was 77ms. 11 tests (91.7%) were fully cached saving 607ms.


Test (Bazel 9.x) (Test)

1 test target passed

Targets
//jq/tests:check_stamped [k8-fastbuild] 128ms

Total test execution time was 128ms. 11 tests (91.7%) were fully cached saving 636ms.


Test (Bazel 7.x) (Test)

e2e/smoke

1 test target passed

Targets
//:jq_bin_test [k8-fastbuild]57ms

Total test execution time was 57ms. 1 test (50.0%) was fully cached saving 38ms.


Test (Bazel 8.x) (Test)

e2e/smoke

1 test target passed

Targets
//:jq_bin_test [k8-fastbuild]           86ms

Total test execution time was 86ms. 1 test (50.0%) was fully cached saving 28ms.


Test (Bazel 9.x) (Test)

e2e/smoke

1 test target passed

Targets
//:jq_bin_test [k8-fastbuild]           102ms

Total test execution time was 102ms. 1 test (50.0%) was fully cached saving 24ms.

@hofbi hofbi force-pushed the jq-bin-in-sh-test branch from 4b3afcd to 40889d2 Compare October 10, 2025 12:13
@alexeagle
Copy link
Contributor

alexeagle@aspect-build smoke % git diff
diff --git a/e2e/smoke/BUILD b/e2e/smoke/BUILD
index 5668f66..9630801 100644
--- a/e2e/smoke/BUILD
+++ b/e2e/smoke/BUILD
@@ -24,5 +24,7 @@ sh_test(
     name = "jq_bin_test",
     srcs = ["tests/jq_bin.sh"],
     env = {"JQ_BIN": "$(JQ_BIN)"},
+    deps = ["@bazel_tools//tools/bash/runfiles"],
+    data = ["@jq_toolchains//:resolved_toolchain"],
     toolchains = ["@jq_toolchains//:resolved_toolchain"],
 )
diff --git a/e2e/smoke/tests/jq_bin.sh b/e2e/smoke/tests/jq_bin.sh
index 9e26992..bee9252 100755
--- a/e2e/smoke/tests/jq_bin.sh
+++ b/e2e/smoke/tests/jq_bin.sh
@@ -1,3 +1,13 @@
 #!/usr/bin/env bash
+# --- begin runfiles.bash initialization v3 ---
+# Copy-pasted from the Bazel Bash runfiles library v3.
+set -uo pipefail; set +e; f=bazel_tools/tools/bash/runfiles/runfiles.bash
+source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \
+  source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \
+  source "$0.runfiles/$f" 2>/dev/null || \
+  source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \
+  source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \
+  { echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e
+# --- end runfiles.bash initialization v3 ---
 
-echo "${JQ_BIN}"
+$(rlocation "${JQ_BIN#external/}") --version

is the solution

@hofbi hofbi changed the title Use JQ_BIN in sh_test test: Use JQ_BIN in sh_test Oct 14, 2025
@hofbi hofbi marked this pull request as ready for review October 14, 2025 20:25
@alexeagle alexeagle merged commit 2e6ddd0 into bazel-contrib:main Oct 14, 2025
7 of 8 checks passed
@hofbi hofbi deleted the jq-bin-in-sh-test branch October 14, 2025 20:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants