From 7ddb2d933c5aa018c11e94497da6e1cbb672cc3d Mon Sep 17 00:00:00 2001 From: Sergey Simonchik Date: Thu, 22 Oct 2015 14:34:07 +0300 Subject: [PATCH] test framework: prevent test failure on case-sensitive file systems: fast fail if the requested and real paths are not case-sensitive equal --- .../com/intellij/codeInsight/CodeInsightTestCase.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/java/testFramework/src/com/intellij/codeInsight/CodeInsightTestCase.java b/java/testFramework/src/com/intellij/codeInsight/CodeInsightTestCase.java index 28efa2baae3f..f611ae7cbf80 100644 --- a/java/testFramework/src/com/intellij/codeInsight/CodeInsightTestCase.java +++ b/java/testFramework/src/com/intellij/codeInsight/CodeInsightTestCase.java @@ -40,6 +40,7 @@ import com.intellij.openapi.roots.ContentEntry; import com.intellij.openapi.roots.ModifiableRootModel; import com.intellij.openapi.roots.ModuleRootManager; import com.intellij.openapi.util.Disposer; +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.*; @@ -544,8 +545,16 @@ public abstract class CodeInsightTestCase extends PsiTestCase { String fullPath = getTestDataPath() + filePath; allowRootAccess(fullPath); - final VirtualFile vFile = LocalFileSystem.getInstance().findFileByPath(fullPath.replace(File.separatorChar, '/')); + String vfsPath = FileUtil.toSystemIndependentName(fullPath); + VirtualFile vFile = LocalFileSystem.getInstance().findFileByPath(vfsPath); assertNotNull("file " + fullPath + " not found", vFile); + String realVfsPath = vFile.getPath(); + if (!SystemInfo.isFileSystemCaseSensitive && !vfsPath.equals(realVfsPath) && + vfsPath.equalsIgnoreCase(realVfsPath)) { + fail("Please correct case-sensitivity of path to prevent test failure on case-sensitive file systems:\n" + + " path " + vfsPath + "\n" + + "real path " + realVfsPath); + } return vFile; }