merge old and new travis; improve so it runs C++ on osx; update BaseSwiftTest so it mirrors other targets; remove unneeded dep in pom to some json stuff

This commit is contained in:
parrt 2016-11-20 19:50:54 -08:00
parent e0b326677b
commit 66be087c38
9 changed files with 84 additions and 78 deletions

View File

@ -1,30 +1,26 @@
sudo: true sudo: true
language: java
matrix:
include:
- os: linux
jdk: oraclejdk8
- os: osx
osx_image: xcode8
script:
- mvn -Dparallel=methods -DthreadCount=4 install
jdk:
- oraclejdk7
- oraclejdk8
before_install:
- if [[ $TRAVIS_OS_NAME == osx ]]; then ./travis/before_install-macos.sh; fi
- if [[ $TRAVIS_OS_NAME == linux ]]; then ./travis/before_install-linux.sh; fi
env: env:
- CXX=g++-5 - CXX=g++-5
compiler: matrix:
- clang include:
- os: linux
compiler: clang
language: java
jdk: oraclejdk7
- os: osx
compiler: clang
language: java
osx_image: xcode8.1
script:
- if [[ $TRAVIS_OS_NAME == osx ]]; then cd runtime-testsuite; ../.travis/run-tests-macos.sh; fi
- if [[ $TRAVIS_OS_NAME == linux ]]; then cd runtime-testsuite; ../.travis/run-tests-linux.sh; fi
before_install:
- if [[ $TRAVIS_OS_NAME == osx ]]; then ./.travis/before-install-macos.sh; fi
- if [[ $TRAVIS_OS_NAME == linux ]]; then ./.travis/before-install-linux.sh; fi
addons: addons:
apt: apt:

View File

@ -2,8 +2,6 @@
set -euo pipefail set -euo pipefail
thisdir=$(dirname $(readlink -f "$0"))
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
sudo add-apt-repository ppa:fkrull/deadsnakes -y sudo add-apt-repository ppa:fkrull/deadsnakes -y
sudo add-apt-repository ppa:rwky/nodejs -y sudo add-apt-repository ppa:rwky/nodejs -y
@ -14,4 +12,6 @@ echo "deb http://download.mono-project.com/repo/debian wheezy/snapshots/3.12.1 m
sudo apt-get install -qq mono-complete sudo apt-get install -qq mono-complete
eval "$(sudo gimme 1.7.3)" eval "$(sudo gimme 1.7.3)"
"$thisdir/before_install-common.sh" ( go version ; go env ) || true
python --version
python3 --version

View File

@ -5,11 +5,13 @@ set -euo pipefail
thisdir=$(dirname "$0") thisdir=$(dirname "$0")
brew update brew update
brew install mono python3 brew install mono python3 cmake
# Work around apparent rvm bug that is in Travis's Xcode image. # Work around apparent rvm bug that is in Travis's Xcode image.
# https://github.com/direnv/direnv/issues/210 # https://github.com/direnv/direnv/issues/210
# https://github.com/travis-ci/travis-ci/issues/6307 # https://github.com/travis-ci/travis-ci/issues/6307
shell_session_update() { :; } shell_session_update() { :; }
"$thisdir/before_install-common.sh" ( go version ; go env ) || true
python --version
python3 --version

9
.travis/run-tests-linux.sh Executable file
View File

@ -0,0 +1,9 @@
#!/bin/bash
mvn -Dtest=java.* test
mvn -Dtest=csharp.* test
mvn -Dtest=python2.* test
mvn -Dtest=python3.* test
mvn -Dtest=node.* test
mvn -Dtest=go.* test
mvn -Dtest=cpp.* test

10
.travis/run-tests-macos.sh Executable file
View File

@ -0,0 +1,10 @@
#!/bin/bash
mvn -Dtest=java.* test
mvn -Dtest=csharp.* test
mvn -Dtest=python2.* test
mvn -Dtest=python3.* test
mvn -Dtest=node.* test
mvn -Dtest=go.* test
mvn -Dtest=cpp.* test
mvn -Dtest=swift.* test

View File

@ -582,6 +582,7 @@ public class BaseCppTest implements RuntimeTestSupport {
} }
private String runProcess(ProcessBuilder builder, String description) throws Exception { private String runProcess(ProcessBuilder builder, String description) throws Exception {
// System.out.println("BUILDER: "+builder.command());
Process process = builder.start(); Process process = builder.start();
StreamVacuum stdoutVacuum = new StreamVacuum(process.getInputStream()); StreamVacuum stdoutVacuum = new StreamVacuum(process.getInputStream());
StreamVacuum stderrVacuum = new StreamVacuum(process.getErrorStream()); StreamVacuum stderrVacuum = new StreamVacuum(process.getErrorStream());
@ -593,6 +594,7 @@ public class BaseCppTest implements RuntimeTestSupport {
String output = stdoutVacuum.toString(); String output = stdoutVacuum.toString();
if ( stderrVacuum.toString().length()>0 ) { if ( stderrVacuum.toString().length()>0 ) {
this.stderrDuringParse = stderrVacuum.toString(); this.stderrDuringParse = stderrVacuum.toString();
System.err.println(this.stderrDuringParse);
} }
if (errcode != 0) { if (errcode != 0) {
String err = "execution failed with error code: "+errcode; String err = "execution failed with error code: "+errcode;
@ -620,7 +622,7 @@ public class BaseCppTest implements RuntimeTestSupport {
System.out.println("Building ANTLR4 C++ runtime (if necessary) at "+ runtimePath); System.out.println("Building ANTLR4 C++ runtime (if necessary) at "+ runtimePath);
try { try {
String command[] = { "cmake", ".", "-DCMAKE_BUILD_TYPE=release" }; String command[] = { "cmake", ".", "-DCMAKE_CXX_COMPILER=clang++", "-DCMAKE_BUILD_TYPE=release" };
if (runCommand(command, runtimePath, "antlr runtime cmake") == null) if (runCommand(command, runtimePath, "antlr runtime cmake") == null)
return false; return false;
} }
@ -688,11 +690,13 @@ public class BaseCppTest implements RuntimeTestSupport {
return null; return null;
} }
catch (Exception e) { catch (Exception e) {
System.err.println("can't exec module: " + fileName); System.err.println("can't create link to " + runtimePath + "/dist/libantlr4-runtime." + libExtension);
e.printStackTrace(System.err);
return null;
} }
try { try {
List<String> command2 = new ArrayList<String>(Arrays.asList("clang++", "-std=c++11", "-I", includePath, "-L.", "-lantlr4-runtime")); List<String> command2 = new ArrayList<String>(Arrays.asList("clang++", "-std=c++11", "-I", includePath, "-L.", "-lantlr4-runtime", "-o", "a.out"));
command2.addAll(allCppFiles(tmpdir)); command2.addAll(allCppFiles(tmpdir));
if (runCommand(command2.toArray(new String[0]), tmpdir, "building test binary") == null) { if (runCommand(command2.toArray(new String[0]), tmpdir, "building test binary") == null) {
return null; return null;
@ -700,6 +704,7 @@ public class BaseCppTest implements RuntimeTestSupport {
} }
catch (Exception e) { catch (Exception e) {
System.err.println("can't compile test module: " + e.getMessage()); System.err.println("can't compile test module: " + e.getMessage());
e.printStackTrace(System.err);
return null; return null;
} }
@ -709,7 +714,7 @@ public class BaseCppTest implements RuntimeTestSupport {
ProcessBuilder builder = new ProcessBuilder(binPath, inputPath); ProcessBuilder builder = new ProcessBuilder(binPath, inputPath);
builder.directory(new File(tmpdir)); builder.directory(new File(tmpdir));
Map<String, String> env = builder.environment(); Map<String, String> env = builder.environment();
env.put("LD_PRELOAD", runtimePath + "/dist/libantlr4-runtime.so"); // For linux. env.put("LD_PRELOAD", runtimePath + "/dist/libantlr4-runtime." + libExtension);
String output = runProcess(builder, "running test binary"); String output = runProcess(builder, "running test binary");
if ( output.length()==0 ) { if ( output.length()==0 ) {
output = null; output = null;
@ -723,7 +728,8 @@ public class BaseCppTest implements RuntimeTestSupport {
return output; return output;
} }
catch (Exception e) { catch (Exception e) {
System.err.println("can't exec module: " + fileName + "\nerror is: "+ e.getMessage()); System.err.println("can't exec module: " + fileName);
e.printStackTrace(System.err);
} }
return null; return null;

View File

@ -23,6 +23,7 @@ import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import static org.antlr.v4.test.runtime.java.BaseJavaTest.antlrLock;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
public class BaseSwiftTest implements RuntimeTestSupport { public class BaseSwiftTest implements RuntimeTestSupport {
@ -77,10 +78,9 @@ public class BaseSwiftTest implements RuntimeTestSupport {
//compile Antlr4 module //compile Antlr4 module
buildAntlr4Framework(); buildAntlr4Framework();
String argsString; String argsString;
} catch (IOException e) { }
System.out.println(e.getMessage()); catch (Exception e) {
} catch (Exception e) { e.printStackTrace(System.err);
e.printStackTrace();
} }
Runtime.getRuntime().addShutdownHook(new Thread() { Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() { public void run() {
@ -138,8 +138,10 @@ public class BaseSwiftTest implements RuntimeTestSupport {
buf.append('\n'); buf.append('\n');
line = in.readLine(); line = in.readLine();
} }
} catch (IOException ioe) { }
catch (IOException ioe) {
System.err.println("can't read output from process"); System.err.println("can't read output from process");
ioe.printStackTrace(System.err);
} }
} }
@ -230,9 +232,6 @@ public class BaseSwiftTest implements RuntimeTestSupport {
compile(); compile();
String output = execTest(); String output = execTest();
if (stderrDuringParse != null && stderrDuringParse.length() > 0) {
System.err.println(stderrDuringParse);
}
return output; return output;
} }
@ -257,10 +256,10 @@ public class BaseSwiftTest implements RuntimeTestSupport {
} }
if (stderrVacuum.toString().length() > 0) { if (stderrVacuum.toString().length() > 0) {
this.stderrDuringParse = stderrVacuum.toString(); this.stderrDuringParse = stderrVacuum.toString();
System.err.println("execTest stderrVacuum: " + stderrVacuum);
} }
return output; return output;
} catch (Exception e) { }
catch (Exception e) {
System.err.println("can't exec recognizer"); System.err.println("can't exec recognizer");
e.printStackTrace(System.err); e.printStackTrace(System.err);
} }
@ -293,7 +292,7 @@ public class BaseSwiftTest implements RuntimeTestSupport {
private static boolean runProcess(String argsString, String execPath) throws IOException, InterruptedException { private static boolean runProcess(String argsString, String execPath) throws IOException, InterruptedException {
String[] args = argsString.split(" "); String[] args = argsString.split(" ");
System.err.println("Starting build " + argsString);//Utils.join(args, " ")) // System.err.println("Starting build " + argsString);//Utils.join(args, " "))
Process process = Runtime.getRuntime().exec(args, null, new File(execPath)); Process process = Runtime.getRuntime().exec(args, null, new File(execPath));
StreamVacuum stdoutVacuum = new StreamVacuum(process.getInputStream()); StreamVacuum stdoutVacuum = new StreamVacuum(process.getInputStream());
StreamVacuum stderrVacuum = new StreamVacuum(process.getErrorStream()); StreamVacuum stderrVacuum = new StreamVacuum(process.getErrorStream());
@ -519,18 +518,18 @@ public class BaseSwiftTest implements RuntimeTestSupport {
} }
protected ErrorQueue antlr(String grammarFileName, boolean defaultListener, String... extraOptions) { protected ErrorQueue antlr(String grammarFileName, boolean defaultListener, String... extraOptions) {
final List<String> options = new ArrayList<>(); final List<String> options = new ArrayList<String>();
Collections.addAll(options, extraOptions); Collections.addAll(options, extraOptions);
options.add("-Dlanguage=Swift"); options.add("-Dlanguage=Swift");
if (!options.contains("-o")) { if ( !options.contains("-o") ) {
options.add("-o"); options.add("-o");
options.add(tmpdir); options.add(tmpdir);
} }
if (!options.contains("-lib")) { if ( !options.contains("-lib") ) {
options.add("-lib"); options.add("-lib");
options.add(tmpdir); options.add(tmpdir);
} }
if (!options.contains("-encoding")) { if ( !options.contains("-encoding") ) {
options.add("-encoding"); options.add("-encoding");
options.add("UTF-8"); options.add("UTF-8");
} }
@ -541,26 +540,28 @@ public class BaseSwiftTest implements RuntimeTestSupport {
Tool antlr = newTool(optionsA); Tool antlr = newTool(optionsA);
ErrorQueue equeue = new ErrorQueue(antlr); ErrorQueue equeue = new ErrorQueue(antlr);
antlr.addListener(equeue); antlr.addListener(equeue);
if (defaultListener) { if ( defaultListener ) {
antlr.addListener(new DefaultToolListener(antlr)); antlr.addListener(new DefaultToolListener(antlr));
} }
antlr.processGrammarsOnCommandLine(); synchronized (antlrLock) {
antlr.processGrammarsOnCommandLine();
}
if (!defaultListener && !equeue.errors.isEmpty()) { if ( !defaultListener && !equeue.errors.isEmpty() ) {
for (int i = 0; i < equeue.errors.size(); i++) { for (int i = 0; i<equeue.errors.size(); i++) {
ANTLRMessage msg = equeue.errors.get(i); ANTLRMessage msg = equeue.errors.get(i);
System.err.println(msg); antlrToolErrors.append(msg.toString());
} }
try { try {
System.out.println(new String(Utils.readFile(tmpdir + "/" + grammarFileName))); antlrToolErrors.append(new String(Utils.readFile(tmpdir+"/"+grammarFileName)));
} catch (IOException ioe) { } catch (IOException ioe) {
System.err.println(ioe.toString()); antlrToolErrors.append(ioe.toString());
} }
} }
if (!defaultListener && !equeue.warnings.isEmpty()) { if ( !defaultListener && !equeue.warnings.isEmpty() ) {
for (int i = 0; i < equeue.warnings.size(); i++) { for (int i = 0; i<equeue.warnings.size(); i++) {
ANTLRMessage msg = equeue.warnings.get(i); ANTLRMessage msg = equeue.warnings.get(i);
System.err.println(msg); // antlrToolErrors.append(msg); warnings are hushed
} }
} }
@ -568,7 +569,6 @@ public class BaseSwiftTest implements RuntimeTestSupport {
} }
protected ErrorQueue antlr(String grammarFileName, String grammarStr, boolean defaultListener, String... extraOptions) { protected ErrorQueue antlr(String grammarFileName, String grammarStr, boolean defaultListener, String... extraOptions) {
System.out.println("dir " + tmpdir);
mkdir(tmpdir); mkdir(tmpdir);
writeFile(tmpdir, grammarFileName, grammarStr); writeFile(tmpdir, grammarFileName, grammarStr);
return antlr(grammarFileName, defaultListener, extraOptions); return antlr(grammarFileName, defaultListener, extraOptions);

View File

@ -51,20 +51,10 @@
<version>1.0.1</version> <version>1.0.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>javax.json</groupId> <groupId>javax.json</groupId>
<artifactId>javax.json-api</artifactId> <artifactId>javax.json-api</artifactId>
<version>1.0</version> <version>RELEASE</version>
</dependency> </dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.json</artifactId>
<version>1.0.4</version>
</dependency>
<dependency>
<groupId>javax.json</groupId>
<artifactId>javax.json-api</artifactId>
<version>RELEASE</version>
</dependency>
</dependencies> </dependencies>
<build> <build>

View File

@ -1,7 +0,0 @@
#!/bin/bash
set -euo pipefail
( go version ; go env ) || true
python --version
python3 --version