test framework: extend case sensitive path comparing (IDEA-CR-6089)

This commit is contained in:
Sergey Simonchik
2015-10-27 15:11:40 +03:00
parent 1de4eaaafd
commit c38baabe38
2 changed files with 15 additions and 0 deletions
@@ -20,6 +20,7 @@ import com.intellij.openapi.application.WriteAction;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
@@ -132,4 +133,16 @@ public class VfsTestUtil {
}
return vFile;
}
public static void assertFilePathEndsWithCaseSensitivePath(@NotNull VirtualFile file, @NotNull String suffixPath) {
String vfsSuffixPath = FileUtil.toSystemIndependentName(suffixPath);
String vfsPath = file.getPath();
if (!SystemInfo.isFileSystemCaseSensitive && !vfsPath.endsWith(vfsSuffixPath) &&
StringUtil.endsWithIgnoreCase(vfsPath, vfsSuffixPath)) {
String realSuffixPath = vfsPath.substring(vfsPath.length() - vfsSuffixPath.length());
Assert.fail("Please correct case-sensitivity of path to prevent test failure on case-sensitive file systems:\n" +
" path " + suffixPath + "\n" +
"real path " + realSuffixPath);
}
}
}
@@ -407,6 +407,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
fromVFile = myTempDirFixture.getFile(sourceFilePath);
}
Assert.assertNotNull("can't find test data file " + sourceFilePath + " (" + testDataPath + ")", fromVFile);
VfsTestUtil.assertFilePathEndsWithCaseSensitivePath(fromVFile, sourceFilePath);
result = myTempDirFixture.copyFile(fromVFile, targetPath);
}
else {
@@ -1604,6 +1605,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
final VirtualFile copy = LocalFileSystem.getInstance().refreshAndFindFileByPath(fullPath.replace(File.separatorChar, '/'));
Assert.assertNotNull("file " + fullPath + " not found", copy);
VfsTestUtil.assertFilePathEndsWithCaseSensitivePath(copy, filePath);
return copy;
}