[test framework] an attempt to better guess target path for files copied into test project (IDEA-223901)

GitOrigin-RevId: ed184e44e72b41c52d51b00d3a989dd72883b54e
This commit is contained in:
Roman Shevchenko
2019-10-02 13:08:48 +00:00
committed by intellij-monorepo-bot
parent 16786f4b89
commit 8620ee09b5
@@ -129,6 +129,8 @@ import org.jetbrains.annotations.TestOnly;
import java.io.File;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -347,7 +349,13 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
if (candidate.isAbsolute()) {
sourceFile = candidate;
if (targetPath == sourcePath) {
targetPath = PathUtil.getFileName(sourcePath);
Path testDataPathObj = Paths.get(testDataPath), targetPathObj = Paths.get(targetPath);
if (targetPathObj.startsWith(testDataPathObj)) {
targetPath = testDataPathObj.relativize(targetPathObj).toString();
}
else {
targetPath = targetPathObj.getFileName().toString();
}
Logger.getInstance(getClass()).warn("Absolute target path '" + sourcePath + "' trimmed to '" + targetPath + "'");
}
}