[tests] fixing tests failing on windows because of file separator

This commit is contained in:
Jan Koehnlein 2012-03-01 14:47:59 +01:00
parent 7c5d2cd831
commit 31690a5d29
4 changed files with 10 additions and 6 deletions

View file

@ -329,8 +329,9 @@ public abstract class AbstractXtextTests extends Assert implements ResourceLoadH
if (url == null) {
fail("Could not read resource: '" + filePath + "'. Is your file system case sensitive?");
} else {
if(!new File(url.getPath()).getCanonicalPath().endsWith(filePath))
throw new RuntimeException(filePath + ":\n" +
String canonicalPath = new File(new File(url.getPath()).getCanonicalPath()).toURI().getPath();
if(!canonicalPath.endsWith(filePath))
throw new RuntimeException(filePath + " -> " + canonicalPath + ":\n" +
"The file does not exist exactly as it was named.\n" +
"The test is likely to cause trouble on the build server.\n" +
"Is your filesystem case insensitive? Please verify the spelling.");

View file

@ -72,7 +72,7 @@ public class JavaIoFileSystemAccess extends AbstractFileSystemAccess {
if (outlet == null)
throw new IllegalArgumentException("A slot with name '" + outputConfigName + "' has not been configured.");
String pathName = toSystemFileName(outlet + "/" + fileName);
File file = new File(pathName);
File file = new File(pathName).getAbsoluteFile();
return file;
}

View file

@ -61,7 +61,9 @@ public class JavaIoFileSystemAccessTest extends Assert {
JavaIoFileSystemAccess fileSystemAccess = new JavaIoFileSystemAccess();
fileSystemAccess.setOutputPath("testOutput", "/testDir");
URI uri = fileSystemAccess.getURI("testFile", "testOutput");
assertEquals("file:/testDir/testFile", uri.toString());
String expectedUri = new File(new File(File.separator + "testDir"), "testFile")
.toURI().toString();
assertEquals(expectedUri, uri.toString());
}
@Test

View file

@ -7,6 +7,7 @@
*******************************************************************************/
package org.eclipse.xtext.mwe;
import java.io.File;
import java.util.List;
import org.eclipse.emf.ecore.EPackage;
@ -64,7 +65,7 @@ public class UriBasedReaderTest extends AbstractXtextTests {
@Test public void testTransitiveReferences() throws Exception {
UriBasedReader reader = new UriBasedReader();
reader.addRegister(new ImportUriTestLanguageStandaloneSetup());
reader.addUri("file:" + pathTo("importUriSubfolder/Start.importuritestlanguage"));
reader.addUri("file:/" + pathTo("importUriSubfolder/Start.importuritestlanguage"));
SlotEntry slotEntry = new SlotEntry();
slotEntry.setType("Type");
@ -188,7 +189,7 @@ public class UriBasedReaderTest extends AbstractXtextTests {
}
public String pathTo(String string) throws Exception {
return new ReaderTest().pathTo(string);
return new ReaderTest().pathTo(string).replace(File.separator, "/");
}
}