forked from jasder/antlr
small improvements to locating mono, node
This commit is contained in:
parent
978851f703
commit
79dbb8be96
|
@ -130,9 +130,12 @@ Note that ANTLR is written in itself, which is why maven downloads antlr4-4.5.ja
|
||||||
|
|
||||||
## Running test subsets
|
## Running test subsets
|
||||||
|
|
||||||
|
*From the `runtime-testsuite` dir*
|
||||||
|
|
||||||
### Run one test group across targets
|
### Run one test group across targets
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
$ cd runtime-testsuite
|
||||||
$ mvn -Dtest=TestParserExec test
|
$ mvn -Dtest=TestParserExec test
|
||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
T E S T S
|
T E S T S
|
||||||
|
|
|
@ -494,7 +494,7 @@ public class BaseCSharpTest implements RuntimeTestSupport, SpecialRuntimeTestAss
|
||||||
}
|
}
|
||||||
|
|
||||||
private String locateTool(String tool) {
|
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) {
|
for(String root : roots) {
|
||||||
if(new File(root + tool).exists())
|
if(new File(root + tool).exists())
|
||||||
return root + tool;
|
return root + tool;
|
||||||
|
|
|
@ -450,22 +450,36 @@ public class BaseNodeTest implements RuntimeTestSupport {
|
||||||
return null;
|
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() {
|
private String locateNodeJS() {
|
||||||
// typically /usr/local/bin/node
|
// typically /usr/local/bin/node
|
||||||
String propName = "antlr-javascript-nodejs";
|
String propName = "antlr-javascript-nodejs";
|
||||||
String prop = System.getProperty(propName);
|
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 ) {
|
||||||
}
|
|
||||||
if ( prop==null ) {
|
|
||||||
prop = locateTool("node"); // seems to be node on mac
|
|
||||||
}
|
|
||||||
File file = new File(prop);
|
|
||||||
if (!file.exists()) {
|
|
||||||
throw new RuntimeException("Missing system property:" + propName);
|
|
||||||
}
|
|
||||||
return prop;
|
return prop;
|
||||||
}
|
}
|
||||||
|
if (canExecute("nodejs")) {
|
||||||
|
return "nodejs"; // nodejs on Debian without node-legacy package
|
||||||
|
}
|
||||||
|
return "node"; // everywhere else
|
||||||
|
}
|
||||||
|
|
||||||
private String locateRuntime() {
|
private String locateRuntime() {
|
||||||
final ClassLoader loader = Thread.currentThread().getContextClassLoader();
|
final ClassLoader loader = Thread.currentThread().getContextClassLoader();
|
||||||
|
|
|
@ -592,10 +592,11 @@ public abstract class BasePythonTest implements RuntimeTestSupport {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String locateTool(String tool) {
|
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) {
|
for(String root : roots) {
|
||||||
if(new File(root + tool).exists())
|
if(new File(root + tool).exists()) {
|
||||||
return root + tool;
|
return root+tool;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
throw new RuntimeException("Could not locate " + tool);
|
throw new RuntimeException("Could not locate " + tool);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue