From fa8c21cd688007f2eef5e9806f1482e836262eaa Mon Sep 17 00:00:00 2001 From: Sam Berlin Date: Wed, 19 Apr 2023 14:30:54 -0700 Subject: [PATCH] Fix Guice's dependence on the system line separator by never using the system line separator and always using \n explicitly. (We were previously inconsistent: many places used \n, and many other places used %n with a formatter, which would end up being the system line separator.) This allows tests to pass on Windows, where the line separator is different. Also update tests to do a run with the windows line separator, to catch regressions. Fixes #1213. PiperOrigin-RevId: 525552063 --- core/pom.xml | 9 +++++++ .../internal/BindingAlreadySetError.java | 2 +- .../internal/ChildBindingAlreadySetError.java | 6 ++--- .../internal/DuplicateElementError.java | 10 ++++---- .../inject/internal/DuplicateMapKeyError.java | 10 ++++---- .../com/google/inject/internal/Errors.java | 24 +++++++++---------- .../internal/InternalProvisionException.java | 6 ++--- .../com/google/inject/internal/Messages.java | 4 ++-- .../internal/MissingConstructorError.java | 12 +++++----- .../internal/MissingImplementationError.java | 2 +- .../MissingImplementationErrorHints.java | 14 +++++------ .../ProvisionListenerStackCallback.java | 2 +- .../google/inject/internal/RealMapBinder.java | 8 +++---- .../inject/internal/ScopeNotFoundError.java | 2 +- .../inject/internal/SingletonScope.java | 8 +++---- .../inject/internal/SourceFormatter.java | 18 +++++++------- .../inject/spi/BindingSourceRestriction.java | 2 +- .../com/google/inject/spi/ErrorDetail.java | 6 ++--- core/src/com/google/inject/util/Modules.java | 4 ++-- core/test/com/google/inject/BUILD | 19 +++++++++++++++ .../google/inject/internal/MessagesTest.java | 2 +- 21 files changed, 99 insertions(+), 71 deletions(-) diff --git a/core/pom.xml b/core/pom.xml index a42cca1127..57ddc8f217 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -129,6 +129,15 @@ -Dguice_bytecode_gen_option=DISABLED + + with-windows-line-separators + test + test + + + -Dline.separator='\r\n' -XX:+UnlockDiagnosticVMOptions -XX:+ShowHiddenFrames + +