add UTF-8 encoding on all antlr runs during test, fix appveyor

This commit is contained in:
parrt 2016-11-22 10:00:28 -08:00
parent 68180117d7
commit 2cb02d9b43
7 changed files with 35 additions and 14 deletions

View File

@ -1,7 +1,7 @@
version: '4.5.4-SNAPSHOT+AppVeyor.{build}'
version: '4.6-SNAPSHOT+AppVeyor.{build}'
os: Windows Server 2012
build_script:
- mvn compile -q --batch-mode
- mvn -DskipTests install -q --batch-mode
test_script:
- mvn install -q -Dantlr-python2-python="C:\Python27\python.exe" -Dantlr-python3-python="C:\Python35\python.exe" -Dantlr-javascript-nodejs="C:\Program Files (x86)\nodejs\node.exe" --batch-mode
build:

View File

@ -81,7 +81,7 @@
<directory>../runtime</directory>
</resource>
</resources>
<plugins>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
@ -97,7 +97,7 @@
<include>${antlr.tests.swift}</include>
</includes>
</configuration>
</plugin>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
@ -109,10 +109,10 @@
</goals>
</execution>
</executions>
</plugin>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>includeSwiftTests</id>
@ -153,7 +153,7 @@
</configuration>
</execution>
</executions>
</plugin>
</plugin>
</plugins>
</build>
</profile>
@ -169,9 +169,9 @@
<include>**/Test*.java</include>
</includes>
</configuration>
</plugin>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</profile>
</profiles>
</project>

View File

@ -338,6 +338,10 @@ public class BaseGoTest implements RuntimeTestSupport {
options.add(tmpdir.getPath());
options.add("-lib");
options.add(tmpdir.getPath());
if ( !options.contains("-encoding") ) {
options.add("-encoding");
options.add("UTF-8");
}
options.add(new File(tmpdir, grammarFileName).getPath());
final String[] optionsA = new String[options.size()];

View File

@ -511,7 +511,8 @@ public class BaseJavaTest implements RuntimeTestSupport {
}
try {
antlrToolErrors.append(new String(Utils.readFile(tmpdir+"/"+grammarFileName)));
} catch (IOException ioe) {
}
catch (IOException ioe) {
antlrToolErrors.append(ioe.toString());
}
}
@ -690,11 +691,14 @@ public class BaseJavaTest implements RuntimeTestSupport {
if ( parserName!=null ) {
files.add(parserName+".java");
Set<String> optionsSet = new HashSet<String>(Arrays.asList(extraOptions));
String grammarName = grammarFileName.substring(0, grammarFileName.lastIndexOf('.'));
if (!optionsSet.contains("-no-listener")) {
files.add(grammarFileName.substring(0, grammarFileName.lastIndexOf('.'))+"BaseListener.java");
files.add(grammarName+"Listener.java");
files.add(grammarName+"BaseListener.java");
}
if (optionsSet.contains("-visitor")) {
files.add(grammarFileName.substring(0, grammarFileName.lastIndexOf('.'))+"BaseVisitor.java");
files.add(grammarName+"Visitor.java");
files.add(grammarName+"BaseVisitor.java");
}
}
boolean allIsWell = compile(files.toArray(new String[files.size()]));

View File

@ -274,6 +274,10 @@ public class BaseNodeTest implements RuntimeTestSupport {
options.add(tmpdir);
options.add("-lib");
options.add(tmpdir);
if ( !options.contains("-encoding") ) {
options.add("-encoding");
options.add("UTF-8");
}
options.add(new File(tmpdir, grammarFileName).toString());
final String[] optionsA = new String[options.size()];

View File

@ -369,6 +369,10 @@ public abstract class BasePythonTest implements RuntimeTestSupport {
options.add(tmpdir);
options.add("-lib");
options.add(tmpdir);
if ( !options.contains("-encoding") ) {
options.add("-encoding");
options.add("UTF-8");
}
options.add(new File(tmpdir,grammarFileName).toString());
final String[] optionsA = new String[options.size()];

View File

@ -367,7 +367,12 @@ public class ATNSerializer {
// don't adjust the first value since that's the version number
for (int i = 1; i < data.size(); i++) {
if (data.get(i) < Character.MIN_VALUE || data.get(i) > Character.MAX_VALUE) {
throw new UnsupportedOperationException("Serialized ATN data element out of range.");
throw new UnsupportedOperationException("Serialized ATN data element "+
data.get(i)+
" element "+i+" out of range "+
(int)Character.MIN_VALUE+
".."+
(int)Character.MAX_VALUE);
}
int value = (data.get(i) + 2) & 0xFFFF;