small improvements to locating mono, node

This commit is contained in:
parrt 2016-11-19 14:05:43 -08:00
parent 978851f703
commit 79dbb8be96
4 changed files with 31 additions and 13 deletions

View File

@ -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

View File

@ -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;

View File

@ -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() {

View File

@ -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);
}