From ba526bdce5f30f16b69093ae7a5b912e5f95c475 Mon Sep 17 00:00:00 2001 From: peter Date: Tue, 19 Mar 2019 14:39:12 +0100 Subject: [PATCH] UnivocityTest: don't leave modified files after test execution --- .../AbstractApplyAndRevertTestCase.java | 16 +++++++++------- .../java/propertyBased/UnivocityTest.java | 7 ++++--- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/java/java-tests/testSrc/com/intellij/java/propertyBased/AbstractApplyAndRevertTestCase.java b/java/java-tests/testSrc/com/intellij/java/propertyBased/AbstractApplyAndRevertTestCase.java index 972b219965b4..f73e9136491f 100644 --- a/java/java-tests/testSrc/com/intellij/java/propertyBased/AbstractApplyAndRevertTestCase.java +++ b/java/java-tests/testSrc/com/intellij/java/propertyBased/AbstractApplyAndRevertTestCase.java @@ -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()); diff --git a/java/java-tests/testSrc/com/intellij/java/propertyBased/UnivocityTest.java b/java/java-tests/testSrc/com/intellij/java/propertyBased/UnivocityTest.java index 939c9c4e3268..e00116dd45d8 100644 --- a/java/java-tests/testSrc/com/intellij/java/propertyBased/UnivocityTest.java +++ b/java/java-tests/testSrc/com/intellij/java/propertyBased/UnivocityTest.java @@ -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())));