Skip to content

Commit

Permalink
Allow test_all.sh to pass under Bazel 7
Browse files Browse the repository at this point in the history
`bash ./test_all.sh` passes after minor updates to the following test
cases to handle slightly different behavior under Bazel 7:

- `test_custom_reporter_class_has_been_set` makes the test output dir
  writable, since it no longer is by default.

- `test_scala_import_expect_failure_on_missing_direct_deps_warn_mode`
  removes preexisting output, since Bazel 7 won't emit warnings if it
  already exists.

---

FYI: Under Bazel 7.0 and Bazel 7.1, buildifier warnings for external
targets in the following test cases changed to begin with `@@repo_name`
instead of `@repo_name`:

- test/shell/test_scala_library.sh:
  `test_scala_library_expect_failure_on_missing_direct_external_deps_jar`
  `test_scala_library_expect_failure_on_missing_direct_external_deps_file_group`

- test/shell/test_strict_dependency.sh:
  `test_stamped_target_label_loading`
  `test_strict_deps_filter_included_target`

- test/shell/test_test_unused_dependency.sh:
  `test_unused_deps_filter_included_target`

However, as of Bazel 7.2, those warnings changed back to `@repo_name`,
so those changes aren't reflected in this commit.
  • Loading branch information
mbland committed Oct 6, 2024
1 parent 14d3fa6 commit 7ff6833
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion test/shell/test_custom_reporter_class.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ test_custom_reporter_class_has_been_set() {
bazel test test/scala_test:custom_reporter
set +e
reporter_output_dir="$(bazel info bazel-testlogs)/test/scala_test/custom_reporter/test.outputs"
chmod u+w "$reporter_output_dir" # Needed under Bazel 7
reporter_output_filepath="${reporter_output_dir}/${custom_reporter_check_file}"
unzip -oq "${reporter_output_dir}/outputs.zip" -d "${reporter_output_dir}"
assert_file_exists "${reporter_output_filepath}"
}

$runner test_custom_reporter_class_has_been_set
$runner test_custom_reporter_class_has_been_set
3 changes: 3 additions & 0 deletions test/shell/test_strict_dependency.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ test_scala_import_expect_failure_on_missing_direct_deps_warn_mode() {
dependency_target2='//test_expect_failure/scala_import:guava'
test_target='test_expect_failure/scala_import:scala_import_propagates_compile_deps'

# Bazel 7 won't emit warnings if the output already exists.
rm -f "$(bazel info bazel-bin)/${test_target/://}"*

local expected_message1="buildozer 'add deps $dependency_target1' //$test_target"
local expected_message2="buildozer 'add deps $dependency_target2' //$test_target"

Expand Down

0 comments on commit 7ff6833

Please sign in to comment.