UnivocityTest: don't leave modified files after test execution

This commit is contained in:
peter
2019-03-19 17:59:15 +01:00
parent ef2ee9683d
commit ba526bdce5
2 changed files with 13 additions and 10 deletions
@@ -13,8 +13,9 @@ import com.intellij.openapi.diagnostic.DefaultLogger;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.projectRoots.JavaSdk;
import com.intellij.openapi.projectRoots.ProjectJdkTable;
import com.intellij.openapi.projectRoots.impl.JavaAwareProjectJdkTableImpl;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.roots.ProjectRootManager;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
@@ -26,6 +27,7 @@ import com.intellij.testFramework.CompilerTester;
import com.intellij.testFramework.PlatformTestCase;
import com.intellij.testFramework.PlatformTestUtil;
import com.intellij.testFramework.TestDataProvider;
import com.intellij.util.SystemProperties;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jetCheck.Generator;
@@ -70,14 +72,14 @@ public abstract class AbstractApplyAndRevertTestCase extends PlatformTestCase {
oldMacroValue = pathMacros.getValue(PathMacrosImpl.MAVEN_REPOSITORY);
pathMacros.setMacro(PathMacrosImpl.MAVEN_REPOSITORY, getDefaultMavenRepositoryPath());
WriteAction.run(() -> ProjectJdkTable.getInstance().addJdk(JavaAwareProjectJdkTableImpl.getInstanceEx().getInternalJdk(), getTestRootDisposable()));
CompilerTestUtil.saveApplicationSettings();
myProject = ProjectUtil.openOrImport(getTestDataPath(), null, false);
WriteAction.run(() -> {
String sdkName = ProjectRootManager.getInstance(myProject).getProjectSdkName();
Sdk internalJdk = JavaSdk.getInstance().createJdk(sdkName, SystemProperties.getJavaHome());
ProjectJdkTable.getInstance().addJdk(internalJdk, getTestRootDisposable());
});
WriteAction.run(
() -> ProjectRootManager.getInstance(myProject).setProjectSdk(JavaAwareProjectJdkTableImpl.getInstanceEx().getInternalJdk()));
CompilerTestUtil.saveApplicationSettings();
InspectionProfileImpl.INIT_INSPECTIONS = true;
DefaultLogger.disableStderrDumping(getTestRootDisposable());
@@ -60,11 +60,12 @@ public class UnivocityTest extends AbstractApplyAndRevertTestCase {
PropertyChecker.customized()
.withIterationCount(30).checkScenarios(() -> env -> {
long startModCount = tracker.getModificationCount();
if (rebuildStamp.getAndSet(startModCount) != startModCount) {
checkCompiles(myCompilerTester.rebuild());
}
MadTestingUtil.changeAndRevert(myProject, () -> {
if (rebuildStamp.getAndSet(startModCount) != startModCount) {
checkCompiles(myCompilerTester.rebuild());
}
env.executeCommands(Generator.constant(env1 -> {
PsiJavaFile file = env1.generateValue(psiJavaFiles(), "Open %s in editor");
env1.executeCommands(IntDistribution.uniform(1, 5), Generator.constant(new InvokeIntention(file, new JavaGreenIntentionPolicy())));