forked from jasder/antlr
simplify runtime test pom, add swift back in.
This commit is contained in:
parent
f83d03a93e
commit
e434560015
|
@ -79,107 +79,60 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<testSourceDirectory>test</testSourceDirectory>
|
<testSourceDirectory>test</testSourceDirectory>
|
||||||
<resources>
|
<resources>
|
||||||
<resource>
|
<resource>
|
||||||
<directory>resources</directory>
|
<directory>resources</directory>
|
||||||
</resource>
|
</resource>
|
||||||
<resource>
|
<resource>
|
||||||
<directory>../runtime</directory>
|
<directory>../runtime</directory>
|
||||||
</resource>
|
</resource>
|
||||||
</resources>
|
</resources>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
<version>2.19.1</version>
|
<version>2.19.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<includes>
|
<includes>
|
||||||
<include>**/csharp/Test*.java</include>
|
<include>${antlr.tests.swift}</include>
|
||||||
<include>**/java/Test*.java</include>
|
<include>**/csharp/Test*.java</include>
|
||||||
<include>**/go/Test*.java</include>
|
<include>**/java/Test*.java</include>
|
||||||
<include>**/javascript/node/Test*.java</include>
|
<include>**/go/Test*.java</include>
|
||||||
<include>**/python2/Test*.java</include>
|
<include>**/javascript/node/Test*.java</include>
|
||||||
<include>**/python3/Test*.java</include>
|
<include>**/python2/Test*.java</include>
|
||||||
<include>${antlr.tests.swift}</include>
|
<include>**/python3/Test*.java</include>
|
||||||
</includes>
|
<include>**/cpp/Test*.java</include>
|
||||||
</configuration>
|
</includes>
|
||||||
</plugin>
|
</configuration>
|
||||||
<plugin>
|
</plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<plugin>
|
||||||
<artifactId>maven-jar-plugin</artifactId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<version>2.4</version>
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
<executions>
|
<version>2.4</version>
|
||||||
<execution>
|
<executions>
|
||||||
<goals>
|
<execution>
|
||||||
<goal>test-jar</goal>
|
<goals>
|
||||||
</goals>
|
<goal>test-jar</goal>
|
||||||
</execution>
|
</goals>
|
||||||
</executions>
|
</execution>
|
||||||
</plugin>
|
</executions>
|
||||||
</plugins>
|
</plugin>
|
||||||
</build>
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
<profiles>
|
<profiles>
|
||||||
<profile>
|
<profile>
|
||||||
<id>includeSwiftTests</id>
|
<id>includeSwiftTests</id>
|
||||||
<activation>
|
<activation>
|
||||||
<os>
|
<os>
|
||||||
<family>mac</family>
|
<family>mac</family>
|
||||||
</os>
|
</os>
|
||||||
</activation>
|
</activation>
|
||||||
<properties>
|
<properties>
|
||||||
<antlr.tests.swift>**/swift/Test*.java</antlr.tests.swift>
|
<antlr.tests.swift>**/swift/Test*.java</antlr.tests.swift>
|
||||||
</properties>
|
</properties>
|
||||||
</profile>
|
</profile>
|
||||||
|
</profiles>
|
||||||
<profile>
|
|
||||||
<id>gen</id>
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.codehaus.mojo</groupId>
|
|
||||||
<artifactId>exec-maven-plugin</artifactId>
|
|
||||||
<version>1.4.0</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<phase>generate-test-sources</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>java</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<mainClass>org.antlr.v4.testgen.TestGenerator</mainClass>
|
|
||||||
<arguments>
|
|
||||||
<argument>-root</argument>
|
|
||||||
<argument>${basedir}</argument>
|
|
||||||
<argument>-outdir</argument>
|
|
||||||
<argument>${basedir}/test</argument>
|
|
||||||
<argument>-templates</argument>
|
|
||||||
<argument>${basedir}/resources/org/antlr/v4/test/runtime/templates</argument>
|
|
||||||
</arguments>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
</profile>
|
|
||||||
<profile>
|
|
||||||
<id>tests</id>
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
|
||||||
<configuration>
|
|
||||||
<includes>
|
|
||||||
<include>**/Test*.java</include>
|
|
||||||
</includes>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
</profile>
|
|
||||||
</profiles>
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -508,7 +508,7 @@ public class BaseCppTest implements RuntimeTestSupport {
|
||||||
return files;
|
return files;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String runProcess(ProcessBuilder builder, String description) throws Exception {
|
private String runProcess(ProcessBuilder builder, String description, boolean showStderr) throws Exception {
|
||||||
// System.out.println("BUILDER: "+builder.command());
|
// 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());
|
||||||
|
@ -521,10 +521,10 @@ 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 ( showStderr ) System.err.println(this.stderrDuringParse);
|
||||||
}
|
}
|
||||||
if (errcode != 0) {
|
if (errcode != 0) {
|
||||||
String err = "execution failed with error code: "+errcode;
|
String err = "execution of '"+description+"' failed with error code: "+errcode;
|
||||||
if ( this.stderrDuringParse!=null ) {
|
if ( this.stderrDuringParse!=null ) {
|
||||||
this.stderrDuringParse += err;
|
this.stderrDuringParse += err;
|
||||||
}
|
}
|
||||||
|
@ -536,11 +536,11 @@ public class BaseCppTest implements RuntimeTestSupport {
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String runCommand(String command[], String workPath, String description) throws Exception {
|
private String runCommand(String command[], String workPath, String description, boolean showStderr) throws Exception {
|
||||||
ProcessBuilder builder = new ProcessBuilder(command);
|
ProcessBuilder builder = new ProcessBuilder(command);
|
||||||
builder.directory(new File(workPath));
|
builder.directory(new File(workPath));
|
||||||
|
|
||||||
return runProcess(builder, description);
|
return runProcess(builder, description, showStderr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: add a buildRuntimeOnWindows variant.
|
// TODO: add a buildRuntimeOnWindows variant.
|
||||||
|
@ -550,8 +550,9 @@ public class BaseCppTest implements RuntimeTestSupport {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String command[] = { "cmake", ".", /*"-DCMAKE_CXX_COMPILER=clang++",*/ "-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", true) == null) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
System.err.println("can't configure antlr cpp runtime cmake file");
|
System.err.println("can't configure antlr cpp runtime cmake file");
|
||||||
|
@ -559,7 +560,7 @@ public class BaseCppTest implements RuntimeTestSupport {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String command[] = { "make", "-j", "8" }; // Assuming a reasonable amount of available CPU cores.
|
String command[] = { "make", "-j", "8" }; // Assuming a reasonable amount of available CPU cores.
|
||||||
if (runCommand(command, runtimePath, "building antlr runtime") == null)
|
if (runCommand(command, runtimePath, "building antlr runtime", true) == null)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
|
@ -593,7 +594,7 @@ public class BaseCppTest implements RuntimeTestSupport {
|
||||||
if ( !runtimeBuiltOnce ) {
|
if ( !runtimeBuiltOnce ) {
|
||||||
try {
|
try {
|
||||||
String command[] = {"clang++", "--version"};
|
String command[] = {"clang++", "--version"};
|
||||||
String output = runCommand(command, tmpdir, "printing compiler version");
|
String output = runCommand(command, tmpdir, "printing compiler version", false);
|
||||||
System.out.println("Compiler version is: "+output);
|
System.out.println("Compiler version is: "+output);
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
|
@ -613,7 +614,7 @@ public class BaseCppTest implements RuntimeTestSupport {
|
||||||
String libExtension = (getOS().equals("mac")) ? "dylib" : "so";
|
String libExtension = (getOS().equals("mac")) ? "dylib" : "so";
|
||||||
try {
|
try {
|
||||||
String command[] = { "ln", "-s", runtimePath + "/dist/libantlr4-runtime." + libExtension };
|
String command[] = { "ln", "-s", runtimePath + "/dist/libantlr4-runtime." + libExtension };
|
||||||
if (runCommand(command, tmpdir, "sym linking C++ runtime") == null)
|
if (runCommand(command, tmpdir, "sym linking C++ runtime", true) == null)
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
|
@ -625,7 +626,7 @@ public class BaseCppTest implements RuntimeTestSupport {
|
||||||
try {
|
try {
|
||||||
List<String> command2 = new ArrayList<String>(Arrays.asList("clang++", "-std=c++11", "-I", includePath, "-L.", "-lantlr4-runtime", "-o", "a.out"));
|
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", true) == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -642,7 +643,7 @@ public class BaseCppTest implements RuntimeTestSupport {
|
||||||
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." + libExtension);
|
env.put("LD_PRELOAD", runtimePath + "/dist/libantlr4-runtime." + libExtension);
|
||||||
String output = runProcess(builder, "running test binary");
|
String output = runProcess(builder, "running test binary", false);
|
||||||
if ( output.length()==0 ) {
|
if ( output.length()==0 ) {
|
||||||
output = null;
|
output = null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue