Cleanup (further simplifies VM options bean test)

This commit is contained in:
Roman Shevchenko
2017-01-05 19:25:52 +01:00
parent 451c65e123
commit cc29ff70e5
2 changed files with 4 additions and 23 deletions
@@ -24,7 +24,6 @@ import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.SystemProperties;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.TestOnly;
import java.io.File;
import java.io.IOException;
@@ -161,10 +160,6 @@ public class VMOptions {
@Nullable
public static File getWriteFile() {
if (ourTestPath != null) {
return new File(ourTestPath);
}
String vmOptionsFile = System.getProperty("jb.vmOptionsFile");
if (vmOptionsFile == null) {
// launchers should specify a path to an options file used to configure a JVM
@@ -188,18 +183,6 @@ public class VMOptions {
return new File(location, fileName);
}
private static String ourTestPath;
@TestOnly
static void setTestFile(String path) {
ourTestPath = path;
}
@TestOnly
static void clearTestFile() {
ourTestPath = null;
}
//<editor-fold desc="Deprecated stuff.">
/** @deprecated use {@link #readOption(MemoryKind, boolean)} (to be removed in IDEA 2018) */
public static int readXmx() {
@@ -37,12 +37,12 @@ public class VMOptionsTest {
public void setUp() throws IOException {
myFile = myTempDir.newFile("vmoptions.txt");
FileUtil.writeToFile(myFile, "-Xmx512m\n-XX:MaxPermSize=128m");
VMOptions.setTestFile(myFile.getPath());
System.setProperty("jb.vmOptionsFile", myFile.getPath());
}
@After
public void tearDown() {
VMOptions.clearTestFile();
System.clearProperty("jb.vmOptionsFile");
}
@Test
@@ -125,13 +125,11 @@ public class VMOptionsTest {
@Test
public void testWritingNonExistingFile() throws IOException {
File testFile = myTempDir.newFile("vmoptions.non.existing.txt");
FileUtil.delete(testFile);
VMOptions.setTestFile(testFile.getPath());
FileUtil.delete(myFile);
VMOptions.writeOption(VMOptions.MemoryKind.HEAP, 1024);
VMOptions.writeOption(VMOptions.MemoryKind.PERM_GEN, 256);
assertThat(FileUtil.loadFile(testFile)).isEqualToIgnoringWhitespace("-Xmx1024m -XX:MaxPermSize=256m");
assertThat(FileUtil.loadFile(myFile)).isEqualToIgnoringWhitespace("-Xmx1024m -XX:MaxPermSize=256m");
}
}