Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump com.google.truth:truth from 1.1.5 to 1.4.1 #78

Merged
merged 1 commit into from
Feb 19, 2024

Conversation

dependabot[bot]
Copy link
Contributor

@dependabot dependabot bot commented on behalf of github Feb 19, 2024

Bumps com.google.truth:truth from 1.1.5 to 1.4.1.

Release notes

Sourced from com.google.truth:truth's releases.

1.4.1

This release deprecates Truth8.

All its methods have become available on the main Truth class. In most cases, you can migrate your whole project mechanically: git grep -l Truth8 | xargs perl -pi -e 's/\bTruth8\b/Truth/g;'

While we do not plan to delete Truth8, we recommend migrating off it, at least if you static import assertThat: If you do not migrate, such static imports will become ambiguous in Truth 1.4.2, breaking your build.

1.4.0

In this release, our assertions on Java 8 types continue to move from the Truth8 class to the main Truth class. This change should not break compatibility for any supported JDK or Android version, even users who test under old versions of Android without API desugaring. Additionally, we will never break binary compatibility, though some users will have to make changes to their source code in order for it to compile against newer versions.

This release is likely to lead to more build failures than 1.3.0 did. However, those failures should be straightforward to fix.

Example build failure

Foo.java:152: error: reference to assertThat is ambiguous
    assertThat(repo.findFileWithName("foo")).isNull();
    ^
  both method assertThat(@org.jspecify.nullness.Nullable Path) in Truth8 and method assertThat(@org.jspecify.nullness.Nullable Path) in Truth match

Simplest upgrade strategy (if you can update all your code atomically in the same commit as the Truth upgrade)

In the same commit:

  1. Upgrade Truth to 1.4.0.
  2. Replace import static com.google.common.truth.Truth8.assertThat; with import static com.google.common.truth.Truth.assertThat;.
    • If you use Kotlin, replace import com.google.common.truth.Truth8.assertThat with import com.google.common.truth.Truth.assertThat.
  3. Replace import com.google.common.truth.Truth8; with import com.google.common.truth.Truth;.
    • again, similarly for Kotlin if needed
  4. Optionally replace remaining references to Truth8 with references to Truth.
    • For example, replace Truth8.assertThat(optional).isPresent() with Truth.assertThat(optional).isPresent().

If you're feeling lucky, you can try this one-liner for the code updates:

git grep -l Truth8 | xargs perl -pi -e 's/import static com.google.common.truth.Truth8.assertThat;/import static com.google.common.truth.Truth.assertThat;/g; s/import com.google.common.truth.Truth8.assertThat/import com.google.common.truth.Truth.assertThat/g; s/import com.google.common.truth.Truth8/import com.google.common.truth.Truth/g; s/\bTruth8[.]/Truth./g;'

In most cases, that can be further simplified to:

git grep -l Truth8 | xargs perl -pi -e 's/\bTruth8\b/Truth/g;'

After that process, it is possible that you'll still see build errors from ambiguous usages of assertThat static imports. If so, you can find a workaround in the section about overload ambiguity in the release notes for 1.3.0. Alternatively, you can wait to upgrade until after a future Truth release, which will eliminate the ambiguity by changing the signatures of some Truth.assertThat overloads.

Incremental upgrade strategy

If you have a very large repo or you have other reasons to prefer to upgrade incrementally, you can use the approach that we used inside Google. Roughly, that approach was:

... (truncated)

Commits
  • a920d7d Set version number for truth-parent to 1.4.1.
  • 3406074 Document more about how and why to migrate off Truth8.
  • 2be0061 Update docs to reflect that the Java 8 assertions have "moved" to the main `T...
  • 2e8e488 Set version number for truth-parent to 1.4.0.
  • 1f81827 Copy Truth8.assertThat overloads for Path and OptionalLong to the main ...
  • 9be8e77 Copy remaining Truth8.assertThat overloads to the main Truth class—except...
  • b02a658 Migrate most usages of Truth8.assertThat to equivalent usages of `Truth.ass...
  • 0999369 Automated Code Change
  • 7c65fc6 Make it possible to write expect.that(optionalInt).isPresent(), `assertWith...
  • 87b371d Bump styfle/cancel-workflow-action from 0.12.0 to 0.12.1
  • Additional commits viewable in compare view

Dependabot compatibility score

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


Dependabot commands and options

You can trigger Dependabot actions by commenting on this PR:

  • @dependabot rebase will rebase this PR
  • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
  • @dependabot merge will merge this PR after your CI passes on it
  • @dependabot squash and merge will squash and merge this PR after your CI passes on it
  • @dependabot cancel merge will cancel a previously requested merge and block automerging
  • @dependabot reopen will reopen this PR if it is closed
  • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
  • @dependabot show <dependency name> ignore conditions will show all of the ignore conditions of the specified dependency
  • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)

Bumps [com.google.truth:truth](https://github.com/google/truth) from 1.1.5 to 1.4.1.
- [Release notes](https://github.com/google/truth/releases)
- [Commits](google/truth@v1.1.5...v1.4.1)

---
updated-dependencies:
- dependency-name: com.google.truth:truth
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
@dependabot dependabot bot added the dependencies Pull requests that update a dependency file label Feb 19, 2024
@ZacSweers ZacSweers added this pull request to the merge queue Feb 19, 2024
Merged via the queue into main with commit 1ee3e91 Feb 19, 2024
2 checks passed
@ZacSweers ZacSweers deleted the dependabot/gradle/com.google.truth-truth-1.4.1 branch February 19, 2024 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant