Use ZipArchive to extract fixtures for tests

The current method used by this library uses NSTask to spin up an
externally running task to unzip the fixtures, this will not work on iOS
as this functionality is not allowed. Switching to use ZipArchive, as
noted by @modocache, provides a portable way of extracting fixtures.
This commit is contained in:
Tom Booth 2016-02-15 21:55:02 +00:00
parent a6cde2b1d1
commit aec66f930c
7 changed files with 17 additions and 10 deletions

3
.gitmodules vendored
View File

@ -16,3 +16,6 @@
[submodule "Carthage/Checkouts/Result"]
path = Carthage/Checkouts/Result
url = https://github.com/antitypical/Result.git
[submodule "Carthage/Checkouts/ZipArchive"]
path = Carthage/Checkouts/ZipArchive
url = https://github.com/ZipArchive/ZipArchive.git

View File

@ -2,3 +2,4 @@ github "jspahrsummers/xcconfigs" >= 0.7.2
github "Quick/Quick" "v0.8.0"
github "Quick/Nimble" ~> 3.0.0
github "modocache/Guanaco" "5031bf67297afbe61ac0f2fbf3e3e8400b3f8888"
github "ZipArchive/ZipArchive" ~> 1.1

View File

@ -2,4 +2,5 @@ github "modocache/Guanaco" "5031bf67297afbe61ac0f2fbf3e3e8400b3f8888"
github "Quick/Nimble" "v3.0.0"
github "Quick/Quick" "v0.8.0"
github "antitypical/Result" "1.0.1"
github "ZipArchive/ZipArchive" "v1.1"
github "jspahrsummers/xcconfigs" "0.8.1"

1
Carthage/Checkouts/ZipArchive vendored Submodule

@ -0,0 +1 @@
Subproject commit 057c4937552f421d782e6d07ae09191b191bcc23

View File

@ -7,6 +7,7 @@
objects = {
/* Begin PBXBuildFile section */
62E6FD8F1C727E9C00A312B0 /* ZipArchive.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 62E6FD8E1C727E9C00A312B0 /* ZipArchive.framework */; };
BE0991F71A578FB1007D4E6A /* Mantle.zip in Resources */ = {isa = PBXBuildFile; fileRef = BE0991F61A578FB1007D4E6A /* Mantle.zip */; };
BE0B1C5D1A9978890004726D /* detached-head.zip in Resources */ = {isa = PBXBuildFile; fileRef = BE0B1C5C1A9978890004726D /* detached-head.zip */; };
BE14AA501A1974010015B439 /* SwiftGit2.m in Sources */ = {isa = PBXBuildFile; fileRef = BE14AA4F1A1974010015B439 /* SwiftGit2.m */; };
@ -185,6 +186,7 @@
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
62E6FD8E1C727E9C00A312B0 /* ZipArchive.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ZipArchive.framework; path = ../Carthage/Checkouts/ZipArchive/build/Debug/ZipArchive.framework; sourceTree = "<group>"; };
BE0991F61A578FB1007D4E6A /* Mantle.zip */ = {isa = PBXFileReference; lastKnownFileType = archive.zip; path = Mantle.zip; sourceTree = "<group>"; };
BE0B1C5C1A9978890004726D /* detached-head.zip */ = {isa = PBXFileReference; lastKnownFileType = archive.zip; path = "detached-head.zip"; sourceTree = "<group>"; };
BE14AA4F1A1974010015B439 /* SwiftGit2.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SwiftGit2.m; sourceTree = "<group>"; };
@ -312,6 +314,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
62E6FD8F1C727E9C00A312B0 /* ZipArchive.framework in Frameworks */,
DA59146D1A94549A00AED74C /* Guanaco.framework in Frameworks */,
DA5023A01A969F1A004175D7 /* Nimble.framework in Frameworks */,
DAC8143D1A99749D0063D88C /* Quick.framework in Frameworks */,
@ -467,6 +470,7 @@
BEB31F331A0D6F7A00F525B9 /* Supporting Files */ = {
isa = PBXGroup;
children = (
62E6FD8E1C727E9C00A312B0 /* ZipArchive.framework */,
DA50239F1A969F1A004175D7 /* Nimble.framework */,
DAC8143C1A99749D0063D88C /* Quick.framework */,
DA59146C1A94549A00AED74C /* Guanaco.framework */,
@ -914,6 +918,7 @@
FRAMEWORK_SEARCH_PATHS = (
"$(DEVELOPER_FRAMEWORKS_DIR)",
"$(inherited)",
"$(PROJECT_DIR)/Carthage/Checkouts/ZipArchive/build/Debug",
);
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
@ -935,6 +940,7 @@
FRAMEWORK_SEARCH_PATHS = (
"$(DEVELOPER_FRAMEWORKS_DIR)",
"$(inherited)",
"$(PROJECT_DIR)/Carthage/Checkouts/ZipArchive/build/Debug",
);
INFOPLIST_FILE = SwiftGit2Tests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";

View File

@ -16,4 +16,7 @@
<FileRef
location = "group:Carthage/Checkouts/Guanaco/Guanaco.xcodeproj">
</FileRef>
<FileRef
location = "group:Carthage/Checkouts/ZipArchive/ZipArchive.xcodeproj">
</FileRef>
</Workspace>

View File

@ -8,6 +8,7 @@
import Foundation
import SwiftGit2
import ZipArchive
final class Fixtures {
@ -37,7 +38,7 @@ final class Fixtures {
let zipURLs = bundle.URLsForResourcesWithExtension("zip", subdirectory: nil)! as [NSURL]
for URL in zipURLs {
unzipFileAtURL(URL, intoDirectoryAtURL: directoryURL)
SSZipArchive.unzipFileAtPath(URL.path!, toDestination: directoryURL.path!)
}
}
@ -45,15 +46,6 @@ final class Fixtures {
try! NSFileManager.defaultManager().removeItemAtURL(directoryURL)
}
func unzipFileAtURL(fileURL: NSURL, intoDirectoryAtURL directoryURL: NSURL) {
let task = NSTask()
task.launchPath = "/usr/bin/unzip"
task.arguments = [ "-qq", "-d", directoryURL.path!, fileURL.path! ]
task.launch()
task.waitUntilExit()
}
// MARK: - Helpers
func repositoryWithName(name: String) -> Repository {