forked from jasder/antlr
Merge pull request #15 from wjkohnen/timeout2
runtime-testsuite/Go: timeout tests, honour GOROOT
This commit is contained in:
commit
6abe69f6e2
|
@ -66,6 +66,7 @@ import org.antlr.v4.tool.Rule;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.rules.TestRule;
|
import org.junit.rules.TestRule;
|
||||||
import org.junit.rules.TestWatcher;
|
import org.junit.rules.TestWatcher;
|
||||||
|
import org.junit.rules.Timeout;
|
||||||
import org.junit.runner.Description;
|
import org.junit.runner.Description;
|
||||||
import org.stringtemplate.v4.ST;
|
import org.stringtemplate.v4.ST;
|
||||||
import org.stringtemplate.v4.STGroup;
|
import org.stringtemplate.v4.STGroup;
|
||||||
|
@ -125,6 +126,9 @@ public abstract class BaseTest {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@org.junit.Rule
|
||||||
|
public final Timeout eachTimeout = new Timeout(60000);
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
// new output dir for each test
|
// new output dir for each test
|
||||||
|
@ -424,17 +428,23 @@ public abstract class BaseTest {
|
||||||
private String locateTool(String tool) {
|
private String locateTool(String tool) {
|
||||||
ArrayList<String> paths = new ArrayList<String>(); // default cap is about right
|
ArrayList<String> paths = new ArrayList<String>(); // default cap is about right
|
||||||
|
|
||||||
String pathEnv = System.getenv("PATH");
|
// GOROOT should have priority if set
|
||||||
if (pathEnv != null) {
|
|
||||||
paths.addAll(Arrays.asList(pathEnv.split(pathSep)));
|
|
||||||
}
|
|
||||||
String goroot = System.getenv("GOROOT");
|
String goroot = System.getenv("GOROOT");
|
||||||
if (goroot != null) {
|
if (goroot != null) {
|
||||||
paths.add(goroot + File.separatorChar + "bin");
|
paths.add(goroot + File.separatorChar + "bin");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String pathEnv = System.getenv("PATH");
|
||||||
|
if (pathEnv != null) {
|
||||||
|
paths.addAll(Arrays.asList(pathEnv.split(pathSep)));
|
||||||
|
}
|
||||||
|
|
||||||
|
// OS specific default locations of binary dist as last resort
|
||||||
|
paths.add("/usr/local/go/bin");
|
||||||
|
paths.add("c:\\Go\\bin");
|
||||||
|
|
||||||
for (String path : paths) {
|
for (String path : paths) {
|
||||||
File candidate = new File(path + File.separatorChar + tool);
|
File candidate = new File(new File(path), tool);
|
||||||
if (candidate.exists()) {
|
if (candidate.exists()) {
|
||||||
return candidate.getPath();
|
return candidate.getPath();
|
||||||
}
|
}
|
||||||
|
@ -443,7 +453,6 @@ public abstract class BaseTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String locateGo() {
|
private String locateGo() {
|
||||||
// typically /usr/local/go/bin
|
|
||||||
String propName = "antlr-go";
|
String propName = "antlr-go";
|
||||||
String prop = System.getProperty(propName);
|
String prop = System.getProperty(propName);
|
||||||
if (prop == null || prop.length() == 0) {
|
if (prop == null || prop.length() == 0) {
|
||||||
|
|
|
@ -655,7 +655,7 @@ func (d *DefaultErrorStrategy) escapeWSAndQuote(s string) string {
|
||||||
// reSync to one of those tokens. Note that FOLLOW(c)='^' and if
|
// reSync to one of those tokens. Note that FOLLOW(c)='^' and if
|
||||||
// we reSync'd to that token, we'd consume until EOF. We need to
|
// we reSync'd to that token, we'd consume until EOF. We need to
|
||||||
// Sync to context-sensitive FOLLOWs for a, b, and c: {']','^'}.
|
// Sync to context-sensitive FOLLOWs for a, b, and c: {']','^'}.
|
||||||
// In d case, for input "[]", LA(1) is ']' and in the set, so we would
|
// In this case, for input "[]", LA(1) is ']' and in the set, so we would
|
||||||
// not consume anything. After printing an error, rule c would
|
// not consume anything. After printing an error, rule c would
|
||||||
// return normally. Rule b would not find the required '^' though.
|
// return normally. Rule b would not find the required '^' though.
|
||||||
// At this point, it gets a mismatched token error and panics an
|
// At this point, it gets a mismatched token error and panics an
|
||||||
|
|
Loading…
Reference in New Issue