ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject cvs commit: ant/src/testcases/org/apache/tools/ant/taskdefs/optional ANTLRTest.java
Date Tue, 01 Apr 2003 14:33:29 GMT
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  Changes    Path
  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 -0000	1.8
  +++ antlr.xml	1 Apr 2003 14:33:28 -0000	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.java	1 Apr 2003 13:47:06 -0000	1.21
  +++ ANTLR.java	1 Apr 2003 14:33:28 -0000	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.java	1 Apr 2003 10:54:36 -0000	1.12
  +++ ANTLRTest.java	1 Apr 2003 14:33:28 -0000	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 {
  
  
  

Mime
View raw message