Normalize paths in output in integration-tests.
This commit is contained in:
@@ -27,8 +27,12 @@ import com.intellij.execution.process.ProcessOutputTypes;
|
|||||||
import com.intellij.openapi.application.PathManager;
|
import com.intellij.openapi.application.PathManager;
|
||||||
import com.intellij.openapi.util.Key;
|
import com.intellij.openapi.util.Key;
|
||||||
import com.intellij.openapi.util.SystemInfo;
|
import com.intellij.openapi.util.SystemInfo;
|
||||||
|
import com.intellij.openapi.util.io.FileUtil;
|
||||||
import com.intellij.openapi.util.text.StringUtil;
|
import com.intellij.openapi.util.text.StringUtil;
|
||||||
import com.intellij.util.ArrayUtil;
|
import com.intellij.util.ArrayUtil;
|
||||||
|
import jet.Function1;
|
||||||
|
import kotlin.KotlinPackage;
|
||||||
|
import org.intellij.lang.annotations.Language;
|
||||||
import org.jetbrains.jet.JetTestUtils;
|
import org.jetbrains.jet.JetTestUtils;
|
||||||
import org.jetbrains.jet.test.Tmpdir;
|
import org.jetbrains.jet.test.Tmpdir;
|
||||||
import org.junit.ComparisonFailure;
|
import org.junit.ComparisonFailure;
|
||||||
@@ -42,6 +46,8 @@ import java.io.IOException;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.regex.MatchResult;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
@@ -95,19 +101,24 @@ public abstract class KotlinIntegrationTestBase {
|
|||||||
return exitCode;
|
return exitCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String replacePath(String content, File path, String pathId) {
|
private static String normalizePath(String content, File baseDir, String pathId) {
|
||||||
String absolutePath = path.getAbsolutePath();
|
String contentWithRelativePaths = content.replace(baseDir.getAbsolutePath(), pathId);
|
||||||
|
|
||||||
return content
|
@Language("RegExp")
|
||||||
.replace(absolutePath + "/", pathId + "/")
|
String RELATIVE_PATH_WITH_MIXED_SEPARATOR = Pattern.quote(pathId) + "[-.\\w/\\\\]*";
|
||||||
.replace(absolutePath + "\\", pathId + "/")
|
|
||||||
.replace(absolutePath, pathId);
|
return KotlinPackage.replaceAll(contentWithRelativePaths, RELATIVE_PATH_WITH_MIXED_SEPARATOR, new Function1<MatchResult, String>() {
|
||||||
|
@Override
|
||||||
|
public String invoke(MatchResult mr) {
|
||||||
|
return FileUtil.toSystemIndependentName(mr.group());
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String normalizeOutput(String content) {
|
protected String normalizeOutput(String content) {
|
||||||
content = replacePath(content, testDataDir, "[TestData]");
|
content = normalizePath(content, testDataDir, "[TestData]");
|
||||||
content = replacePath(content, tmpdir.getTmpDir(), "[Temp]");
|
content = normalizePath(content, tmpdir.getTmpDir(), "[Temp]");
|
||||||
content = replacePath(content, getCompilerLib(), "[CompilerLib]");
|
content = normalizePath(content, getCompilerLib(), "[CompilerLib]");
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user