8000 Update bazel tests to work with implicitly added runtimes deps · coderabbit-test/bazel@2f401c2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2f401c2

Browse files
Googlercopybara-github
authored andcommitted
Update bazel tests to work with implicitly added runtimes deps
PiperOrigin-RevId: 746028984 Change-Id: I3323f7ca81f9e27e8759b75fa8802e7d5d447c09
1 parent a3e26ed commit 2f401c2

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

src/main/starlark/tests/builtins_bzl/cc/cc_shared_library/test/starlark_tests.bzl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,14 @@ def _linking_order_test_impl(env, target):
5454
break
5555

5656
args = target_action.argv
57-
user_libs = [paths.basename(arg) for arg in args if arg.endswith(".o")]
57+
58+
# Exclude implicitly added runtimes libraries by restricting to objects
59+
# in or under the current package.
60+
user_libs = [
61+
paths.basename(arg)
62+
for arg in args
63+
if arg.endswith(".o") and env.ctx.label.package in arg
64+
]
5865

5966
env.expect.that_collection(user_libs).contains_at_least_predicates([
6067
matching.contains("foo.pic.o"),

src/test/shell/integration/exec_group_test.sh

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,18 @@ EOF
432432
bazel build --extra_execution_platforms="${pkg}:my_platform" ${pkg}:a --execution_log_json_file out.txt || fail "Build failed"
433433
grep "platform_key" out.txt || fail "Did not find the platform key"
434434
grep "override_value" out.txt || fail "Did not find the overriding value"
435-
grep "default_value" out.txt && fail "Used the default value"
435+
# If we could do json parsing, we would check that override_value is used for
436+
# the cc_test and default_value is used for all other targets.
437+
# Instead, just check that the number of grep matches is the same.
438+
assert_equals \
439+
"$(grep -c override_valu F1DA e out.txt)" \
440+
"$(grep -c "targetLabel.*${pkg}:a" out.txt)" \
441+
"Used override_value the wrong number of times"
442+
# Note: `grep -c` should not fail if there are no matches.
443+
assert_equals \
444+
"$(grep -c default_value out.txt || true)" \
445+
"$(grep targetLabel out.txt | (grep -cv "${pkg}:a" || true))" \
446+
"Used default_value the wrong number of times"
436447

437448
bazel test --extra_execution_platforms="${pkg}:my_platform" ${pkg}:a --execution_log_json_file out.txt || fail "Test failed"
438449
grep "platform_key" out.txt || fail "Did not find the platform key"
@@ -510,7 +521,18 @@ EOF
510521
bazel build --extra_execution_platforms="${pkg}:my_platform" ${pkg}:a --execution_log_json_file out.txt || fail "Build failed"
511522
grep "platform_key" out.txt || fail "Did not find the platform key"
512523
grep "override_value" out.txt || fail "Did not find the overriding value"
513-
grep "default_value" out.txt && fail "Used the default value"
524+
# If we could do json parsing, we would check that override_value is used for
525+
# the cc_test and default_value is used for all other targets.
526+
# Instead, just check that the number of grep matches is the same.
527+
assert_equals \
528+
"$(grep -c override_value out.txt)" \
529+
"$(grep -c "targetLabel.*${pkg}:a" out.txt)" \
530+
"Used override_value the wrong number of times"
531+
# Note: `grep -c` should not fail if there are no matches.
532+
assert_equals \
533+
"$(grep -c default_value out.txt || true)" \
534+
"$(grep targetLabel out.txt | (grep -cv "${pkg}:a" || true))" \
535+
"Used default_value the wrong number of times"
514536

515537
bazel test --extra_execution_platforms="${pkg}:my_platform" ${pkg}:a --execution_log_json_file out.txt || fail "Test failed"
516538
grep "platform_key" out.txt || fail "Did not find the platform key"

0 commit comments

Comments
 (0)
0