tests: fix running on windows
diff --git a/core/plugins/org.eclipse.dltk.core/compiler/org/eclipse/dltk/compiler/util/Util.java b/core/plugins/org.eclipse.dltk.core/compiler/org/eclipse/dltk/compiler/util/Util.java
index 4fcd5f5..0cd5c03 100644
--- a/core/plugins/org.eclipse.dltk.core/compiler/org/eclipse/dltk/compiler/util/Util.java
+++ b/core/plugins/org.eclipse.dltk.core/compiler/org/eclipse/dltk/compiler/util/Util.java
@@ -142,8 +142,8 @@
try {
stream = file.openInputStream(EFS.NONE, new NullProgressMonitor());
IFileInfo info = file.fetchInfo();
- byte[] data = getInputStreamAsByteArray(stream, (int) info
- .getLength());
+ byte[] data = getInputStreamAsByteArray(stream,
+ (int) info.getLength());
p.done("#", RuntimePerformanceMonitor.IOREAD, data.length);
return data;
} finally {
@@ -380,10 +380,16 @@
public static void copy(File file, InputStream input) throws IOException {
PerformanceNode p = RuntimePerformanceMonitor.begin();
- OutputStream fos = new BufferedOutputStream(new FileOutputStream(file),
- 8096);
- copy(input, fos);
- fos.close();
+ OutputStream fos = new BufferedOutputStream(new FileOutputStream(file));
+ try {
+ copy(input, fos);
+ } finally {
+ try {
+ fos.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
p.done("#", RuntimePerformanceMonitor.IOWRITE, file.length());
}
diff --git a/core/tests/org.eclipse.dltk.core.tests/src/org/eclipse/dltk/core/tests/model/TestSourceElementParser.java b/core/tests/org.eclipse.dltk.core.tests/src/org/eclipse/dltk/core/tests/model/TestSourceElementParser.java
index 21f62fe..4f225d3 100644
--- a/core/tests/org.eclipse.dltk.core.tests/src/org/eclipse/dltk/core/tests/model/TestSourceElementParser.java
+++ b/core/tests/org.eclipse.dltk.core.tests/src/org/eclipse/dltk/core/tests/model/TestSourceElementParser.java
@@ -20,7 +20,7 @@
private ISourceElementRequestor requestor;
public void parseSourceModule(IModuleSource module) {
- String file = module.getSourceContents();
+ String file = module.getSourceContents().replace("\r\n", "\n");
if (file.startsWith(PARSEME_HEADER)) {
parsePseudo(file);
return;
diff --git a/core/tests/org.eclipse.dltk.core.tests/src/org/eclipse/dltk/core/tests/search/Bug387751Test.java b/core/tests/org.eclipse.dltk.core.tests/src/org/eclipse/dltk/core/tests/search/Bug387751Test.java
index 4a8facc..86f0c8f 100644
--- a/core/tests/org.eclipse.dltk.core.tests/src/org/eclipse/dltk/core/tests/search/Bug387751Test.java
+++ b/core/tests/org.eclipse.dltk.core.tests/src/org/eclipse/dltk/core/tests/search/Bug387751Test.java
@@ -13,6 +13,7 @@
import java.io.File;
import java.io.IOException;
+import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -200,7 +201,16 @@
private void addExternalLibraryFromFile(IFile file, String filename)
throws IOException, CoreException {
final File externalFile = new File(temp.getRoot(), filename);
- Util.copy(externalFile, file.getContents());
+ final InputStream input = file.getContents();
+ try {
+ Util.copy(externalFile, input);
+ } finally {
+ try {
+ input.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
addBuildpathEntry(project.getScriptProject(),
DLTKCore.newExtLibraryEntry(getFullPath(externalFile
.getParentFile())));
diff --git a/core/tests/org.eclipse.dltk.core.tests/src/org/eclipse/dltk/core/tests/util/Util.java b/core/tests/org.eclipse.dltk.core.tests/src/org/eclipse/dltk/core/tests/util/Util.java
index 4186b0f..d509561 100644
--- a/core/tests/org.eclipse.dltk.core.tests/src/org/eclipse/dltk/core/tests/util/Util.java
+++ b/core/tests/org.eclipse.dltk.core.tests/src/org/eclipse/dltk/core/tests/util/Util.java
@@ -19,7 +19,6 @@
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
-import org.eclipse.dltk.core.DLTKContentTypeManager;
import org.eclipse.dltk.core.DLTKCore;
public class Util {
@@ -264,7 +263,7 @@
BufferedInputStream input;
try {
input = new BufferedInputStream(new FileInputStream(
- files[i]), 4096);
+ files[i]));
org.eclipse.dltk.compiler.util.Util.copy(child, input);
input.close();
} catch (FileNotFoundException e) {