aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorszarnekow2009-02-05 09:08:22 (EST)
committersefftinge2009-02-05 09:08:22 (EST)
commit1944d25b60e751c9e72475822756dd3860052bcf (patch)
tree374d5918495ad4e87c7926f7aab90fbd695363db
parent207e7c2bf760f15a33e75847a7c6a9ba14aa773a (diff)
downloadorg.eclipse.xtext-1944d25b60e751c9e72475822756dd3860052bcf.zip
org.eclipse.xtext-1944d25b60e751c9e72475822756dd3860052bcf.tar.gz
org.eclipse.xtext-1944d25b60e751c9e72475822756dd3860052bcf.tar.bz2
Fixed issue with case sensitive file systems vs case insensitive file system, added error if readFileIntoString would fail on case sensitive file system
-rwxr-xr-xtests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/GenerateAllTestGrammars.java9
-rw-r--r--tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/parsetree/reconstr/ComplexReconstrTest.java3
-rw-r--r--tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/parsetree/reconstr/SimpleReconstrTest.java13
-rwxr-xr-xtests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/tests/AbstractGeneratorTest.java13
-rw-r--r--tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/xtext/ResourceLoadTest.java2
-rw-r--r--tests/org.eclipse.xtext.ui.common.tests/src/org/eclipse/xtext/ui/common/GenerateAllTestGrammarsWithUiConfig.java4
6 files changed, 29 insertions, 15 deletions
diff --git a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/GenerateAllTestGrammars.java b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/GenerateAllTestGrammars.java
index 74fe811..20039ae 100755
--- a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/GenerateAllTestGrammars.java
+++ b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/GenerateAllTestGrammars.java
@@ -100,7 +100,7 @@ public class GenerateAllTestGrammars {
}
GeneratorFacade.cleanFolder(path + "/src-gen");
for (Class<?> c : testclasses) {
- String filename = "classpath:/" + getGrammarFileName(c);
+ String filename = getGrammarFileNameAsURI(c);
log.info("loading " + filename);
ResourceSetImpl rs = new XtextResourceSet();
URI uri = URI.createURI(filename);
@@ -114,7 +114,12 @@ public class GenerateAllTestGrammars {
}
}
- private static String getGrammarFileName(Class<?> c) {
+ public static String getGrammarFileNameAsURI(Class<?> c) {
+ String filename = "classpath:/" + getGrammarFileName(c);
+ return filename;
+ }
+
+ public static String getGrammarFileName(Class<?> c) {
try {
Method m = c.getMethod("getGrammarFileName");
if (m != null && Modifier.isStatic(m.getModifiers()) && String.class.equals(m.getReturnType()))
diff --git a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/parsetree/reconstr/ComplexReconstrTest.java b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/parsetree/reconstr/ComplexReconstrTest.java
index 99b13c9..1662d1d 100644
--- a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/parsetree/reconstr/ComplexReconstrTest.java
+++ b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/parsetree/reconstr/ComplexReconstrTest.java
@@ -19,8 +19,7 @@ import org.eclipse.xtext.util.EmfFormater;
public class ComplexReconstrTest extends AbstractGeneratorTest {
- private static final Logger logger = Logger
- .getLogger(ComplexReconstrTest.class);
+ private static final Logger logger = Logger.getLogger(ComplexReconstrTest.class);
@Override
protected void setUp() throws Exception {
diff --git a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/parsetree/reconstr/SimpleReconstrTest.java b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/parsetree/reconstr/SimpleReconstrTest.java
index 0bfe1cc..f329870 100644
--- a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/parsetree/reconstr/SimpleReconstrTest.java
+++ b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/parsetree/reconstr/SimpleReconstrTest.java
@@ -17,8 +17,7 @@ import org.eclipse.xtext.util.EmfFormater;
public class SimpleReconstrTest extends AbstractGeneratorTest {
- private static final Logger logger = Logger
- .getLogger(ComplexReconstrTest.class);
+ private static final Logger logger = Logger.getLogger(SimpleReconstrTest.class);
public void testSimple1() throws Exception {
String model = "a b";
@@ -42,12 +41,10 @@ public class SimpleReconstrTest extends AbstractGeneratorTest {
private String parseAndSerialize(String model) throws Exception {
EObject result = (EObject) getModel(model);
- if (logger.isDebugEnabled()) {
- logger.debug(EmfFormater.objToStr(result));
- logger
- .debug(EmfFormater.objToStr(NodeUtil.getRootNode(result)));
- logger.debug(EmfFormater.objToStr(NodeUtil.getRootNode(result)
- .getLeafNodes()));
+ if (logger.isTraceEnabled()) {
+ logger.trace(EmfFormater.objToStr(result));
+ logger.trace(EmfFormater.objToStr(NodeUtil.getRootNode(result)));
+ logger.trace(EmfFormater.objToStr(NodeUtil.getRootNode(result).getLeafNodes()));
}
return serialize(result);
}
diff --git a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/tests/AbstractGeneratorTest.java b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/tests/AbstractGeneratorTest.java
index bc3c503..9ce50e4 100755
--- a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/tests/AbstractGeneratorTest.java
+++ b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/tests/AbstractGeneratorTest.java
@@ -8,9 +8,11 @@
*******************************************************************************/
package org.eclipse.xtext.tests;
+import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Method;
+import java.net.URL;
import junit.framework.TestCase;
@@ -235,7 +237,18 @@ public abstract class AbstractGeneratorTest extends TestCase {
protected String readFileIntoString(String filePath) throws IOException {
ClassLoader classLoader = getClass().getClassLoader();
+ URL url = classLoader.getResource(filePath);
+ if (url == null)
+ fail("Could not read resource: '" + filePath + "'. Is your file system case sensitive?");
+ if(!new File(url.getPath()).getCanonicalPath().endsWith(filePath))
+ throw new RuntimeException(filePath + ":\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.");
+
InputStream resourceAsStream = classLoader.getResourceAsStream(filePath);
+ if (resourceAsStream == null)
+ fail("Could not read resource: '" + filePath + "'. Is your file system case sensitive?");
byte[] buffer = new byte[2048];
int bytesRead = 0;
StringBuffer b = new StringBuffer();
diff --git a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/xtext/ResourceLoadTest.java b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/xtext/ResourceLoadTest.java
index 75ba7a1..12bb459 100644
--- a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/xtext/ResourceLoadTest.java
+++ b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/xtext/ResourceLoadTest.java
@@ -67,7 +67,7 @@ public class ResourceLoadTest extends AbstractGeneratorTest {
private void initModel() {
try {
- model = readFileIntoString(clazz.getName().replace('.', '/') + ".xtext");
+ model = readFileIntoString(GenerateAllTestGrammars.getGrammarFileName(clazz));
} catch(IOException e) {
throw new RuntimeException(e);
}
diff --git a/tests/org.eclipse.xtext.ui.common.tests/src/org/eclipse/xtext/ui/common/GenerateAllTestGrammarsWithUiConfig.java b/tests/org.eclipse.xtext.ui.common.tests/src/org/eclipse/xtext/ui/common/GenerateAllTestGrammarsWithUiConfig.java
index 7e4f1d4..df99fa2 100644
--- a/tests/org.eclipse.xtext.ui.common.tests/src/org/eclipse/xtext/ui/common/GenerateAllTestGrammarsWithUiConfig.java
+++ b/tests/org.eclipse.xtext.ui.common.tests/src/org/eclipse/xtext/ui/common/GenerateAllTestGrammarsWithUiConfig.java
@@ -17,6 +17,7 @@ import org.apache.log4j.Logger;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.xtext.GenerateAllTestGrammars;
import org.eclipse.xtext.GeneratorFacade;
import org.eclipse.xtext.Grammar;
import org.eclipse.xtext.XtextGrammarTestLanguage;
@@ -68,8 +69,7 @@ public class GenerateAllTestGrammarsWithUiConfig {
XtextStandaloneSetup.doSetup();
GeneratorFacade.cleanFolder(uiPath + "/src-gen");
for (Class<?> clazz : testClasses) {
- String filename = "classpath:/" + clazz.getName().replace('.', '/')
- + ".xtext";
+ String filename = GenerateAllTestGrammars.getGrammarFileNameAsURI(clazz);
logger.info("loading " + filename);
ResourceSetImpl rs = new XtextResourceSet();
URI uri = URI.createURI(filename);