diff --git a/doc/building-antlr.md b/doc/building-antlr.md index b0d844760..be98fe612 100644 --- a/doc/building-antlr.md +++ b/doc/building-antlr.md @@ -130,9 +130,12 @@ Note that ANTLR is written in itself, which is why maven downloads antlr4-4.5.ja ## Running test subsets +*From the `runtime-testsuite` dir* + ### Run one test group across targets ```bash +$ cd runtime-testsuite $ mvn -Dtest=TestParserExec test ------------------------------------------------------- T E S T S diff --git a/runtime-testsuite/test/org/antlr/v4/test/runtime/csharp/BaseCSharpTest.java b/runtime-testsuite/test/org/antlr/v4/test/runtime/csharp/BaseCSharpTest.java index 335b7c743..3f0e184ef 100644 --- a/runtime-testsuite/test/org/antlr/v4/test/runtime/csharp/BaseCSharpTest.java +++ b/runtime-testsuite/test/org/antlr/v4/test/runtime/csharp/BaseCSharpTest.java @@ -494,7 +494,7 @@ public class BaseCSharpTest implements RuntimeTestSupport, SpecialRuntimeTestAss } private String locateTool(String tool) { - String[] roots = { "/usr/bin/", "/usr/local/bin/" }; + String[] roots = { "/opt/local/bin/", "/usr/bin/", "/usr/local/bin/" }; for(String root : roots) { if(new File(root + tool).exists()) return root + tool; diff --git a/runtime-testsuite/test/org/antlr/v4/test/runtime/javascript/node/BaseNodeTest.java b/runtime-testsuite/test/org/antlr/v4/test/runtime/javascript/node/BaseNodeTest.java index c9a89f860..2db5b9099 100644 --- a/runtime-testsuite/test/org/antlr/v4/test/runtime/javascript/node/BaseNodeTest.java +++ b/runtime-testsuite/test/org/antlr/v4/test/runtime/javascript/node/BaseNodeTest.java @@ -450,21 +450,35 @@ public class BaseNodeTest implements RuntimeTestSupport { return null; } + private boolean canExecute(String tool) { + try { + ProcessBuilder builder = new ProcessBuilder(tool, "--version"); + builder.redirectErrorStream(true); + Process process = builder.start(); + StreamVacuum vacuum = new StreamVacuum(process.getInputStream()); + vacuum.start(); + process.waitFor(); + vacuum.join(); + return process.exitValue() == 0; + } + catch (Exception e) { + ; + } + return false; + } + private String locateNodeJS() { // typically /usr/local/bin/node String propName = "antlr-javascript-nodejs"; String prop = System.getProperty(propName); - if (prop == null || prop.length() == 0) { - prop = locateTool("nodejs"); // seems to be nodejs on ubuntu + + if ( prop!=null && prop.length()!=0 ) { + return prop; } - if ( prop==null ) { - prop = locateTool("node"); // seems to be node on mac + if (canExecute("nodejs")) { + return "nodejs"; // nodejs on Debian without node-legacy package } - File file = new File(prop); - if (!file.exists()) { - throw new RuntimeException("Missing system property:" + propName); - } - return prop; + return "node"; // everywhere else } private String locateRuntime() { diff --git a/runtime-testsuite/test/org/antlr/v4/test/runtime/python/BasePythonTest.java b/runtime-testsuite/test/org/antlr/v4/test/runtime/python/BasePythonTest.java index 28179f06b..90de0ee64 100644 --- a/runtime-testsuite/test/org/antlr/v4/test/runtime/python/BasePythonTest.java +++ b/runtime-testsuite/test/org/antlr/v4/test/runtime/python/BasePythonTest.java @@ -592,10 +592,11 @@ public abstract class BasePythonTest implements RuntimeTestSupport { } private String locateTool(String tool) { - String[] roots = { "/usr/bin/", "/usr/local/bin/" }; + String[] roots = { "/opt/local/bin", "/usr/bin/", "/usr/local/bin/" }; for(String root : roots) { - if(new File(root + tool).exists()) - return root + tool; + if(new File(root + tool).exists()) { + return root+tool; + } } throw new RuntimeException("Could not locate " + tool); }