From f11e35f988a54b2c93ad9bb340daff293c4b77d1 Mon Sep 17 00:00:00 2001 From: Nikolay Krasko Date: Fri, 25 Apr 2014 19:37:27 +0400 Subject: [PATCH] Don't check trailing spaces because idea removes them by default --- .../tests/org/jetbrains/jet/JetTestUtils.java | 9 ++++++--- .../tests/org/jetbrains/jet/jetTestUtils.kt | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 compiler/tests/org/jetbrains/jet/jetTestUtils.kt diff --git a/compiler/tests/org/jetbrains/jet/JetTestUtils.java b/compiler/tests/org/jetbrains/jet/JetTestUtils.java index 667dabd3179..2e2c55ef355 100644 --- a/compiler/tests/org/jetbrains/jet/JetTestUtils.java +++ b/compiler/tests/org/jetbrains/jet/JetTestUtils.java @@ -69,6 +69,7 @@ import org.jetbrains.jet.lexer.JetTokens; import org.jetbrains.jet.plugin.JetLanguage; import org.jetbrains.jet.test.InnerTestClasses; import org.jetbrains.jet.test.TestMetadata; +import org.jetbrains.jet.test.util.UtilPackage; import org.jetbrains.jet.util.slicedmap.ReadOnlySlice; import org.jetbrains.jet.util.slicedmap.SlicedMap; import org.jetbrains.jet.util.slicedmap.WritableSlice; @@ -437,9 +438,11 @@ public class JetTestUtils { } String expected = FileUtil.loadFile(expectedFile, CharsetToolkit.UTF8, true); - // compare with hard copy: make sure nothing is lost in output - String expectedText = StringUtil.convertLineSeparators(expected.trim()); - String actualText = StringUtil.convertLineSeparators(actual.trim()); + String expectedText = UtilPackage.removeTrailingWhitespacesFromEachLine( + StringUtil.convertLineSeparators(expected.trim())); + String actualText = UtilPackage.removeTrailingWhitespacesFromEachLine( + StringUtil.convertLineSeparators(actual.trim())); + if (!Comparing.equal(expectedText, actualText)) { throw new FileComparisonFailure("Actual data differs from file content: " + expectedFile.getName(), expected, actual, expectedFile.getAbsolutePath()); diff --git a/compiler/tests/org/jetbrains/jet/jetTestUtils.kt b/compiler/tests/org/jetbrains/jet/jetTestUtils.kt new file mode 100644 index 00000000000..505061a0d17 --- /dev/null +++ b/compiler/tests/org/jetbrains/jet/jetTestUtils.kt @@ -0,0 +1,19 @@ +/* + * Copyright 2010-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.test.util + +fun String.removeTrailingWhitespacesFromEachLine() = split('\n') map { it.trimTrailing() } makeString ("\n") \ No newline at end of file