My immediate win is that this includes migrating off the old version of bazel-common that includes `google_common_workspace_rules()`: Calling `google_common_workspace_rules()` leads to trouble under macos-latest (as previously in https://github.com/google/guice/commit/17011080a118fc2d23314ccf0d5546ce53e8b650):
```
ERROR: /Users/runner/work/guice/guice/WORKSPACE:26:30: fetching android_sdk_repository rule //external:androidsdk: Android SDK api level 34 was requested but it is not installed in the Android SDK at /Users/runner/Library/Android/sdk. The api levels found were [36, 35]. Please choose an available api level or install api level 34 from the Android SDK Manager.
ERROR: Analysis of target '//tools:osgi_wrapper' failed; build aborted: Android SDK api level 34 was requested but it is not installed in the Android SDK at /Users/runner/Library/Android/sdk. The api levels found were [36, 35]. Please choose an available api level or install api level 34 from the Android SDK Manager.
```
RELNOTES=n/a
PiperOrigin-RevId: 957370304
Truth will soon:
- print only the simple name for some well-known classes (e.g., print "NullPointerException" instead of "java.lang.NullPointerException")
- print the canonical name where available instead of the binary name (e.g., print "com.google.Foo.BarException" instead of "com.google.Foo$BarException"
This CL updates callers to accept both versions.
RELNOTES=n/a
PiperOrigin-RevId: 775721999
This doesn't change any Guice behavior; it just lets nullness checkers (like Kotlin and the Checker Framework) allow you to bind to such providers more easily.
Guice's handling of `null` is not entirely principled, and this CL doesn't attempt to "solve" that, nor does it attempt to thoroughly annotate for nullness, let alone enable a nullness checker for the Guice codebase. Rather, it aims only to remove a restriction that I don't think is serving any particular purpose and that no on "intended"; I think it just kind of happened because the Checker Framework treats unannotated code leniently and strictly at different times, and this happens to be one of the strict cases. (We might also have once had the hope of cracking down on injection of `null`?)
The immediate motivation for this CL is https://github.com/google/inject-common/pull/26: Soon, nullness checkers will know that `Providers.of(null)` returns *gasp* a `Provider` that can return `null`. That makes `bind(Foo.class).to(Providers.of(null))` an error. This CL lets those callers continue to compile.
PiperOrigin-RevId: 734755975
The `Truth8` methods will be deprecated (or hidden) in the future. Callers should move to `Truth`.
Some (but not all) of the CLs in this batch require Truth [1.4.0](https://github.com/google/truth/releases/tag/v1.4.0). I submitted a CL earlier today to (I hope) perform that upgrade for your project.
PiperOrigin-RevId: 604731456
This makes available the rest of the Truth APIs that were recently added in Google's monorepo.
It may be worth also updating to the _following_ version of Truth after it's released, but the purpose of that release will mostly be to deprecate `Truth8`. So, if you just avoid using `Truth8` now (starting by approving any migration CLs that I send your way), then there will be little need for that upgrade. Or, more to the point: I don't expect to keep sending you weekly upgrade CLs after this one :)
PiperOrigin-RevId: 604719853
By "qualify," I mean that, instead of static importing `Truth8.assertThat`, we write "`Truth8.assertThat(...)`" at the call site.
This is normally the opposite of what we recommend. However, it's a necessary step in our migration: We are copying all the `Truth8` methods to `Truth`, and we can't do that if any files static import both `Truth.assertThat` and `Truth8.assertThat` (because it produces a compile error about ambiguous overloads). To unblock that, we're moving callers away from the static import.
We will update static analysis to stop suggesting the import.
A later step will migrate these callers to the new `Truth.assertThat` methods, which we will static import.
The `Truth8` methods will be hidden in the future. All callers will use `Truth`.
PiperOrigin-RevId: 603073706
Renames may include:
- containsAllOf => containsAtLeast
- containsAllIn => containsAtLeastElementsIn
- isSameAs => isSameInstanceAs
- isOrdered => isInOrder
- isStrictlyOrdered => isInStrictOrder
The other major change is to change custom subjects to extend raw Subject instead of supplying type parameters. The type parameters are being removed from Subject. This CL will temporarily produce rawtypes warnings, which will go away when I remove the type parameters (as soon as this batch of CLs is submitted).
Some CLs in this batch also migrate calls away from actualAsString(). Its literal replacement is `"<" + actual + ">"` (unless an object overrides actualCustomStringRepresentation()), but usually I've made a larger change, such as switching from an old-style "Not true that..." failure message to one generated with the Fact API. In that case, the new code usually contains a direct reference to this.actual (a field that I occasionally had to create). Another larger change I sometimes made is to switch from a manual check-and-fail approach to instead use check(...). And sometimes I just remove a withMessage() call that's no longer necessary now that the code uses check(...), or I introduce a check(...) call. (An assertion made with check(...) automatically includes the actual value from the original subject, so there's no need to set it again with withMessage().)
Finally, there's one CL in this batch in which I migrate a Correspondence subclass to instead use Correspondence.from.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=251472122
The overload that accepts a description generally produces better failure messages:
- The first line of the message it produces is something like: "value of: myProto.getResponse()" (where "getResponse()" is taken from the provided description)
- The last line of the message it produces is something like: "myProto was: response: query was throttled" (the full value of myProto)
- And the existing text goes in between.
Additional motivation: We are deleting the no-arg overload externally (and probably internally thereafter).
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=247095743
It's required by Truth 0.41, which we switched to in CL 200574789.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=202732649
Also, update the bundled-for-Ant JUnit from JUnit 3-something to JUnit 4.11. This matches the dependency used by the Maven build. It's necessary to avoid the problem "java.lang.ClassNotFoundException: org.junit.ComparisonFailure." Truth was already using that type as of 0.36[*], so I suspect that we were just getting away with the JUnit 3 dependency because of the vagaries of class loading. Presumably, if a test had ever actually failed in a way that should have produced a ComparisonFailure, the current build setup would have produces the same error.
[*] https://github.com/google/truth/blob/release_0_36/core/src/main/java/com/google/common/truth/Platform.java#L24
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=200574789
I'm sorry that the replacement is so ugly. Our reason for not supporting this directly is partially that it's needed by only ~1% of subjects. But mostly, we've over time taken the position that Truth is intended for only the "assert" phases of the "arrange, act, assert" testing process. Exceptions, on the other hand, usually come from the earlier phases.
Unfortunately, I still owe everyone a long explanation of *why* we have come to this position. If it's bugging you now, let me know, and I can make it happen.
(And yes, in this particular case, we're basically arguing that Your Subject Is Wrong. Sorry: I'm not trying to get you to delete it or recant or anything; I'm just trying to explain where we're coming from.)
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=192278109
We now accept (sigh) 3 versions:
- The version generated by the latest open-source release of Truth.
- The version generated by the current internal version of Truth.
- The version that will be generated once I submit CL 185043225.
I continue to promise to reduce this back to expecting a single version once I release a version of Truth that contains CL 185043225.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=190771332
Before:
some messsage: the main message
After:
some message
the main message
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=189625749
This is necessary to build with JDK9.
(You can still build *for* older versions of Java to maintain compatibility; this is just to work with build tools from JDK9, as will become the Google default.)
As part of that, migrate from additionalparam, which was deprecated and removed last year, to additionalOptions.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=182374950
The new this.fail* methods are available in Truth 0.36, which I've imported into the [] Maven repository for people who use that. If I could find a pom/build.xml for your open-source project, this CL updates it.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=169571495
Tests of a testing API often look like this:
try {
runATestThatShouldFail();
fail();
} catch (AssertionError expected) {
}
However, the catch() block can catch not only the expected failure from runATestThatShouldFail() but also the "test did not fail when it should have" failure from fail().
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=118941782