disable a few tests on Windows
authorStefan Bodewig <bodewig@apache.org>
Mon, 16 May 2016 12:31:30 +0000 (14:31 +0200)
committerStefan Bodewig <bodewig@apache.org>
Mon, 16 May 2016 12:31:30 +0000 (14:31 +0200)
src/tests/antunit/types/selectors/ownedby-test.xml
src/tests/junit/org/apache/tools/ant/types/selectors/OwnedBySelectorTest.java
src/tests/junit/org/apache/tools/ant/util/PermissionUtilsTest.java

index 7949c41..5ec4381 100644 (file)
 
   <property name="file" value="testfile"/>
 
+  <condition property="unix">
+    <os family="unix"/>
+  </condition>
+
   <target name="createTestdir">
     <mkdir dir="${output}"/>
     <touch file="${output}/${file}"/>
@@ -36,8 +40,8 @@
     </au:expectfailure>
   </target>
 
-  <!-- not sure whether this works on Windows, Jenkins will tell us -->
-  <target name="testOwnedBy" depends="createTestdir">
+  <!-- at least on Jenkins the file is owned by BUILTIN\Administrators -->
+  <target name="testOwnedBy" depends="createTestdir" if="unix">
     <au:assertTrue>
       <resourcecount when="equal" count="1">
         <fileset dir="${output}">
@@ -54,7 +58,7 @@
     </au:assertTrue>
   </target>
 
-  <target name="testAsTrueConditions" depends="createTestdir">
+  <target name="testAsTrueConditions" depends="createTestdir" if="unix">
     <au:assertTrue>
       <isfileselected file="${output}/${file}">
         <ownedBy owner="${user.name}"/>
index a6dddcf..389923f 100644 (file)
@@ -25,6 +25,8 @@ import java.io.File;
 import java.nio.file.Files;
 import java.nio.file.attribute.UserPrincipal;
 
+import org.apache.tools.ant.taskdefs.condition.Os;
+import org.junit.Assume;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
@@ -36,6 +38,8 @@ public class OwnedBySelectorTest {
 
     @Test
     public void ownedByIsTrueForSelf() throws Exception {
+        // at least on Jenkins the file is owned by "BUILTIN\Administrators"
+        Assume.assumeFalse(Os.isFamily("windows"));
         String self = System.getProperty("user.name");
         File file = folder.newFile("f.txt");
         UserPrincipal user = Files.getOwner(file.toPath());
index 6ec486a..c4dd8fc 100644 (file)
@@ -23,6 +23,8 @@ import static org.junit.Assert.assertEquals;
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.attribute.PosixFileAttributeView;
 import java.nio.file.attribute.PosixFilePermission;
 import java.util.EnumSet;
 import java.util.Set;
@@ -34,6 +36,7 @@ import org.apache.tools.tar.TarEntry;
 import org.apache.tools.tar.TarOutputStream;
 import org.apache.tools.zip.ZipEntry;
 import org.apache.tools.zip.ZipOutputStream;
+import org.junit.Assume;
 import org.junit.Test;
 
 public class PermissionUtilsTest {
@@ -100,6 +103,8 @@ public class PermissionUtilsTest {
     public void getSetPermissionsWorksForFiles() throws IOException {
         File f = File.createTempFile("ant", ".tst");
         f.deleteOnExit();
+        Assume.assumeNotNull(Files.getFileAttributeView(f.toPath(),
+                                                        PosixFileAttributeView.class));
         Set<PosixFilePermission> s =
             EnumSet.of(PosixFilePermission.OWNER_READ,
                        PosixFilePermission.OWNER_WRITE,