test framework: extend case sensitive path comparing (IDEA-CR-6089)
authorSergey Simonchik <sergey.simonchik@jetbrains.com>
Tue, 27 Oct 2015 12:10:58 +0000 (15:10 +0300)
committerSergey Simonchik <sergey.simonchik@jetbrains.com>
Tue, 27 Oct 2015 12:11:40 +0000 (15:11 +0300)
platform/testFramework/src/com/intellij/testFramework/VfsTestUtil.java
platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java

index f9019cf47ee9335a2b67ad68c0198d51f838142a..eb2b96dc74f48aed9a63a3423907b4f3ca3ee480 100644 (file)
@@ -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);
+    }
+  }
 }
index 57006b629b316ff5df7268407065b35b638b6280..dd52c9fc66e4b97d94ebed213c8dca0249f28f63 100644 (file)
@@ -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;
   }