You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by bo...@apache.org on 2003/02/07 15:59:06 UTC

cvs commit: jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs UnzipTest.java

bodewig     2003/02/07 06:59:06

  Modified:    src/etc/testcases/taskdefs unzip.xml
               src/main/org/apache/tools/ant/taskdefs Expand.java
               src/testcases/org/apache/tools/ant/taskdefs UnzipTest.java
  Log:
  PR: 11100
  
  revisited.  The original patch wouldn't pass Unzip's new
  testPatternSetIncludeAndExclude test.
  
  Revision  Changes    Path
  1.4       +35 -0     jakarta-ant/src/etc/testcases/taskdefs/unzip.xml
  
  Index: unzip.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/etc/testcases/taskdefs/unzip.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- unzip.xml	21 Nov 2001 15:45:26 -0000	1.3
  +++ unzip.xml	7 Feb 2003 14:59:06 -0000	1.4
  @@ -4,6 +4,9 @@
   
     <target name="cleanup">
       <delete file="asf-logo.gif" />
  +    <delete file="unziptest.zip"/>
  +    <delete dir="unziptestin"/>
  +    <delete dir="unziptestout"/>
     </target>
   
     <target name="test1">
  @@ -28,4 +31,36 @@
       <unzip src="expected/asf-logo.gif.zip" dest="." />
     </target>
   
  +  <target name="prepareTestZip">
  +    <mkdir dir="unziptestin/1"/>
  +    <mkdir dir="unziptestin/2"/>
  +    <touch file="unziptestin/1/foo"/>
  +    <touch file="unziptestin/2/bar"/>
  +    <zip destfile="unziptest.zip" basedir="unziptestin"/>
  +  </target>
  +
  +  <target name="testPatternSetExcludeOnly" depends="prepareTestZip">
  +    <unzip dest="unziptestout" src="unziptest.zip">
  +      <patternset>
  +        <exclude name="1/**"/>
  +      </patternset>
  +    </unzip>
  +  </target>
  +
  +  <target name="testPatternSetIncludeOnly" depends="prepareTestZip">
  +    <unzip dest="unziptestout" src="unziptest.zip">
  +      <patternset>
  +        <include name="2/**"/>
  +      </patternset>
  +    </unzip>
  +  </target>
  +
  +  <target name="testPatternSetIncludeAndExclude" depends="prepareTestZip">
  +    <unzip dest="unziptestout" src="unziptest.zip">
  +      <patternset>
  +        <include name="2/**"/>
  +        <exclude name="2/**"/>
  +      </patternset>
  +    </unzip>
  +  </target>
   </project>
  
  
  
  1.39      +15 -7     jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Expand.java
  
  Index: Expand.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Expand.java,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- Expand.java	7 Feb 2003 09:50:49 -0000	1.38
  +++ Expand.java	7 Feb 2003 14:59:06 -0000	1.39
  @@ -182,17 +182,25 @@
               String name = entryName;
               boolean included = false;
               for (int v = 0; v < patternsets.size(); v++) {
  -                included = true;
                   PatternSet p = (PatternSet) patternsets.elementAt(v);
                   String[] incls = p.getIncludePatterns(getProject());
  -                if (incls != null) {
  -                    for (int w = 0; w < incls.length; w++) {
  -                        included = DirectoryScanner.match(incls[w], name);
  -                        if (included) {
  -                            break;
  -                        }
  +                if (incls == null || incls.length == 0) {
  +                    // no include pattern implicitly means includes="**"
  +                    incls = new String[] {"**"};
  +                }
  +                    
  +                for (int w = 0; w < incls.length; w++) {
  +                    included = DirectoryScanner.match(incls[w], name);
  +                    if (included) {
  +                        break;
                       }
                   }
  +                
  +                if (!included) {
  +                    break;
  +                }
  +                
  +
                   String[] excls = p.getExcludePatterns(getProject());
                   if (excls != null) {
                       for (int w = 0; w < excls.length; w++) {
  
  
  
  1.6       +34 -1     jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/UnzipTest.java
  
  Index: UnzipTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/UnzipTest.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- UnzipTest.java	10 Jan 2002 10:13:12 -0000	1.5
  +++ UnzipTest.java	7 Feb 2003 14:59:06 -0000	1.6
  @@ -1,7 +1,7 @@
   /*
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 2000-2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 2000-2001,2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -101,4 +101,37 @@
                                              project.resolveFile("asf-logo.gif")));
       }
       
  +    /*
  +     * PR 11100
  +     */
  +    public void testPatternSetExcludeOnly() {
  +        executeTarget("testPatternSetExcludeOnly");
  +        assertTrue("1/foo is excluded",
  +                   !getProject().resolveFile("unziptestout/1/foo").exists());
  +        assertTrue("2/bar is not excluded",
  +                   getProject().resolveFile("unziptestout/2/bar").exists());
  +    }
  +
  +    /*
  +     * PR 11100
  +     */
  +    public void testPatternSetIncludeOnly() {
  +        executeTarget("testPatternSetIncludeOnly");
  +        assertTrue("1/foo is not included",
  +                   !getProject().resolveFile("unziptestout/1/foo").exists());
  +        assertTrue("2/bar is included",
  +                   getProject().resolveFile("unziptestout/2/bar").exists());
  +    }
  +
  +    /*
  +     * PR 11100
  +     */
  +    public void testPatternSetIncludeAndExclude() {
  +        executeTarget("testPatternSetIncludeAndExclude");
  +        assertTrue("1/foo is not included",
  +                   !getProject().resolveFile("unziptestout/1/foo").exists());
  +        assertTrue("2/bar is excluded",
  +                   !getProject().resolveFile("unziptestout/2/bar").exists());
  +    }
  +
   }