From 02620c417cf8d3df9de0b2d8240e0d88b729f035 Mon Sep 17 00:00:00 2001 From: jjudd Date: Tue, 12 Nov 2024 14:20:54 -0700 Subject: [PATCH] Try using Bazel's command_log instead of piping --- tests/compile/log_level/test | 4 +++- tests/dependencies/unused/test | 4 ++-- tests/plugins/classpath/test | 6 ++++-- tests/resources/prefix/test | 4 +++- tests/worker-error/test | 4 +++- tests/worker-verbosity/test | 6 ++++-- 6 files changed, 19 insertions(+), 9 deletions(-) diff --git a/tests/compile/log_level/test b/tests/compile/log_level/test index 1fc8397fe..64115adf0 100755 --- a/tests/compile/log_level/test +++ b/tests/compile/log_level/test @@ -1,9 +1,11 @@ #!/bin/bash -e . "$(dirname "$0")"/../../common.sh +command_log="$(bazel info command_log)" + # We use nouse_action_cache + bazel shutdown here in order to prevent the skyframe # cache and the persistent action cache from being used and thus getting the # warning we want printed, printed. The alternative is to bazel clean, which # takes much longer. bazel shutdown -bazel build :lib --nouse_action_cache |& grep "compiling 1 Scala source" +bazel build :lib --nouse_action_cache && grep "compiling 1 Scala source" "${command_log}" diff --git a/tests/dependencies/unused/test b/tests/dependencies/unused/test index 2ba2b76f3..1f455ba1b 100755 --- a/tests/dependencies/unused/test +++ b/tests/dependencies/unused/test @@ -5,9 +5,9 @@ command_log="$(bazel info command_log)" bazel build :0_used ! bazel build :0_unused || false -bazel build :0_unused && grep "buildozer 'remove deps @annex_test//:org_scalacheck_scalacheck_2_13' //dependencies/unused:0_unused" "${command_log}" +! bazel build :0_unused && grep "buildozer 'remove deps @annex_test//:org_scalacheck_scalacheck_2_13' //dependencies/unused:0_unused" "${command_log}" bazel build :0_unused_whitelist bazel build :indirect_unused ! bazel build :indirect_unused_missing || false -bazel build :indirect_unused_missing && grep "buildozer 'add deps @annex_test//:org_specs2_specs2_matcher_2_13' //dependencies/unused:indirect_unused_missing" "${command_log}" +! bazel build :indirect_unused_missing && grep "buildozer 'add deps @annex_test//:org_specs2_specs2_matcher_2_13' //dependencies/unused:indirect_unused_missing" "${command_log}" bazel build :indirect_unused_whitelist diff --git a/tests/plugins/classpath/test b/tests/plugins/classpath/test index 7b7b5eb7a..36bc03022 100755 --- a/tests/plugins/classpath/test +++ b/tests/plugins/classpath/test @@ -1,6 +1,8 @@ #!/bin/bash -e . "$(dirname "$0")"/../../common.sh +command_log="$(bazel info command_log)" + # We use nouse_action_cache + bazel shutdown here in order to prevent the skyframe # cache and the persistent action cache from being used and thus getting the # warning we want printed, printed. The alternative is to bazel clean, which @@ -8,9 +10,9 @@ bazel shutdown # Using a worker here prevents a println this tests needs from making it # to the command line, so we use standalone instead. -bazel build :inefficient-usage --strategy=ScalaCompile=standalone --nouse_action_cache |& \ +bazel build :inefficient-usage --strategy=ScalaCompile=standalone --nouse_action_cache && \ awk ' BEGIN {z = 2} /slightly inefficient/ {z -= 1} /scalac plugin phase success/ {z -= 1} - END {exit z}' + END {exit z}' "${command_log}" diff --git a/tests/resources/prefix/test b/tests/resources/prefix/test index ccff72bec..82a6cd3af 100755 --- a/tests/resources/prefix/test +++ b/tests/resources/prefix/test @@ -1,10 +1,12 @@ #!/bin/bash -e . "$(dirname "$0")"/../../common.sh +command_log="$(bazel info command_log)" + bazel build :prefix diff <(sort expected) <( zipinfo -m -T --h-t "$(bazel info bazel-bin)/resources/prefix/prefix.jar" | sort ) ! bazel build :outside -bazel build :outside |& grep 'does not have prefix' +! bazel build :outside && grep 'does not have prefix' "${command_log}" diff --git a/tests/worker-error/test b/tests/worker-error/test index 1ce3c9aff..88193f9ae 100755 --- a/tests/worker-error/test +++ b/tests/worker-error/test @@ -1,5 +1,7 @@ #!/bin/bash -e . "$(dirname "$0")"/../common.sh +command_log="$(bazel info command_log)" + bazel test :error-spec -bazel test :fatal-error-spec |& grep -q 'java.lang.OutOfMemoryError' +! bazel test :fatal-error-spec && grep -q 'java.lang.OutOfMemoryError' "${command_log}" diff --git a/tests/worker-verbosity/test b/tests/worker-verbosity/test index 7ecf1c748..90a11de5d 100755 --- a/tests/worker-verbosity/test +++ b/tests/worker-verbosity/test @@ -1,12 +1,14 @@ #!/bin/bash -e . "$(dirname "$0")"/../common.sh +command_log="$(bazel info command_log)" + # We use modify_execution_info, nouse_action_cache, and bazel shutdown here # in order to prevent the disk cache, skyframe cache, and persistent action cache # from being used for the verbosity spec worker actions and thus getting the # verbosity we want getting printed. The alternative is to bazel clean, which # takes much longer. bazel shutdown -bazel build --modify_execution_info="VerbositySpecWorkerRun=+no-cache" --nouse_action_cache :verbosity-spec-target |& grep -q "Verbosity: 0" +bazel build --modify_execution_info="VerbositySpecWorkerRun=+no-cache" --nouse_action_cache :verbosity-spec-target && grep -q "Verbosity: 0" "${command_log}" bazel shutdown -bazel build --modify_execution_info="VerbositySpecWorkerRun=+no-cache" --nouse_action_cache --worker_verbose :verbosity-spec-target |& grep -q "Verbosity: 10" +bazel build --modify_execution_info="VerbositySpecWorkerRun=+no-cache" --nouse_action_cache --worker_verbose :verbosity-spec-target && grep -q "Verbosity: 10" "${command_log}"