mad testing: canonicalize paths, delete non-suitable files, export jetCheck dependency

This commit is contained in:
peter
2017-07-28 20:27:24 +02:00
parent bdfd0fbe37
commit b950b45223
3 changed files with 7 additions and 7 deletions
-1
View File
@@ -57,6 +57,5 @@
<orderEntry type="library" scope="TEST" name="memoryfilesystem" level="project" />
<orderEntry type="module" module-name="testExtensions" scope="TEST" />
<orderEntry type="module" module-name="configuration-store-impl" scope="TEST" />
<orderEntry type="module" module-name="jetCheck" scope="TEST" />
</component>
</module>
+1 -1
View File
@@ -26,6 +26,6 @@
<orderEntry type="module" module-name="RegExpSupport" exported="" scope="RUNTIME" />
<orderEntry type="library" name="KotlinJavaRuntime" level="project" />
<orderEntry type="module" module-name="boot" />
<orderEntry type="module" module-name="jetCheck" scope="TEST" />
<orderEntry type="module" module-name="jetCheck" exported="" scope="TEST" />
</component>
</module>
@@ -155,7 +155,7 @@ public class MadTestingUtil {
}
/**
* Finds files under {@code rootPath} (e.g. test data root) satisfying {@code fileFilter condition} (e.g. correct extension) and uses {@code actions} to generate actions those files (e.g. invoke compleiton/intentions or random editing).
* Finds files under {@code rootPath} (e.g. test data root) satisfying {@code fileFilter condition} (e.g. correct extension) and uses {@code actions} to generate actions those files (e.g. invoke completion/intentions or random editing).
* Almost: the files with same paths and contents are created inside the test project, then the actions are executed on them.
* Note that the test project contains only one file at each moment, so it's best to test actions that don't require much environment.
* @return
@@ -182,10 +182,12 @@ public class MadTestingUtil {
PsiDocumentManager.getInstance(fixture.getProject()).commitAllDocuments();
PsiFile file = PsiManager.getInstance(fixture.getProject()).findFile(vFile);
if (file instanceof PsiBinaryFile || file instanceof PsiPlainTextFile) {
return Generator.constant(null);
// no operations, but the just created file needs to be deleted (in FileWithActions#runActions)
// todo a side-effect-free generator
return Generator.constant(new FileWithActions(file, Collections.emptyList()));
}
return Generator.nonEmptyLists(actions.apply(file)).map(a -> new FileWithActions(file, a));
}).suchThat(Objects::nonNull);
});
}
private static boolean shouldGoInsiderDir(@NotNull String name) {
@@ -206,9 +208,8 @@ public class MadTestingUtil {
@NotNull
private static VirtualFile copyFileToProject(File ioFile, CodeInsightTestFixture fixture, String rootPath) {
//todo strip test data markup
try {
String path = FileUtil.getRelativePath(rootPath, ioFile.getPath(), '/');
String path = FileUtil.getRelativePath(FileUtil.toCanonicalPath(rootPath), ioFile.getPath(), '/');
assert path != null;
VirtualFile existing = fixture.findFileInTempDir(path);
if (existing != null) {