Permalink
Browse files

Issue #85: Add test for relative symlink preservation patch.

This test adds a fixture RelativeSymlinks.zip with the following
structure:

    RelativeSymbolicLink
    ├── symlinkedFile
    ├── symlinkedFolder
    └── symlinks
       ├── fileSymlink -> ../symlinkedFile
       └── folderSymlink -> ../symlinkedFolder

The test checks if both `fileSymlink` and `folderSymlink` still point to
the respective files in the parent directory after the fixture has been
unzipped.
  • Loading branch information...
dennda committed Nov 8, 2013
1 parent a5de5b6 commit f89c159b2ab14b5caa5f1d1e965f0900676b037e
@@ -7,6 +7,8 @@
objects = {
/* Begin PBXBuildFile section */
+ 011F4B96182D71B700DE704F /* RelativeSymbolicLink.zip in Resources */ = {isa = PBXBuildFile; fileRef = 011F4B95182D71B700DE704F /* RelativeSymbolicLink.zip */; };
+ 011F4B97182D72B400DE704F /* RelativeSymbolicLink.zip in Resources */ = {isa = PBXBuildFile; fileRef = 011F4B95182D71B700DE704F /* RelativeSymbolicLink.zip */; };
210D525417DEFB880060D41A /* ioapi.c in Sources */ = {isa = PBXBuildFile; fileRef = 210D524C17DEFB880060D41A /* ioapi.c */; };
210D525517DEFB880060D41A /* ioapi.c in Sources */ = {isa = PBXBuildFile; fileRef = 210D524C17DEFB880060D41A /* ioapi.c */; };
210D525617DEFB880060D41A /* mztools.c in Sources */ = {isa = PBXBuildFile; fileRef = 210D524E17DEFB880060D41A /* mztools.c */; };
@@ -48,6 +50,7 @@
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
+ 011F4B95182D71B700DE704F /* RelativeSymbolicLink.zip */ = {isa = PBXFileReference; lastKnownFileType = archive.zip; path = RelativeSymbolicLink.zip; sourceTree = "<group>"; };
210D524B17DEFB880060D41A /* crypt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = crypt.h; sourceTree = "<group>"; };
210D524C17DEFB880060D41A /* ioapi.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ioapi.c; sourceTree = "<group>"; };
210D524D17DEFB880060D41A /* ioapi.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ioapi.h; sourceTree = "<group>"; };
@@ -179,6 +182,7 @@
21CC41EF17DB7D3500201DDC /* Fixtures */ = {
isa = PBXGroup;
children = (
+ 011F4B95182D71B700DE704F /* RelativeSymbolicLink.zip */,
21CC41F017DB7D3500201DDC /* IncorrectHeaders.zip */,
21CC41F117DB7D3500201DDC /* PermissionsTestApp.app */,
21CC41F217DB7D3500201DDC /* SymbolicLink.zip */,
@@ -303,13 +307,15 @@
buildActionMask = 2147483647;
files = (
21CC420F17DB7D6F00201DDC /* Images.xcassets in Resources */,
+ 011F4B96182D71B700DE704F /* RelativeSymbolicLink.zip in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
21CC41BE17DB7D1300201DDC /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
+ 011F4B97182D72B400DE704F /* RelativeSymbolicLink.zip in Resources */,
21CC41F817DB7D3500201DDC /* IncorrectHeaders.zip in Resources */,
21CC41FD17DB7D3500201DDC /* Unicode.zip in Resources */,
21CC41FA17DB7D3500201DDC /* SymbolicLink.zip in Resources */,
Binary file not shown.
View
@@ -120,6 +120,36 @@ - (void)testUnzippingWithSymlinkedFileInside {
XCTAssertTrue(symbolicLinkToFilePersists && symbolicLinkToFolderPersists, @"Symbolic links should persist from the original archive to the outputted files.");
}
+- (void)testUnzippingWithRelativeSymlink {
+
+ NSString *resourceName = @"RelativeSymbolicLink";
+ NSString* zipPath = [[NSBundle bundleForClass:[self class]] pathForResource:resourceName ofType:@"zip"];
+ NSString* outputPath = [self _cachesPath:resourceName];
+
+ [SSZipArchive unzipFileAtPath:zipPath toDestination:outputPath delegate:self];
+
+ // Determine where the symlinks are
+ NSString *subfolderName = @"symlinks";
+ NSString *testBasePath = [NSString pathWithComponents:@[outputPath, resourceName]];
+ NSString *testSymlinkFolder = [NSString pathWithComponents:@[testBasePath, subfolderName, @"folderSymlink"]];
+ NSString *testSymlinkFile = [NSString pathWithComponents:@[testBasePath, subfolderName, @"fileSymlink"]];
+
+ // Determine where the files they link to are
+ NSString *parentDir = @"../";
+ NSString *testSymlinkFolderTarget = [NSString pathWithComponents:@[parentDir, @"symlinkedFolder"]];
+ NSString *testSymlinkFileTarget = [NSString pathWithComponents:@[parentDir, @"symlinkedFile"]];
+
+ NSError *error = nil;
+ NSString *symlinkFolderPath = [[NSFileManager defaultManager] destinationOfSymbolicLinkAtPath:testSymlinkFolder error:&error];
+ bool symbolicLinkToFolderPersists = ((symlinkFolderPath != nil) && [symlinkFolderPath isEqualToString:testSymlinkFolderTarget]) && (error == nil);
+
+ error = nil;
+
+ NSString *symlinkFilePath = [[NSFileManager defaultManager] destinationOfSymbolicLinkAtPath:testSymlinkFile error:&error];
+ bool symbolicLinkToFilePersists = ((symlinkFilePath != nil) && [symlinkFilePath isEqualToString:testSymlinkFileTarget]) && (error == nil);
+
+ XCTAssertTrue(symbolicLinkToFilePersists && symbolicLinkToFolderPersists, @"Relative symbolic links should persist from the original archive to the outputted files (and also remain relative).");
+}
- (void)testUnzippingWithUnicodeFilenameInside {

0 comments on commit f89c159

Please sign in to comment.