Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Pazderski2020-08-29 23:02:13 +0000
committerPaul Pazderski2020-09-13 13:34:10 +0000
commit2fd33c3287e81664c5094542bd18c1895c9ca244 (patch)
tree4f1f531272b30876de99d9a6aaaafc330e1070ad
parent5bdc65e433a2f78b82c44af5828485ec0315c86d (diff)
downloadeclipse.platform.debug-2fd33c3287e81664c5094542bd18c1895c9ca244.tar.gz
eclipse.platform.debug-2fd33c3287e81664c5094542bd18c1895c9ca244.tar.xz
eclipse.platform.debug-2fd33c3287e81664c5094542bd18c1895c9ca244.zip
Avoid a theoretical race condition where a fast terminating process get not all content to console. Includes a of-by-one error fix in MockProcess termination calculation. Before a MockProcess with 0ms runtime was reported as not terminated for up to 1ms. This can be relevant for the initial termination check in RuntimeProcess. This change might also fix random failures for other tests using the doConsoleOutputTest method. Change-Id: I76cad5317607b1889513827c8191edefa7637491 Signed-off-by: Paul Pazderski <paul-eclipse@ppazderski.de>
-rw-r--r--org.eclipse.debug.tests/META-INF/MANIFEST.MF2
-rw-r--r--org.eclipse.debug.tests/pom.xml2
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/MockProcess.java2
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/ProcessConsoleTests.java5
4 files changed, 6 insertions, 5 deletions
diff --git a/org.eclipse.debug.tests/META-INF/MANIFEST.MF b/org.eclipse.debug.tests/META-INF/MANIFEST.MF
index 2f725b167..3696af528 100644
--- a/org.eclipse.debug.tests/META-INF/MANIFEST.MF
+++ b/org.eclipse.debug.tests/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.debug.tests;singleton:=true
-Bundle-Version: 3.11.800.qualifier
+Bundle-Version: 3.11.900.qualifier
Bundle-Activator: org.eclipse.debug.tests.TestsPlugin
Bundle-Localization: plugin
Require-Bundle: org.eclipse.ui;bundle-version="[3.6.0,4.0.0)",
diff --git a/org.eclipse.debug.tests/pom.xml b/org.eclipse.debug.tests/pom.xml
index 730367299..3051467ba 100644
--- a/org.eclipse.debug.tests/pom.xml
+++ b/org.eclipse.debug.tests/pom.xml
@@ -18,7 +18,7 @@
</parent>
<groupId>org.eclipse.debug</groupId>
<artifactId>org.eclipse.debug.tests</artifactId>
- <version>3.11.800-SNAPSHOT</version>
+ <version>3.11.900-SNAPSHOT</version>
<packaging>eclipse-test-plugin</packaging>
<properties>
<code.ignoredWarnings>${tests.ignoredWarnings}</code.ignoredWarnings>
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/MockProcess.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/MockProcess.java
index 135b54c7c..0c5667235 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/MockProcess.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/MockProcess.java
@@ -232,7 +232,7 @@ public class MockProcess extends Process {
* @return <code>true</code> if process is terminated
*/
private boolean isTerminated() {
- return endTime != RUN_FOREVER && System.currentTimeMillis() > endTime;
+ return endTime != RUN_FOREVER && System.currentTimeMillis() >= endTime;
}
/**
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/ProcessConsoleTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/ProcessConsoleTests.java
index e6eb8b195..a1c6beb2c 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/ProcessConsoleTests.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/ProcessConsoleTests.java
@@ -309,7 +309,7 @@ public class ProcessConsoleTests extends AbstractDebugTest {
@Test
public void testAppendOutputToFile() throws Exception {
final String testContent = "Hello World!";
- final File outFile = createTmpFile("test.out");
+ final File outFile = createTmpFile("test-append.out");
Map<String, Object> launchConfigAttributes = new HashMap<>();
launchConfigAttributes.put(IDebugUIConstants.ATTR_CAPTURE_IN_FILE, outFile.getCanonicalPath());
launchConfigAttributes.put(IDebugUIConstants.ATTR_APPEND_TO_FILE, true);
@@ -367,7 +367,7 @@ public class ProcessConsoleTests extends AbstractDebugTest {
* @return the console object after it has finished
*/
private IOConsole doConsoleOutputTest(byte[] testContent, Map<String, Object> launchConfigAttributes) throws Exception {
- final MockProcess mockProcess = new MockProcess(new ByteArrayInputStream(testContent), null, 0);
+ final MockProcess mockProcess = new MockProcess(new ByteArrayInputStream(testContent), null, MockProcess.RUN_FOREVER);
final IProcess process = mockProcess.toRuntimeProcess("Output Redirect", launchConfigAttributes);
final String encoding = launchConfigAttributes != null ? (String) launchConfigAttributes.get(DebugPlugin.ATTR_CONSOLE_ENCODING) : null;
final AtomicBoolean consoleFinished = new AtomicBoolean(false);
@@ -381,6 +381,7 @@ public class ProcessConsoleTests extends AbstractDebugTest {
final IConsoleManager consoleManager = ConsolePlugin.getDefault().getConsoleManager();
try {
consoleManager.addConsoles(new IConsole[] { console });
+ mockProcess.destroy();
waitWhile(c -> !consoleFinished.get(), testTimeout, c -> "Console did not finished.");
Object value = launchConfigAttributes != null ? launchConfigAttributes.get(IDebugUIConstants.ATTR_CAPTURE_IN_FILE) : null;

Back to the top