v4: Compile the generated listeners in BaseTest. Allow tests to specify extra options to the tool.

[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9497]
This commit is contained in:
sharwell 2011-11-30 09:34:32 -08:00
parent 8c3e8272d8
commit 49ea01136c
1 changed files with 7 additions and 3 deletions

View File

@ -345,7 +345,7 @@ public abstract class BaseTest {
/** Return true if all is ok, no errors */ /** Return true if all is ok, no errors */
protected boolean antlr(String fileName, String grammarFileName, String grammarStr, boolean debug) { protected boolean antlr(String fileName, String grammarFileName, String grammarStr, boolean debug, String... extraOptions) {
boolean allIsWell = true; boolean allIsWell = true;
System.out.println("dir "+tmpdir); System.out.println("dir "+tmpdir);
mkdir(tmpdir); mkdir(tmpdir);
@ -355,6 +355,7 @@ public abstract class BaseTest {
if ( debug ) { if ( debug ) {
options.add("-debug"); options.add("-debug");
} }
Collections.addAll(options, extraOptions);
options.add("-o"); options.add("-o");
options.add(tmpdir); options.add(tmpdir);
options.add("-lib"); options.add("-lib");
@ -523,10 +524,11 @@ public abstract class BaseTest {
String grammarStr, String grammarStr,
String parserName, String parserName,
String lexerName, String lexerName,
boolean debug) boolean debug,
String... extraOptions)
{ {
boolean allIsWell = boolean allIsWell =
antlr(grammarFileName, grammarFileName, grammarStr, debug); antlr(grammarFileName, grammarFileName, grammarStr, debug, extraOptions);
boolean ok; boolean ok;
if ( lexerName!=null ) { if ( lexerName!=null ) {
ok = compile(lexerName+".java"); ok = compile(lexerName+".java");
@ -535,6 +537,8 @@ public abstract class BaseTest {
if ( parserName!=null ) { if ( parserName!=null ) {
ok = compile(parserName+".java"); ok = compile(parserName+".java");
if ( !ok ) { allIsWell = false; } if ( !ok ) { allIsWell = false; }
ok = compile("Blank"+grammarFileName.substring(0, grammarFileName.lastIndexOf('.'))+"Listener.java");
if ( !ok ) { allIsWell = false; }
} }
return allIsWell; return allIsWell;
} }