if (Functions.isWindows()) return; // can't test on Windows
File tar = File.createTempFile("test","tar");
File zip = File.createTempFile("test","zip");
FilePath dir = new FilePath(File.createTempFile("test","dir"));
try {
dir.delete();
dir.child("subdir").mkdirs();
FilePath f = dir.child("a.txt");
f.touch(0);
f.chmod(0755);
f = dir.child("subdir/b.txt");
f.touch(0);
f.chmod(0644);
int dirMode = dir.child("subdir").mode();
dir.tar(new FileOutputStream(tar),"**/*");
dir.zip(new FileOutputStream(zip));
FilePath e = dir.child("extract");
e.mkdirs();
// extract via the tar command
assertEquals(0, new LocalLauncher(new StreamTaskListener(System.out)).launch().cmds("tar", "xvf", tar.getAbsolutePath()).pwd(e).join());
assertEquals(0100755,e.child("a.txt").mode());
assertEquals(dirMode,e.child("subdir").mode());
assertEquals(0100644,e.child("subdir/b.txt").mode());
// extract via the zip command
e.deleteContents();
assertEquals(0, new LocalLauncher(new StreamTaskListener(System.out)).launch().cmds("unzip", zip.getAbsolutePath()).pwd(e).join());
e = e.listDirectories().get(0);
assertEquals(0100755, e.child("a.txt").mode());
assertEquals(dirMode,e.child("subdir").mode());
assertEquals(0100644,e.child("subdir/b.txt").mode());
} finally {
tar.delete();
zip.delete();
dir.deleteRecursive();
}