Skip to content

Commit

Permalink
Try using Bazel's command_log instead of piping
Browse files Browse the repository at this point in the history
  • Loading branch information
jjudd committed Nov 12, 2024
1 parent ceb2b1d commit 02620c4
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 9 deletions.
4 changes: 3 additions & 1 deletion tests/compile/log_level/test
Original file line number Diff line number Diff line change
@@ -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}"
4 changes: 2 additions & 2 deletions tests/dependencies/unused/test
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 4 additions & 2 deletions tests/plugins/classpath/test
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
#!/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
# 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}"
4 changes: 3 additions & 1 deletion tests/resources/prefix/test
Original file line number Diff line number Diff line change
@@ -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}"
4 changes: 3 additions & 1 deletion tests/worker-error/test
Original file line number Diff line number Diff line change
@@ -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}"
6 changes: 4 additions & 2 deletions tests/worker-verbosity/test
Original file line number Diff line number Diff line change
@@ -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}"

0 comments on commit 02620c4

Please sign in to comment.