diff --git a/platform/testFramework/src/com/intellij/testFramework/VfsTestUtil.java b/platform/testFramework/src/com/intellij/testFramework/VfsTestUtil.java index f9019cf47ee9..eb2b96dc74f4 100644 --- a/platform/testFramework/src/com/intellij/testFramework/VfsTestUtil.java +++ b/platform/testFramework/src/com/intellij/testFramework/VfsTestUtil.java @@ -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); + } + } } diff --git a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java index 57006b629b31..dd52c9fc66e4 100644 --- a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java +++ b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java @@ -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; }