Permalink
Browse files

tests: fix running on windows

  • Loading branch information...
1 parent 2dae687 commit 5cf777abd151491a717f52a113dbcb02c62182d4 @panchenko committed Mar 26, 2013
@@ -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 final static boolean isExcluded(char[] path,
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());
}
@@ -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;
@@ -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 @@ public boolean visit(IModelElement element) {
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())));
@@ -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 @@ public static void copyFiles(String from, String to) {
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) {

0 comments on commit 5cf777a

Please sign in to comment.