From ad866b892c49032a97c50ab7e4e4fb5ddc78904a Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Fri, 2 Sep 2011 18:37:18 +0200 Subject: [PATCH] Fix GeneralCommandLineTest --- .../execution/GeneralCommandLineTest.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/platform/platform-impl/testSrc/com/intellij/execution/GeneralCommandLineTest.java b/platform/platform-impl/testSrc/com/intellij/execution/GeneralCommandLineTest.java index 501f54d0c3b2..246d6aab46dc 100644 --- a/platform/platform-impl/testSrc/com/intellij/execution/GeneralCommandLineTest.java +++ b/platform/platform-impl/testSrc/com/intellij/execution/GeneralCommandLineTest.java @@ -88,8 +88,9 @@ public class GeneralCommandLineTest extends UsefulTestCase { assertNotNull(url); final File testClass = new File(url.getFile()); + final String javaHome = System.getenv("JAVA_HOME"); final GeneralCommandLine commandLine = new GeneralCommandLine(); - commandLine.setExePath("java"); + commandLine.setExePath(javaHome != null ? javaHome + "/bin/java" : "java"); commandLine.addParameter("-cp"); commandLine.addParameter(testClass.getParentFile().getParentFile().getParentFile().getParentFile().getAbsolutePath()); commandLine.addParameter("com.intellij.execution." + testClass.getName().replace(".class", "")); @@ -116,6 +117,7 @@ public class GeneralCommandLineTest extends UsefulTestCase { 0, result); final Set lines = new HashSet(Arrays.asList(StringUtil.convertLineSeparators(output).split("\n"))); + lines.remove("====="); for (Map.Entry entry : testEnv.entrySet()) { final String str = EnvPassingTest.formatEntry(entry); @@ -127,16 +129,14 @@ public class GeneralCommandLineTest extends UsefulTestCase { final List missed = new ArrayList(); for (Map.Entry entry : parentEnv.entrySet()) { final String str = EnvPassingTest.formatEntry(entry); - if (passParentEnv) { - assertTrue("\"" + str + "\" should be in " + lines, - lines.contains(str)); - } - else if (lines.contains(str)) { + if (!lines.contains(str)) { missed.add(str); } } - if (!passParentEnv && missed.size() > 0 && parentEnv.size()/missed.size() < 2) { - fail(missed + " shouldn't be in " + lines + " (ratio: " + parentEnv.size() + '/' + missed.size() + ')'); + + final long pctMissed = Math.round((100.0 * missed.size()) / parentEnv.size()); + if (passParentEnv && pctMissed >= 10 || !passParentEnv && pctMissed <= 90) { + fail("% missed: " + pctMissed + ", missed: " + missed + ", passed: " + lines); } } }