diff --git a/runtime-testsuite/pom.xml b/runtime-testsuite/pom.xml index 50555409f..a1aa8ac96 100644 --- a/runtime-testsuite/pom.xml +++ b/runtime-testsuite/pom.xml @@ -79,107 +79,60 @@ - - test - - - resources - - - ../runtime - - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.19.1 - - - **/csharp/Test*.java - **/java/Test*.java - **/go/Test*.java - **/javascript/node/Test*.java - **/python2/Test*.java - **/python3/Test*.java - ${antlr.tests.swift} - - - - - org.apache.maven.plugins - maven-jar-plugin - 2.4 - - - - test-jar - - - - - - + + test + + + resources + + + ../runtime + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.19.1 + + + ${antlr.tests.swift} + **/csharp/Test*.java + **/java/Test*.java + **/go/Test*.java + **/javascript/node/Test*.java + **/python2/Test*.java + **/python3/Test*.java + **/cpp/Test*.java + + + + + org.apache.maven.plugins + maven-jar-plugin + 2.4 + + + + test-jar + + + + + + - - - includeSwiftTests - - - mac - - - - **/swift/Test*.java - - - - - gen - - - - org.codehaus.mojo - exec-maven-plugin - 1.4.0 - - - generate-test-sources - - java - - - org.antlr.v4.testgen.TestGenerator - - -root - ${basedir} - -outdir - ${basedir}/test - -templates - ${basedir}/resources/org/antlr/v4/test/runtime/templates - - - - - - - - - - tests - - - - org.apache.maven.plugins - maven-surefire-plugin - - - **/Test*.java - - - - - - - + + + includeSwiftTests + + + mac + + + + **/swift/Test*.java + + + diff --git a/runtime-testsuite/test/org/antlr/v4/test/runtime/cpp/BaseCppTest.java b/runtime-testsuite/test/org/antlr/v4/test/runtime/cpp/BaseCppTest.java index 146812f8f..9673414e4 100644 --- a/runtime-testsuite/test/org/antlr/v4/test/runtime/cpp/BaseCppTest.java +++ b/runtime-testsuite/test/org/antlr/v4/test/runtime/cpp/BaseCppTest.java @@ -508,7 +508,7 @@ public class BaseCppTest implements RuntimeTestSupport { 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()); Process process = builder.start(); StreamVacuum stdoutVacuum = new StreamVacuum(process.getInputStream()); @@ -521,10 +521,10 @@ public class BaseCppTest implements RuntimeTestSupport { String output = stdoutVacuum.toString(); if ( stderrVacuum.toString().length()>0 ) { this.stderrDuringParse = stderrVacuum.toString(); -// System.err.println(this.stderrDuringParse); + if ( showStderr ) System.err.println(this.stderrDuringParse); } 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 ) { this.stderrDuringParse += err; } @@ -536,11 +536,11 @@ public class BaseCppTest implements RuntimeTestSupport { 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); builder.directory(new File(workPath)); - return runProcess(builder, description); + return runProcess(builder, description, showStderr); } // TODO: add a buildRuntimeOnWindows variant. @@ -550,8 +550,9 @@ public class BaseCppTest implements RuntimeTestSupport { try { 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; + } } catch (Exception e) { System.err.println("can't configure antlr cpp runtime cmake file"); @@ -559,7 +560,7 @@ public class BaseCppTest implements RuntimeTestSupport { try { 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; } catch (Exception e) { @@ -593,7 +594,7 @@ public class BaseCppTest implements RuntimeTestSupport { if ( !runtimeBuiltOnce ) { try { 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); } catch (Exception e) { @@ -613,7 +614,7 @@ public class BaseCppTest implements RuntimeTestSupport { String libExtension = (getOS().equals("mac")) ? "dylib" : "so"; try { 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; } catch (Exception e) { @@ -625,7 +626,7 @@ public class BaseCppTest implements RuntimeTestSupport { try { List command2 = new ArrayList(Arrays.asList("clang++", "-std=c++11", "-I", includePath, "-L.", "-lantlr4-runtime", "-o", "a.out")); 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; } } @@ -642,7 +643,7 @@ public class BaseCppTest implements RuntimeTestSupport { builder.directory(new File(tmpdir)); Map env = builder.environment(); 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 ) { output = null; }