Skip to content

Commit

Permalink
Bump to Bazel 8.0.0rc6, fix //third_party tests
Browse files Browse the repository at this point in the history
Fixes `{strict_deps,unused_dependency_checker}_test` from
`//third_party/dependency_analyzer/src/test` by updating `$(location)`
to `$(rootpath)`. Part of bazelbuild#1652.

`//third_party/dependency_analyzer/src/test:strict_deps_test` and
`//third_party/dependency_analyzer/src/test:unused_dependency_checker_test`
both failed with errors of the form:

```txt
StrictDepsTest:
- error on indirect dependency target *** FAILED *** (379 milliseconds)
  nice errors on sequence of strings.this.infos.exists(nice errors on
  sequence of strings.this.checkErrorContainsMessage(target)) was false
  expected an error on //commons:Target to appear in errors (with
  buildozer command)!
  Errors: List(object apache is not a member of package org)
  (StrictDepsTest.scala:85)
```

This happened both under `WORKSPACE` and Bzlmod.

These targets both depend on
`@org_apache_commons_commons_lang_3_5_without_file//:linkable_org_apache_commons_commons_lang_3_5_without_file`.
The `@org_apache_commons_commons_lang_3_5_without_file` repo is now
instantiated by `dev_deps_repositories()` from
`scala/private/extensions/dev_deps.bzl`. These tests pass on Bazel 6 and
7.

I added code to the "error on indirect dependency target" test case
from `third_party/dependency_analyzer/src/test/io/bazel/rulesscala/
dependencyanalyzer/StrictDepsTest.scala` to see the result of
`compileWithDependencyAnalyzer()`:

```diff
diff --git a/third_party/dependency_analyzer/src/test/io/bazel/rulesscala/dependencyanalyzer/StrictDepsTest.scala b/third_party/dependency_analyzer/src/test/io/bazel/rulesscala/dependencyanalyzer/StrictDepsTest.scala
index b26ba5e5..76b19e90 100644
--- a/third_party/dependency_analyzer/src/test/io/bazel/rulesscala/dependencyanalyzer/StrictDepsTest.scala
+++ b/third_party/dependency_analyzer/src/test/io/bazel/rulesscala/dependencyanalyzer/StrictDepsTest.scala
@@ -37,7 +37,9 @@ class StrictDepsTest extends AnyFunSuite {
     val commonsTarget = "//commons:Target"

     val indirect = List(apacheCommonsClasspath -> commonsTarget)
-    compileWithDependencyAnalyzer(testCode, withIndirect = indirect).expectErrorOn(commonsTarget)
+    val errors = compileWithDependencyAnalyzer(testCode, withIndirect = indirect)
+    System.out.println(errors)
+    errors.expectErrorOn(commonsTarget)
   }

   test("error on multiple indirect dependency targets") {
```

Under Bazel 7.4.1, the test passed and shows this output:

```txt
$ bazel test --test_output=streamed \
  //third_party/dependency_analyzer/src/test:strict_deps_test

[ ...snip... ]
StrictDepsTest:
List(Target '//commons:Target' is used but isn't explicitly declared, please add it to the deps.
You can use the following buildozer command:
buildozer 'add deps //commons:Target' //...)
```

Under Bazel 8.0.0rc6, it failed and showed this:

```txt
$ bazel test --test_output=streamed \
  //third_party/dependency_analyzer/src/test:strict_deps_test

[ ...snip... ]
StrictDepsTest:
List(object apache is not a member of package org)
```
  • Loading branch information
mbland committed Dec 10, 2024
1 parent 61e7502 commit 941df7d
Show file tree
Hide file tree
Showing 16 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.4.1
8.0.0rc6
2 changes: 1 addition & 1 deletion dt_patches/compiler_sources/.bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.4.1
8.0.0rc6
2 changes: 1 addition & 1 deletion dt_patches/test_dt_patches/.bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.4.1
8.0.0rc6
2 changes: 1 addition & 1 deletion dt_patches/test_dt_patches_user_srcjar/.bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.4.1
8.0.0rc6
2 changes: 1 addition & 1 deletion examples/crossbuild/.bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.4.1
8.0.0rc6
2 changes: 1 addition & 1 deletion examples/scala3/.bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.4.1
8.0.0rc6
2 changes: 1 addition & 1 deletion examples/semanticdb/.bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.4.1
8.0.0rc6
2 changes: 1 addition & 1 deletion examples/testing/multi_frameworks_toolchain/.bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.4.1
8.0.0rc6
2 changes: 1 addition & 1 deletion examples/testing/scalatest_repositories/.bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.4.1
8.0.0rc6
2 changes: 1 addition & 1 deletion examples/testing/specs2_junit_repositories/.bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.4.1
8.0.0rc6
2 changes: 1 addition & 1 deletion test/proto_cross_repo_boundary/repo/.bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.4.1
8.0.0rc6
2 changes: 1 addition & 1 deletion test_cross_build/.bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.4.1
8.0.0rc6
4 changes: 2 additions & 2 deletions third_party/dependency_analyzer/src/test/analyzer_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def tests():
],
jvm_flags = common_jvm_flags + [
"-Dguava.jar.location=$(rootpath @com_google_guava_guava_21_0_with_file//jar)",
"-Dapache.commons.jar.location=$(location @org_apache_commons_commons_lang_3_5_without_file//:linkable_org_apache_commons_commons_lang_3_5_without_file)",
"-Dapache.commons.jar.location=$(rootpath @org_apache_commons_commons_lang_3_5_without_file//:linkable_org_apache_commons_commons_lang_3_5_without_file)",
],
unused_dependency_checker_mode = "off",
deps = scala_std_dependencies + [
Expand All @@ -80,7 +80,7 @@ def tests():
"io/bazel/rulesscala/dependencyanalyzer/UnusedDependencyCheckerTest.scala",
],
jvm_flags = common_jvm_flags + [
"-Dapache.commons.jar.location=$(location @org_apache_commons_commons_lang_3_5_without_file//:linkable_org_apache_commons_commons_lang_3_5_without_file)",
"-Dapache.commons.jar.location=$(rootpath @org_apache_commons_commons_lang_3_5_without_file//:linkable_org_apache_commons_commons_lang_3_5_without_file)",
],
unused_dependency_checker_mode = "off",
deps = scala_std_dependencies + [
Expand Down
2 changes: 1 addition & 1 deletion third_party/test/example_external_workspace/.bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.4.1
8.0.0rc6
2 changes: 1 addition & 1 deletion third_party/test/new_local_repo/.bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.4.1
8.0.0rc6
2 changes: 1 addition & 1 deletion third_party/test/proto/.bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.4.1
8.0.0rc6

0 comments on commit 941df7d

Please sign in to comment.