diff --git a/.travis.yml b/.travis.yml index 084559ab..20dc67d5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,5 @@ language: objective-c +osx_image: xcode7 before_install: - brew update - brew install macmade/tap/xcode-coveralls diff --git a/Configurations/ConfigCommonDebug.xcconfig b/Configurations/ConfigCommonDebug.xcconfig index 824b79b3..2ac1b545 100644 --- a/Configurations/ConfigCommonDebug.xcconfig +++ b/Configurations/ConfigCommonDebug.xcconfig @@ -3,6 +3,7 @@ // Debug only GCC_OPTIMIZATION_LEVEL = 0 +SWIFT_OPTIMIZATION_LEVEL = -Onone DEBUG_INFORMATION_FORMAT = dwarf ENABLE_TESTABILITY = YES GCC_GENERATE_DEBUGGING_SYMBOLS = YES diff --git a/Configurations/ConfigCommonRelease.xcconfig b/Configurations/ConfigCommonRelease.xcconfig index 0888aaff..32eae505 100644 --- a/Configurations/ConfigCommonRelease.xcconfig +++ b/Configurations/ConfigCommonRelease.xcconfig @@ -3,6 +3,7 @@ // Release only GCC_OPTIMIZATION_LEVEL = s +SWIFT_OPTIMIZATION_LEVEL = -Ofast DEBUG_INFORMATION_FORMAT = dwarf-with-dsym GCC_GENERATE_DEBUGGING_SYMBOLS = YES GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS_COMMON) diff --git a/Configurations/ConfigUnitTest.xcconfig b/Configurations/ConfigUnitTest.xcconfig index b21896e4..36dc8857 100644 --- a/Configurations/ConfigUnitTest.xcconfig +++ b/Configurations/ConfigUnitTest.xcconfig @@ -7,3 +7,6 @@ GCC_SYMBOLS_PRIVATE_EXTERN = NO WARNING_CFLAGS = $(inherited) -Wno-variadic-macros -Wno-gnu-zero-variadic-macro-arguments FRAMEWORK_SEARCH_PATHS = $(inherited) $(DEVELOPER_FRAMEWORKS_DIR) LD_RUNPATH_SEARCH_PATHS = @loader_path/../Frameworks +MACOSX_DEPLOYMENT_TARGET = 10.9 +CLANG_ENABLE_MODULES = YES +SWIFT_OBJC_BRIDGING_HEADER = Tests/Sparkle Unit Tests-Bridging-Header.h diff --git a/Configurations/ConfigUnitTestCoverage.xcconfig b/Configurations/ConfigUnitTestCoverage.xcconfig index 67f13139..f3d5d3db 100644 --- a/Configurations/ConfigUnitTestCoverage.xcconfig +++ b/Configurations/ConfigUnitTestCoverage.xcconfig @@ -1,2 +1,4 @@ +#include "ConfigUnitTest.xcconfig" + GCC_GENERATE_TEST_COVERAGE_FILES = NO GCC_INSTRUMENT_PROGRAM_FLOW_ARCS = NO diff --git a/Sparkle.xcodeproj/project.pbxproj b/Sparkle.xcodeproj/project.pbxproj index bb597d60..b1f6dddb 100644 --- a/Sparkle.xcodeproj/project.pbxproj +++ b/Sparkle.xcodeproj/project.pbxproj @@ -72,8 +72,6 @@ 55C14F9A136F045400649790 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 61B5F8F609C4CEB300B25A18 /* Security.framework */; }; 55C14FC7136F05E100649790 /* Sparkle.strings in Resources */ = {isa = PBXBuildFile; fileRef = 61AAE8220A321A7F00D8810D /* Sparkle.strings */; }; 55E6F33319EC9F6C00005E76 /* SUErrors.h in Headers */ = {isa = PBXBuildFile; fileRef = 55E6F33219EC9F6C00005E76 /* SUErrors.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 5AF6C1E51AE86A410014A3AB /* SUPipedUnarchiverTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 5AF6C1EA1AE870A90014A3AB /* SUPipedUnarchiverTest.m */; }; - 5AF6C1E91AE86E270014A3AB /* test archive.zip in Resources */ = {isa = PBXBuildFile; fileRef = 5AF6C1E81AE86E270014A3AB /* test archive.zip */; }; 5AF6C74F1AEA46D10014A3AB /* test.sparkle_guided.pkg in Resources */ = {isa = PBXBuildFile; fileRef = 5AF6C74E1AEA46D10014A3AB /* test.sparkle_guided.pkg */; }; 5AF6C7541AEA49840014A3AB /* SUInstallerTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 5AF6C74C1AEA40760014A3AB /* SUInstallerTest.m */; }; 5AF9DC3C1981DBEE001EA135 /* SUDSAVerifierTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 5AF9DC3B1981DBEE001EA135 /* SUDSAVerifierTest.m */; }; @@ -164,6 +162,7 @@ 61F83F720DBFE140006FDD30 /* SUBasicUpdateDriver.m in Sources */ = {isa = PBXBuildFile; fileRef = 61F83F700DBFE137006FDD30 /* SUBasicUpdateDriver.m */; }; 61F83F740DBFE141006FDD30 /* SUBasicUpdateDriver.h in Headers */ = {isa = PBXBuildFile; fileRef = 61F83F6F0DBFE137006FDD30 /* SUBasicUpdateDriver.h */; settings = {ATTRIBUTES = (); }; }; 61FA52880E2D9EA400EF58AD /* Sparkle.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8DC2EF5B0486A6940098B216 /* Sparkle.framework */; settings = {ATTRIBUTES = (Required, ); }; }; + 7210C7681B9A9A1500EB90AC /* SUUnarchiverTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7210C7671B9A9A1500EB90AC /* SUUnarchiverTest.swift */; settings = {ASSET_TAGS = (); }; }; 721CF1A71AD7643600D9AC09 /* bsdiff.c in Sources */ = {isa = PBXBuildFile; fileRef = 5D06E8DB0FD68CB9005AE3F6 /* bsdiff.c */; settings = {COMPILER_FLAGS = "-w"; }; }; 721CF1A81AD7644100D9AC09 /* bspatch.c in Sources */ = {isa = PBXBuildFile; fileRef = 5D06E8DC0FD68CB9005AE3F6 /* bspatch.c */; settings = {COMPILER_FLAGS = "-w"; }; }; 721CF1A91AD7644C00D9AC09 /* sais.c in Sources */ = {isa = PBXBuildFile; fileRef = 7223E7611AD1AEFF008E3161 /* sais.c */; settings = {COMPILER_FLAGS = "-w"; }; }; @@ -174,6 +173,11 @@ 7275F9C11B5F1F2900B1D19E /* SUFileManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 7275F9BF1B5F1F2900B1D19E /* SUFileManager.h */; }; 7275F9C21B5F1F2900B1D19E /* SUFileManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 7275F9C01B5F1F2900B1D19E /* SUFileManager.m */; }; 7275F9C31B5F1F2900B1D19E /* SUFileManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 7275F9C01B5F1F2900B1D19E /* SUFileManager.m */; }; + 72AC6B261B9AAC8800F62325 /* SparkleTestCodeSignApp.tar.gz in Resources */ = {isa = PBXBuildFile; fileRef = 72AC6B251B9AAC8800F62325 /* SparkleTestCodeSignApp.tar.gz */; settings = {ASSET_TAGS = (); }; }; + 72AC6B281B9AAD6700F62325 /* SparkleTestCodeSignApp.tar in Resources */ = {isa = PBXBuildFile; fileRef = 72AC6B271B9AAD6700F62325 /* SparkleTestCodeSignApp.tar */; settings = {ASSET_TAGS = (); }; }; + 72AC6B2A1B9AAF3A00F62325 /* SparkleTestCodeSignApp.tar.bz2 in Resources */ = {isa = PBXBuildFile; fileRef = 72AC6B291B9AAF3A00F62325 /* SparkleTestCodeSignApp.tar.bz2 */; settings = {ASSET_TAGS = (); }; }; + 72AC6B2C1B9AB0EE00F62325 /* SparkleTestCodeSignApp.tar.xz in Resources */ = {isa = PBXBuildFile; fileRef = 72AC6B2B1B9AB0EE00F62325 /* SparkleTestCodeSignApp.tar.xz */; settings = {ASSET_TAGS = (); }; }; + 72AC6B2E1B9B218C00F62325 /* SparkleTestCodeSignApp.dmg in Resources */ = {isa = PBXBuildFile; fileRef = 72AC6B2D1B9B218C00F62325 /* SparkleTestCodeSignApp.dmg */; settings = {ASSET_TAGS = (); }; }; 72D4DAA11AD7632900B211E2 /* SUBinaryDeltaCreate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7268AC621AD634C200C3E0C1 /* SUBinaryDeltaCreate.m */; }; 72E45CF31B640CDD005C701A /* SUTestApplicationDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 72E45CF21B640CDD005C701A /* SUTestApplicationDelegate.m */; }; 72E45CF71B640DAE005C701A /* SUUpdateSettingsWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 72E45CF51B640DAE005C701A /* SUUpdateSettingsWindowController.m */; }; @@ -428,8 +432,6 @@ 55C14F31136EFC2400649790 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; }; 55E6F33219EC9F6C00005E76 /* SUErrors.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUErrors.h; sourceTree = ""; }; 5AEF45D9189D1CC90030D7DC /* tr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = tr; path = tr.lproj/Sparkle.strings; sourceTree = ""; }; - 5AF6C1E81AE86E270014A3AB /* test archive.zip */ = {isa = PBXFileReference; lastKnownFileType = archive.zip; path = "test archive.zip"; sourceTree = ""; }; - 5AF6C1EA1AE870A90014A3AB /* SUPipedUnarchiverTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUPipedUnarchiverTest.m; sourceTree = ""; }; 5AF6C74C1AEA40760014A3AB /* SUInstallerTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUInstallerTest.m; sourceTree = ""; }; 5AF6C74E1AEA46D10014A3AB /* test.sparkle_guided.pkg */ = {isa = PBXFileReference; lastKnownFileType = file; path = test.sparkle_guided.pkg; sourceTree = ""; }; 5AF9DC3B1981DBEE001EA135 /* SUDSAVerifierTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUDSAVerifierTest.m; sourceTree = ""; }; @@ -560,12 +562,19 @@ 61F614540E24A12D009F47E7 /* it */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = it; path = it.lproj/Sparkle.strings; sourceTree = ""; }; 61F83F6F0DBFE137006FDD30 /* SUBasicUpdateDriver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUBasicUpdateDriver.h; sourceTree = ""; }; 61F83F700DBFE137006FDD30 /* SUBasicUpdateDriver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUBasicUpdateDriver.m; sourceTree = ""; }; + 7210C7671B9A9A1500EB90AC /* SUUnarchiverTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SUUnarchiverTest.swift; sourceTree = ""; }; 7223E7611AD1AEFF008E3161 /* sais.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = sais.c; sourceTree = ""; }; 7223E7621AD1AEFF008E3161 /* sais.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sais.h; sourceTree = ""; }; 7268AC621AD634C200C3E0C1 /* SUBinaryDeltaCreate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUBinaryDeltaCreate.m; sourceTree = ""; }; 7268AC641AD634E400C3E0C1 /* SUBinaryDeltaCreate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUBinaryDeltaCreate.h; sourceTree = ""; }; 7275F9BF1B5F1F2900B1D19E /* SUFileManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUFileManager.h; sourceTree = ""; }; 7275F9C01B5F1F2900B1D19E /* SUFileManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUFileManager.m; sourceTree = ""; }; + 72AC6B251B9AAC8800F62325 /* SparkleTestCodeSignApp.tar.gz */ = {isa = PBXFileReference; lastKnownFileType = archive.gzip; path = SparkleTestCodeSignApp.tar.gz; sourceTree = ""; }; + 72AC6B271B9AAD6700F62325 /* SparkleTestCodeSignApp.tar */ = {isa = PBXFileReference; lastKnownFileType = archive.tar; path = SparkleTestCodeSignApp.tar; sourceTree = ""; }; + 72AC6B291B9AAF3A00F62325 /* SparkleTestCodeSignApp.tar.bz2 */ = {isa = PBXFileReference; lastKnownFileType = file; path = SparkleTestCodeSignApp.tar.bz2; sourceTree = ""; }; + 72AC6B2B1B9AB0EE00F62325 /* SparkleTestCodeSignApp.tar.xz */ = {isa = PBXFileReference; lastKnownFileType = file; path = SparkleTestCodeSignApp.tar.xz; sourceTree = ""; }; + 72AC6B2D1B9B218C00F62325 /* SparkleTestCodeSignApp.dmg */ = {isa = PBXFileReference; lastKnownFileType = file; path = SparkleTestCodeSignApp.dmg; sourceTree = ""; }; + 72AFC6121B9A944200F6B565 /* Sparkle Unit Tests-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Sparkle Unit Tests-Bridging-Header.h"; sourceTree = ""; }; 72E45CF11B640CDD005C701A /* SUTestApplicationDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUTestApplicationDelegate.h; sourceTree = ""; }; 72E45CF21B640CDD005C701A /* SUTestApplicationDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUTestApplicationDelegate.m; sourceTree = ""; }; 72E45CF41B640DAE005C701A /* SUUpdateSettingsWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUUpdateSettingsWindowController.h; sourceTree = ""; }; @@ -811,7 +820,11 @@ children = ( 14958C6B19AEBC530061B14F /* signed-test-file.txt */, F8761EB21ADC50EB000C9034 /* SparkleTestCodeSignApp.zip */, - 5AF6C1E81AE86E270014A3AB /* test archive.zip */, + 72AC6B271B9AAD6700F62325 /* SparkleTestCodeSignApp.tar */, + 72AC6B251B9AAC8800F62325 /* SparkleTestCodeSignApp.tar.gz */, + 72AC6B291B9AAF3A00F62325 /* SparkleTestCodeSignApp.tar.bz2 */, + 72AC6B2B1B9AB0EE00F62325 /* SparkleTestCodeSignApp.tar.xz */, + 72AC6B2D1B9B218C00F62325 /* SparkleTestCodeSignApp.dmg */, 14958C6C19AEBC610061B14F /* test-pubkey.pem */, 5AF6C74E1AEA46D10014A3AB /* test.sparkle_guided.pkg */, ); @@ -867,9 +880,10 @@ F8761EB01ADC5068000C9034 /* SUCodeSigningVerifierTest.m */, 5AF9DC3B1981DBEE001EA135 /* SUDSAVerifierTest.m */, 5AF6C74C1AEA40760014A3AB /* SUInstallerTest.m */, - 5AF6C1EA1AE870A90014A3AB /* SUPipedUnarchiverTest.m */, 14950074195FDF5900BC5B5B /* SUUpdaterTest.m */, 61227A150DB548B800AB99EA /* SUVersionComparisonTest.m */, + 7210C7671B9A9A1500EB90AC /* SUUnarchiverTest.swift */, + 72AFC6121B9A944200F6B565 /* Sparkle Unit Tests-Bridging-Header.h */, ); path = Tests; sourceTree = ""; @@ -1232,6 +1246,7 @@ isa = PBXProject; attributes = { CLASSPREFIX = SU; + LastSwiftUpdateCheck = 0700; LastUpgradeCheck = 0700; ORGANIZATIONNAME = "Sparkle Project"; TargetAttributes = { @@ -1311,8 +1326,12 @@ files = ( 14958C6E19AEBC950061B14F /* signed-test-file.txt in Resources */, F8761EB31ADC50EB000C9034 /* SparkleTestCodeSignApp.zip in Resources */, - 5AF6C1E91AE86E270014A3AB /* test archive.zip in Resources */, + 72AC6B2C1B9AB0EE00F62325 /* SparkleTestCodeSignApp.tar.xz in Resources */, + 72AC6B261B9AAC8800F62325 /* SparkleTestCodeSignApp.tar.gz in Resources */, + 72AC6B2E1B9B218C00F62325 /* SparkleTestCodeSignApp.dmg in Resources */, 14958C6F19AEBC980061B14F /* test-pubkey.pem in Resources */, + 72AC6B281B9AAD6700F62325 /* SparkleTestCodeSignApp.tar in Resources */, + 72AC6B2A1B9AAF3A00F62325 /* SparkleTestCodeSignApp.tar.bz2 in Resources */, 5AF6C74F1AEA46D10014A3AB /* test.sparkle_guided.pkg in Resources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -1470,10 +1489,10 @@ 72D4DAA11AD7632900B211E2 /* SUBinaryDeltaCreate.m in Sources */, 142E0E0919A83AAC00E4312B /* SUBinaryDeltaTest.m in Sources */, F8761EB11ADC5068000C9034 /* SUCodeSigningVerifierTest.m in Sources */, + 7210C7681B9A9A1500EB90AC /* SUUnarchiverTest.swift in Sources */, 5AF9DC3C1981DBEE001EA135 /* SUDSAVerifierTest.m in Sources */, 5AF6C7541AEA49840014A3AB /* SUInstallerTest.m in Sources */, 14652F8219A9746000959E44 /* SULog.m in Sources */, - 5AF6C1E51AE86A410014A3AB /* SUPipedUnarchiverTest.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/TestApplication/SUTestApplicationDelegate.m b/TestApplication/SUTestApplicationDelegate.m index 8b0f1d55..09e98c71 100644 --- a/TestApplication/SUTestApplicationDelegate.m +++ b/TestApplication/SUTestApplicationDelegate.m @@ -28,7 +28,7 @@ static NSString * const UPDATED_VERSION = @"2.0"; NSBundle *mainBundle = [NSBundle mainBundle]; // Check if we are already up to date - if ([[mainBundle objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey] isEqualToString:UPDATED_VERSION]) { + if ([[mainBundle objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleVersionKey] isEqualToString:UPDATED_VERSION]) { NSAlert *alreadyUpdatedAlert = [[NSAlert alloc] init]; alreadyUpdatedAlert.messageText = @"Update succeeded!"; alreadyUpdatedAlert.informativeText = @"This is the updated version of Sparkle Test App.\n\nDelete and rebuild the app to test updates again."; @@ -85,7 +85,7 @@ static NSString * const UPDATED_VERSION = @"2.0"; assert(infoFileExists); NSMutableDictionary *infoDictionary = [[NSMutableDictionary alloc] initWithContentsOfURL:infoURL]; - infoDictionary[(NSString *)kCFBundleVersionKey] = UPDATED_VERSION; + infoDictionary[(__bridge NSString *)kCFBundleVersionKey] = UPDATED_VERSION; infoDictionary[@"CFBundleShortVersionString"] = UPDATED_VERSION; BOOL wroteInfoFile = [infoDictionary writeToURL:infoURL atomically:NO]; diff --git a/Tests/Resources/SparkleTestCodeSignApp.dmg b/Tests/Resources/SparkleTestCodeSignApp.dmg new file mode 100644 index 00000000..4b3b011e Binary files /dev/null and b/Tests/Resources/SparkleTestCodeSignApp.dmg differ diff --git a/Tests/Resources/SparkleTestCodeSignApp.tar b/Tests/Resources/SparkleTestCodeSignApp.tar new file mode 100644 index 00000000..5d8bd11d Binary files /dev/null and b/Tests/Resources/SparkleTestCodeSignApp.tar differ diff --git a/Tests/Resources/SparkleTestCodeSignApp.tar.bz2 b/Tests/Resources/SparkleTestCodeSignApp.tar.bz2 new file mode 100644 index 00000000..79ffd4e0 Binary files /dev/null and b/Tests/Resources/SparkleTestCodeSignApp.tar.bz2 differ diff --git a/Tests/Resources/SparkleTestCodeSignApp.tar.gz b/Tests/Resources/SparkleTestCodeSignApp.tar.gz new file mode 100644 index 00000000..87f12f48 Binary files /dev/null and b/Tests/Resources/SparkleTestCodeSignApp.tar.gz differ diff --git a/Tests/Resources/SparkleTestCodeSignApp.tar.xz b/Tests/Resources/SparkleTestCodeSignApp.tar.xz new file mode 100644 index 00000000..ee145d5a Binary files /dev/null and b/Tests/Resources/SparkleTestCodeSignApp.tar.xz differ diff --git a/Tests/Resources/test archive.zip b/Tests/Resources/test archive.zip deleted file mode 100644 index 51d7aa2b..00000000 Binary files a/Tests/Resources/test archive.zip and /dev/null differ diff --git a/Tests/SUPipedUnarchiverTest.m b/Tests/SUPipedUnarchiverTest.m deleted file mode 100644 index eb5c7c0b..00000000 --- a/Tests/SUPipedUnarchiverTest.m +++ /dev/null @@ -1,82 +0,0 @@ -// -// SUPipedUnarchiverTest.m -// Sparkle -// -// Created by Kornel on 23/04/2015. -// Copyright (c) 2015 Sparkle Project. All rights reserved. -// - -#import -#import -#import "SUUnarchiver.h" -#import "SUPipedUnarchiver.h" - -#if __clang_major__ >= 6 -@interface SUPipedUnarchiverTest : XCTestCase - -@property (nonatomic, strong) XCTestExpectation *unarchived; -@property (nonatomic, assign) BOOL result; - -@end - -@implementation SUPipedUnarchiverTest - -@synthesize unarchived; -@synthesize result; - -- (void)setUp -{ - [super setUp]; - self.unarchived = [self expectationWithDescription:@"unarchived"]; -} - -- (void)tearDown -{ - // Put teardown code here. This method is called after the invocation of each test method in the class. - [super tearDown]; -} - -- (void)unarchiver:(SUUnarchiver *)__unused unarchiver extractedProgress:(double)__unused progress -{ -} - -- (void)unarchiverDidFail:(SUUnarchiver *)__unused unarchiver -{ - self.result = NO; - [self.unarchived fulfill]; -} - -- (void)unarchiverDidFinish:(SUUnarchiver *)__unused unarchiver -{ - self.result = YES; - [self.unarchived fulfill]; -} - -- (void)testZipExtract -{ - NSString *originalArchivePath = [[NSBundle bundleForClass:[self class]] pathForResource:@"test archive" ofType:@"zip"]; - NSString *tempDestDir = NSTemporaryDirectory(); - NSString *tempArchivePath = [[tempDestDir stringByAppendingPathComponent:[[NSUUID UUID] UUIDString]] stringByAppendingPathExtension:@"zip"]; - - NSFileManager *fm = [NSFileManager defaultManager]; - NSString *testFile = [tempDestDir stringByAppendingPathComponent:@"extracted file.txt"]; - [fm removeItemAtPath:testFile error:nil]; - - XCTAssertFalse([fm fileExistsAtPath:testFile isDirectory:nil]); - XCTAssertTrue([fm copyItemAtPath:originalArchivePath toPath:tempArchivePath error:nil]); - - SUUnarchiver *unarc = [SUUnarchiver unarchiverForPath:tempArchivePath updatingHostBundlePath:nil]; - - XCTAssertTrue([unarc isKindOfClass:[SUPipedUnarchiver class]]); - - unarc.delegate = self; - [unarc start]; - - [self waitForExpectationsWithTimeout:5.0 handler:nil]; - - XCTAssertTrue(self.result); - XCTAssertTrue([fm fileExistsAtPath:testFile isDirectory:nil]); -} - -@end -#endif diff --git a/Tests/SUUnarchiverTest.swift b/Tests/SUUnarchiverTest.swift new file mode 100644 index 00000000..66f758bf --- /dev/null +++ b/Tests/SUUnarchiverTest.swift @@ -0,0 +1,93 @@ +// +// SUUnarchiverTest.swift +// Sparkle +// +// Created by Mayur Pawashe on 9/4/15. +// Copyright © 2015 Sparkle Project. All rights reserved. +// + +import XCTest + +class SUUnarchiverTest: XCTestCase, SUUnarchiverDelegate +{ + var unarchivedExpectation: XCTestExpectation? = nil + var unarchivedResult: Bool = false + + func unarchiver(unarchiver: SUUnarchiver!, extractedProgress progress: Double) + { + } + + func unarchiverDidFail(unarchiver: SUUnarchiver!) + { + self.unarchivedResult = false + self.unarchivedExpectation!.fulfill() + } + + func unarchiverDidFinish(unarchiver: SUUnarchiver!) + { + self.unarchivedResult = true + self.unarchivedExpectation!.fulfill() + } + + func unarchiveTestAppWithExtension(archiveExtension: String) + { + let appName = "SparkleTestCodeSignApp" + let archiveResourceURL = NSBundle(forClass: self.dynamicType).URLForResource(appName, withExtension: archiveExtension)! + + let fileManager = NSFileManager.defaultManager() + + let tempDirectoryURL = try! fileManager.URLForDirectory(.ItemReplacementDirectory, inDomain: .UserDomainMask, appropriateForURL: NSURL(fileURLWithPath: NSHomeDirectory()), create: true) + defer { + try! fileManager.removeItemAtURL(tempDirectoryURL) + } + + let tempArchiveURL = tempDirectoryURL.URLByAppendingPathComponent(archiveResourceURL.lastPathComponent!) + let extractedAppURL = tempDirectoryURL.URLByAppendingPathComponent(appName).URLByAppendingPathExtension("app") + + try! fileManager.copyItemAtURL(archiveResourceURL, toURL: tempArchiveURL) + + self.unarchivedExpectation = super.expectationWithDescription("Unarchived Application (format: \(archiveExtension))") + + let unarchiver = SUUnarchiver(forPath: tempArchiveURL.path!, updatingHostBundlePath: nil) + + unarchiver.delegate = self + unarchiver.start() + + super.waitForExpectationsWithTimeout(7.0, handler: nil) + + XCTAssertTrue(self.unarchivedResult) + XCTAssertTrue(fileManager.fileExistsAtPath(extractedAppURL.path!)) + + XCTAssertEqual("6a60ab31430cfca8fb499a884f4a29f73e59b472", hashOfTree(extractedAppURL.path!)) + } + + func testUnarchivingZip() + { + self.unarchiveTestAppWithExtension("zip") + } + + func testUnarchivingTarDotGz() + { + self.unarchiveTestAppWithExtension("tar.gz") + } + + func testUnarchivingTar() + { + self.unarchiveTestAppWithExtension("tar") + } + + func testUnarchivingTarDotBz2() + { + self.unarchiveTestAppWithExtension("tar.bz2") + } + + func testUnarchivingTarDotXz() + { + self.unarchiveTestAppWithExtension("tar.xz") + } + + func testUnarchivingDmg() + { + self.unarchiveTestAppWithExtension("dmg") + } +} diff --git a/Tests/Sparkle Unit Tests-Bridging-Header.h b/Tests/Sparkle Unit Tests-Bridging-Header.h new file mode 100644 index 00000000..f5d76dcd --- /dev/null +++ b/Tests/Sparkle Unit Tests-Bridging-Header.h @@ -0,0 +1,7 @@ +// +// Use this file to import your target's public headers that you would like to expose to Swift. +// + +#import "SUUnarchiver.h" +#import "SUPipedUnarchiver.h" +#import "SUBinaryDeltaCommon.h"