diff --git a/runtime-testsuite/test/org/antlr/v4/test/runtime/go/BaseTest.java b/runtime-testsuite/test/org/antlr/v4/test/runtime/go/BaseTest.java index 178634b2a..a25ce39a4 100644 --- a/runtime-testsuite/test/org/antlr/v4/test/runtime/go/BaseTest.java +++ b/runtime-testsuite/test/org/antlr/v4/test/runtime/go/BaseTest.java @@ -66,6 +66,7 @@ import org.antlr.v4.tool.Rule; import org.junit.Before; import org.junit.rules.TestRule; import org.junit.rules.TestWatcher; +import org.junit.rules.Timeout; import org.junit.runner.Description; import org.stringtemplate.v4.ST; import org.stringtemplate.v4.STGroup; @@ -125,6 +126,9 @@ public abstract class BaseTest { }; + @org.junit.Rule + public final Timeout eachTimeout = new Timeout(60000); + @Before public void setUp() throws Exception { // new output dir for each test @@ -424,17 +428,23 @@ public abstract class BaseTest { private String locateTool(String tool) { ArrayList paths = new ArrayList(); // default cap is about right - String pathEnv = System.getenv("PATH"); - if (pathEnv != null) { - paths.addAll(Arrays.asList(pathEnv.split(pathSep))); - } + // GOROOT should have priority if set String goroot = System.getenv("GOROOT"); if (goroot != null) { 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) { - File candidate = new File(path + File.separatorChar + tool); + File candidate = new File(new File(path), tool); if (candidate.exists()) { return candidate.getPath(); } @@ -443,7 +453,6 @@ public abstract class BaseTest { } private String locateGo() { - // typically /usr/local/go/bin String propName = "antlr-go"; String prop = System.getProperty(propName); if (prop == null || prop.length() == 0) { diff --git a/runtime/Go/antlr/error_strategy.go b/runtime/Go/antlr/error_strategy.go index db9ebcfeb..89262b7d3 100644 --- a/runtime/Go/antlr/error_strategy.go +++ b/runtime/Go/antlr/error_strategy.go @@ -655,7 +655,7 @@ func (d *DefaultErrorStrategy) escapeWSAndQuote(s string) string { // 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 // 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 // return normally. Rule b would not find the required '^' though. // At this point, it gets a mismatched token error and panics an