void ( @NotNull String message, @NotNull File expectedFile, @NotNull String actual, @NotNull Function1<String, String> sanitizer ) { try { String actualText = JetTestUtils.trimTrailingWhitespacesAndAddNewlineAtEOF(StringUtil.convertLineSeparators(actual.trim())); if (!expectedFile.exists()) { FileUtil.writeToFile(expectedFile, actualText); Assert.fail("Expected data file did not exist. Generating: " + expectedFile); } String expected = FileUtil.loadFile(expectedFile, CharsetToolkit.UTF8, true); String expectedText = JetTestUtils.trimTrailingWhitespacesAndAddNewlineAtEOF(StringUtil.convertLineSeparators(expected.trim())); String sanitizedExpectedText = JetTestUtils.trimTrailingWhitespacesAndAddNewlineAtEOF(sanitizer.invoke(expectedText)); String sanitizedActualText = JetTestUtils.trimTrailingWhitespacesAndAddNewlineAtEOF(sanitizer.invoke(actualText)); if (!Objects.equals(sanitizedExpectedText, sanitizedActualText)) { throw new FileComparisonFailure(message + ": " + expectedFile.getName(), sanitizedExpectedText, sanitizedActualText, expectedFile.getAbsolutePath()); } } catch (IOException e) { throw ExceptionUtilsKt.rethrow(e); } }