Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Leherbauer2011-03-07 11:24:27 -0500
committerAnton Leherbauer2011-03-07 11:24:27 -0500
commiteb02ad7b69c229159d663e0476f437b71356d0ed (patch)
tree1a415c1e99c8508f164afbe4101f11c28e058919 /build/org.eclipse.cdt.make.core.tests
parent85a953ca4c653ded1bf14000fa4ad2e8b793ad92 (diff)
downloadorg.eclipse.cdt-eb02ad7b69c229159d663e0476f437b71356d0ed.tar.gz
org.eclipse.cdt-eb02ad7b69c229159d663e0476f437b71356d0ed.tar.xz
org.eclipse.cdt-eb02ad7b69c229159d663e0476f437b71356d0ed.zip
Bug 338936 - Makefile parsers don't close the input streams
Diffstat (limited to 'build/org.eclipse.cdt.make.core.tests')
-rw-r--r--build/org.eclipse.cdt.make.core.tests/build.properties3
-rw-r--r--build/org.eclipse.cdt.make.core.tests/data/Makefile.main4
-rw-r--r--build/org.eclipse.cdt.make.core.tests/data/incl/Makefile.incl2
-rw-r--r--build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/core/tests/MakefileReaderProviderTests.java64
4 files changed, 56 insertions, 17 deletions
diff --git a/build/org.eclipse.cdt.make.core.tests/build.properties b/build/org.eclipse.cdt.make.core.tests/build.properties
index d985ee0868..a88598e0c4 100644
--- a/build/org.eclipse.cdt.make.core.tests/build.properties
+++ b/build/org.eclipse.cdt.make.core.tests/build.properties
@@ -11,5 +11,6 @@
source.. = src/
output.. = bin/
bin.includes = .,\
- META-INF/
+ META-INF/,\
+ data/
src.includes = about.html
diff --git a/build/org.eclipse.cdt.make.core.tests/data/Makefile.main b/build/org.eclipse.cdt.make.core.tests/data/Makefile.main
new file mode 100644
index 0000000000..32c5fefcc8
--- /dev/null
+++ b/build/org.eclipse.cdt.make.core.tests/data/Makefile.main
@@ -0,0 +1,4 @@
+VAR = foo
+include Makefile.incl
+main: $(VAR)
+ nothing
diff --git a/build/org.eclipse.cdt.make.core.tests/data/incl/Makefile.incl b/build/org.eclipse.cdt.make.core.tests/data/incl/Makefile.incl
new file mode 100644
index 0000000000..0cbb66f3ce
--- /dev/null
+++ b/build/org.eclipse.cdt.make.core.tests/data/incl/Makefile.incl
@@ -0,0 +1,2 @@
+INCLVAR = bar
+foo.o: .PHONY
diff --git a/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/core/tests/MakefileReaderProviderTests.java b/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/core/tests/MakefileReaderProviderTests.java
index 0d9a38dbfc..553d808c70 100644
--- a/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/core/tests/MakefileReaderProviderTests.java
+++ b/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/core/tests/MakefileReaderProviderTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008 Nokia and others.
+ * Copyright (c) 2008, 2011 Nokia and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,20 +7,34 @@
*
* Contributors:
* Nokia (Ed Swartz) - initial API and implementation
+ * Wind River Systems - Bug 338936
*******************************************************************************/
-
package org.eclipse.cdt.make.core.tests;
-import org.eclipse.cdt.make.core.MakeCorePlugin;
-import org.eclipse.cdt.make.core.makefile.*;
-import org.eclipse.core.filesystem.URIUtil;
-import org.eclipse.core.runtime.*;
-
-import java.io.*;
-import java.net.*;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.io.StringReader;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
import junit.framework.Test;
import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.eclipse.cdt.make.core.MakeCorePlugin;
+import org.eclipse.cdt.make.core.makefile.IMacroDefinition;
+import org.eclipse.cdt.make.core.makefile.IMakefile;
+import org.eclipse.cdt.make.core.makefile.IMakefileReaderProvider;
+import org.eclipse.cdt.make.core.makefile.IRule;
+import org.eclipse.core.filesystem.URIUtil;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
public class MakefileReaderProviderTests extends TestCase {
private String[] inclDirs;
@@ -91,7 +105,7 @@ public class MakefileReaderProviderTests extends TestCase {
public void testInMemoryReaderProvider() throws Exception {
IMakefile makefile = MakeCorePlugin.createMakefile(
- URIUtil.toURI("Makefile.main"), true, inclDirs,
+ URIUtil.toURI("/memory/Makefile.main"), true, inclDirs,
new IMakefileReaderProvider() {
public Reader getReader(URI fileURI) throws IOException {
@@ -119,6 +133,25 @@ public class MakefileReaderProviderTests extends TestCase {
assertMakefileContents(makefile);
}
+ public void testReaderIsClosed_Bug338936() throws Exception {
+ final boolean[] streamIsClosed = { false };
+ MakeCorePlugin.createMakefile(
+ URIUtil.toURI("Makefile.main"), true, inclDirs,
+ new IMakefileReaderProvider() {
+ public Reader getReader(URI fileURI) throws IOException {
+ return new StringReader("") {
+ @Override
+ public void close() {
+ super.close();
+ streamIsClosed[0] = true;
+ }
+ };
+ }
+
+ });
+ assertTrue("Stream is not closed", streamIsClosed[0]);
+ }
+
/**
* @param makefile
*/
@@ -152,19 +185,18 @@ public class MakefileReaderProviderTests extends TestCase {
}
private URL getPluginRelativeURL(IPath path) throws Exception {
- if (MakeTestsPlugin.getDefault() != null)
- return FileLocator.find(
+ if (MakeTestsPlugin.getDefault() != null) {
+ URL url = FileLocator.find(
MakeTestsPlugin.getDefault().getBundle(),
path, null);
+ return url != null ? FileLocator.toFileURL(url) : null;
+ }
else {
return new URL("file", null, path.toFile().getAbsolutePath());
}
}
- /**
- * @return
- */
public static Test suite() {
- return new MakefileReaderProviderTests();
+ return new TestSuite(MakefileReaderProviderTests.class);
}
}

Back to the top