From 368eaa7581d1cdcabf386902ea5ff1a37f298a92 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Wed, 2 Oct 2019 16:33:23 +0200 Subject: [PATCH] [test framework] rejecting files copied into a project from outside of a test data directory (IDEA-223901) GitOrigin-RevId: 36efa88bb5303ac83d9356301848c3aa1b6ae1b6 --- .../fixtures/impl/CodeInsightTestFixtureImpl.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) 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 dbd52ce8eefa..a2bec7765da5 100644 --- a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java +++ b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java @@ -55,7 +55,6 @@ import com.intellij.openapi.application.ReadAction; import com.intellij.openapi.application.WriteAction; import com.intellij.openapi.command.WriteCommandAction; import com.intellij.openapi.components.ServiceManager; -import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.EditorFactory; @@ -350,13 +349,12 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig sourceFile = candidate; if (targetPath == sourcePath) { Path testDataPathObj = Paths.get(testDataPath), targetPathObj = Paths.get(targetPath); - if (targetPathObj.startsWith(testDataPathObj)) { + if (targetPathObj.startsWith(testDataPathObj) && !targetPathObj.equals(testDataPathObj)) { targetPath = testDataPathObj.relativize(targetPathObj).toString(); } else { - targetPath = targetPathObj.getFileName().toString(); + throw new IllegalArgumentException("Cannot guess target path for '" + sourcePath + "'; please specify explicitly"); } - Logger.getInstance(getClass()).warn("Absolute target path '" + sourcePath + "' trimmed to '" + targetPath + "'"); } } }