Re: cvs commit: ant/src/testcases/org/apache/tools/ant/taskdefs/optional ANTLRTest.java

2003-04-01 Thread Stefan Bodewig
Note that test8 is now going to fail.

test8 expects a BuildException to be thrown because the supergrammar
file didn't exist.  The real reason for the exception that has been
thrown so far was that the outputdirectory didn't exist, I've fixed
that.

Now antlr will pront a warning error: file non-existant-file.g not found
but return with an exit code of 0 so the task doesn't see an error.

We will have to parse the output, I'm afraid.

I wonder whether the now modified test would have passed with ANTLR
2.7.1 or whether it has been broken since its creation.

Stefan


cvs commit: ant/src/testcases/org/apache/tools/ant/taskdefs/optional ANTLRTest.java

2003-04-01 Thread bodewig
bodewig 2003/04/01 06:33:29

  Modified:src/etc/testcases/taskdefs/optional/antlr antlr.xml
   src/main/org/apache/tools/ant/taskdefs/optional ANTLR.java
   src/testcases/org/apache/tools/ant/taskdefs/optional
ANTLRTest.java
  Log:
  demonstrate bug 12961
  
  Revision  ChangesPath
  1.9   +19 -0 ant/src/etc/testcases/taskdefs/optional/antlr/antlr.xml
  
  Index: antlr.xml
  ===
  RCS file: /home/cvs/ant/src/etc/testcases/taskdefs/optional/antlr/antlr.xml,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- antlr.xml 1 Apr 2003 10:54:36 -   1.8
  +++ antlr.xml 1 Apr 2003 14:33:28 -   1.9
  @@ -73,6 +73,25 @@
   antlr target=antlr.g outputdirectory=${tmp.dir} traceLexer=yes 
traceParser=yes traceTreeWalker=yes/
 /target
   
  +  !-- test9 will have been run before that --
  +  target name=noRecompile
  +antlr target=${tmp.dir}/extended.calc.g glib=${tmp.dir}/antlr.g/
  +  /target
  +
  +  !-- test9 will have been run before that --
  +  target name=normalRecompile
  +sleep seconds=2/
  +touch file=${tmp.dir}/extended.calc.g/
  +antlr target=${tmp.dir}/extended.calc.g glib=${tmp.dir}/antlr.g/
  +  /target
  +
  +  !-- test9 will have been run before that --
  +  target name=supergrammarChangeRecompile
  +sleep seconds=2/
  +touch file=${tmp.dir}/antlr.g/
  +antlr target=${tmp.dir}/extended.calc.g glib=${tmp.dir}/antlr.g/
  +  /target
  +
 target name=cleanup
   delete dir=${tmp.dir} /
   delete file=../../../../../../CalcParserTokenTypes.txt/
  
  
  
  1.22  +7 -2  
ant/src/main/org/apache/tools/ant/taskdefs/optional/ANTLR.java
  
  Index: ANTLR.java
  ===
  RCS file: 
/home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/ANTLR.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- ANTLR.java1 Apr 2003 13:47:06 -   1.21
  +++ ANTLR.java1 Apr 2003 14:33:28 -   1.22
  @@ -275,7 +275,11 @@
   public void execute() throws BuildException {
   validateAttributes();
   //TODO: use ANTLR to parse the grammer file to do this.
  -if (target.lastModified()  getGeneratedFile().lastModified()) {
  +File generatedFile = getGeneratedFile();
  +if (target.lastModified()  generatedFile.lastModified()) {
  +log(Compiling  + target +  as it is newer than  
  ++ generatedFile, Project.MSG_VERBOSE);
  +
   populateAttributes();
   commandline.createArgument().setValue(target.toString());
   
  @@ -291,7 +295,8 @@
   }
   }
   } else {
  -log(Skipped grammar file. Generated file is newer., 
Project.MSG_VERBOSE);
  +log(Skipped grammar file. Generated file  + generatedFile 
  ++ is newer., Project.MSG_VERBOSE);
   }
   }
   
  
  
  
  1.13  +22 -0 
ant/src/testcases/org/apache/tools/ant/taskdefs/optional/ANTLRTest.java
  
  Index: ANTLRTest.java
  ===
  RCS file: 
/home/cvs/ant/src/testcases/org/apache/tools/ant/taskdefs/optional/ANTLRTest.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- ANTLRTest.java1 Apr 2003 10:54:36 -   1.12
  +++ ANTLRTest.java1 Apr 2003 14:33:28 -   1.13
  @@ -169,6 +169,28 @@
   public void test13() {
   executeTarget(test13);
   }
  +
  +public void testNoRecompile() {
  +executeTarget(test9);
  +assertEquals(-1, getFullLog().indexOf(Skipped grammar file.));
  +executeTarget(noRecompile);
  +assertTrue(-1 != getFullLog().indexOf(Skipped grammar file.));
  +}
  +
  +public void testNormalRecompile() {
  +executeTarget(test9);
  +assertEquals(-1, getFullLog().indexOf(Skipped grammar file.));
  +executeTarget(normalRecompile);
  +assertEquals(-1, getFullLog().indexOf(Skipped grammar file.));
  +}
  +
  +// Bugzilla Report 12961
  +public void testSupergrammarChangeRecompile() {
  +executeTarget(test9);
  +assertEquals(-1, getFullLog().indexOf(Skipped grammar file.));
  +executeTarget(supergrammarChangeRecompile);
  +assertEquals(-1, getFullLog().indexOf(Skipped grammar file.));
  +}
   }
   
   class CalcFileFilter implements FilenameFilter {