diff --git a/tool/test/org/antlr/v4/test/BaseTest.java b/tool/test/org/antlr/v4/test/BaseTest.java index 2261b40ea..f811e4568 100644 --- a/tool/test/org/antlr/v4/test/BaseTest.java +++ b/tool/test/org/antlr/v4/test/BaseTest.java @@ -358,37 +358,39 @@ public abstract class BaseTest { System.out.println("dir "+tmpdir); mkdir(tmpdir); writeFile(tmpdir, fileName, grammarStr); + ErrorQueue equeue = new ErrorQueue(); + final List options = new ArrayList(); + Collections.addAll(options, extraOptions); + options.add("-o"); + options.add(tmpdir); + options.add("-lib"); + options.add(tmpdir); + options.add(new File(tmpdir,grammarFileName).toString()); try { - final List options = new ArrayList(); - Collections.addAll(options, extraOptions); - options.add("-o"); - options.add(tmpdir); - options.add("-lib"); - options.add(tmpdir); - options.add(new File(tmpdir,grammarFileName).toString()); final String[] optionsA = new String[options.size()]; options.toArray(optionsA); - ErrorQueue equeue = new ErrorQueue(); Tool antlr = newTool(optionsA); antlr.addListener(equeue); antlr.processGrammarsOnCommandLine(); - if ( equeue.errors.size()>0 ) { - allIsWell = false; - System.err.println("antlr reports errors from "+options); - for (int i = 0; i < equeue.errors.size(); i++) { - ANTLRMessage msg = equeue.errors.get(i); - System.err.println(msg); - } - System.out.println("!!!\ngrammar:"); - System.out.println(grammarStr); - System.out.println("###"); - } } catch (Exception e) { allIsWell = false; System.err.println("problems building grammar: "+e); e.printStackTrace(System.err); } + + if ( equeue.errors.size()>0 ) { + allIsWell = false; + System.err.println("antlr reports errors from "+options); + for (int i = 0; i < equeue.errors.size(); i++) { + ANTLRMessage msg = equeue.errors.get(i); + System.err.println(msg); + } + System.out.println("!!!\ngrammar:"); + System.out.println(grammarStr); + System.out.println("###"); + } + return allIsWell; }