From 2a693e62bfffa1df95d3b38014de99d9657934f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kornel=20Lesi=C5=84ski?= Date: Thu, 4 Feb 2016 23:57:25 +0000 Subject: [PATCH 1/4] v1.13.1 --- Configurations/ConfigCommon.xcconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Configurations/ConfigCommon.xcconfig b/Configurations/ConfigCommon.xcconfig index 3f751fdc..4ba80bc0 100644 --- a/Configurations/ConfigCommon.xcconfig +++ b/Configurations/ConfigCommon.xcconfig @@ -16,7 +16,7 @@ SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME = 0 SPARKLE_VERSION_MAJOR = 1 SPARKLE_VERSION_MINOR = 13 -SPARKLE_VERSION_PATCH = 0 +SPARKLE_VERSION_PATCH = 1 SPARKLE_VERSION = $(SPARKLE_VERSION_MAJOR).$(SPARKLE_VERSION_MINOR).$(SPARKLE_VERSION_PATCH) CURRENT_PROJECT_VERSION = $(SPARKLE_VERSION) From a11b1209a97bafd713189f9b0fa14584ba6e100a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kornel=20Lesi=C5=84ski?= Date: Thu, 18 Feb 2016 13:50:05 +0100 Subject: [PATCH 2/4] Unit test for appcast parsing --- Sparkle.xcodeproj/project.pbxproj | 38 +++++++++++++--------- Sparkle/SUAppcast.m | 4 +++ Tests/Resources/testappcast.xml | 17 ++++++++++ Tests/SUAppcastTest.swift | 38 ++++++++++++++++++++++ Tests/Sparkle Unit Tests-Bridging-Header.h | 12 +++++++ 5 files changed, 94 insertions(+), 15 deletions(-) create mode 100644 Tests/Resources/testappcast.xml create mode 100644 Tests/SUAppcastTest.swift diff --git a/Sparkle.xcodeproj/project.pbxproj b/Sparkle.xcodeproj/project.pbxproj index 8b9ac634..e20a16f3 100644 --- a/Sparkle.xcodeproj/project.pbxproj +++ b/Sparkle.xcodeproj/project.pbxproj @@ -72,8 +72,10 @@ 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, ); }; }; + 5A4094481C74EA5200983BE0 /* SUAppcastTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5AA4DCD01C73E5510078F128 /* SUAppcastTest.swift */; }; 5A6D31EE1BF53245009C5157 /* SUFileManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 7275F9C01B5F1F2900B1D19E /* SUFileManager.m */; }; 5A6D31EF1BF5325F009C5157 /* SUOperatingSystem.m in Sources */ = {isa = PBXBuildFile; fileRef = 726F2CE41BC9C33D001971A4 /* SUOperatingSystem.m */; }; + 5AD0FA7F1C73F2E2004BCEFF /* testappcast.xml in Resources */ = {isa = PBXBuildFile; fileRef = 5AD0FA7E1C73F2E2004BCEFF /* testappcast.xml */; }; 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 */; }; @@ -443,6 +445,8 @@ 55C14F05136EF6DB00649790 /* SULog.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SULog.m; sourceTree = ""; }; 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 = ""; }; + 5AA4DCD01C73E5510078F128 /* SUAppcastTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SUAppcastTest.swift; sourceTree = ""; }; + 5AD0FA7E1C73F2E2004BCEFF /* testappcast.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = testappcast.xml; sourceTree = ""; }; 5AEF45D9189D1CC90030D7DC /* tr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = tr; path = tr.lproj/Sparkle.strings; 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 = ""; }; @@ -844,6 +848,7 @@ F8761EB21ADC50EB000C9034 /* SparkleTestCodeSignApp.zip */, 14958C6C19AEBC610061B14F /* test-pubkey.pem */, 5AF6C74E1AEA46D10014A3AB /* test.sparkle_guided.pkg */, + 5AD0FA7E1C73F2E2004BCEFF /* testappcast.xml */, ); path = Resources; sourceTree = ""; @@ -894,6 +899,7 @@ 14958C7019AEBE350061B14F /* Resources */, 72AFC6121B9A944200F6B565 /* Sparkle Unit Tests-Bridging-Header.h */, 612279DA0DB5470200AB99EA /* SparkleTests-Info.plist */, + 5AA4DCD01C73E5510078F128 /* SUAppcastTest.swift */, 142E0E0819A83AAC00E4312B /* SUBinaryDeltaTest.m */, F8761EB01ADC5068000C9034 /* SUCodeSigningVerifierTest.m */, 5AF9DC3B1981DBEE001EA135 /* SUDSAVerifierTest.m */, @@ -968,10 +974,10 @@ 14652F8319A9759F00959E44 /* SUExport.h */, 61EF67580E25C5B400F754E0 /* SUHost.h */, 61EF67550E25B58D00F754E0 /* SUHost.m */, - 726F2CE31BC9C33D001971A4 /* SUOperatingSystem.h */, - 726F2CE41BC9C33D001971A4 /* SUOperatingSystem.m */, 55C14F04136EF6DB00649790 /* SULog.h */, 55C14F05136EF6DB00649790 /* SULog.m */, + 726F2CE31BC9C33D001971A4 /* SUOperatingSystem.h */, + 726F2CE41BC9C33D001971A4 /* SUOperatingSystem.m */, ); includeInIndex = 1; name = "Other Sources"; @@ -987,10 +993,10 @@ 72E45CFB1B641961005C701A /* sparkletestcast.xml */, 72E45CF11B640CDD005C701A /* SUTestApplicationDelegate.h */, 72E45CF21B640CDD005C701A /* SUTestApplicationDelegate.m */, - 72E45CF41B640DAE005C701A /* SUUpdateSettingsWindowController.h */, - 72E45CF51B640DAE005C701A /* SUUpdateSettingsWindowController.m */, A5BF4F1B1BC7668B007A052A /* SUTestWebServer.h */, A5BF4F1C1BC7668B007A052A /* SUTestWebServer.m */, + 72E45CF41B640DAE005C701A /* SUUpdateSettingsWindowController.h */, + 72E45CF51B640DAE005C701A /* SUUpdateSettingsWindowController.m */, 72E45CF61B640DAE005C701A /* SUUpdateSettingsWindowController.xib */, 72E45CFD1B641D0D005C701A /* test_app_only_dsa_priv_dont_ever_do_this_for_real.pem */, 14732BBF1960F0AC00593899 /* test_app_only_dsa_pub.pem */, @@ -1269,8 +1275,8 @@ isa = PBXProject; attributes = { CLASSPREFIX = SU; - LastSwiftUpdateCheck = 0700; - LastUpgradeCheck = 0710; + LastSwiftUpdateCheck = 0720; + LastUpgradeCheck = 0720; ORGANIZATIONNAME = "Sparkle Project"; TargetAttributes = { 612279D80DB5470200AB99EA = { @@ -1356,6 +1362,7 @@ F8761EB31ADC50EB000C9034 /* SparkleTestCodeSignApp.zip in Resources */, 14958C6F19AEBC980061B14F /* test-pubkey.pem in Resources */, 5AF6C74F1AEA46D10014A3AB /* test.sparkle_guided.pkg in Resources */, + 5AD0FA7F1C73F2E2004BCEFF /* testappcast.xml in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1471,7 +1478,6 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 726F2CE71BC9C3E2001971A4 /* SUOperatingSystem.m in Sources */, 55C14BD4136EEFCE00649790 /* Autoupdate.m in Sources */, F8761EB61ADC5E7A000C9034 /* SUCodeSigningVerifier.m in Sources */, 55C14F00136EF6B700649790 /* SUConstants.m in Sources */, @@ -1480,6 +1486,7 @@ 55C14F0C136EF6EA00649790 /* SUHost.m in Sources */, 55C14F0D136EF6F200649790 /* SUInstaller.m in Sources */, 55C14F08136EF6DB00649790 /* SULog.m in Sources */, + 726F2CE71BC9C3E2001971A4 /* SUOperatingSystem.m in Sources */, 55C14F24136EF86F00649790 /* SUPackageInstaller.m in Sources */, 55C14F21136EF84D00649790 /* SUPlainInstaller.m in Sources */, 55C14F22136EF86000649790 /* SUStandardVersionComparator.m in Sources */, @@ -1493,9 +1500,6 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 726F2CE91BC9C499001971A4 /* SUOperatingSystem.m in Sources */, - 726F2CE81BC9C48F001971A4 /* SUConstants.m in Sources */, - 726F2CDE1BC9BE5B001971A4 /* SUFileManager.m in Sources */, 5D06E8E90FD68CDB005AE3F6 /* bsdiff.c in Sources */, 14652F7E19A9728A00959E44 /* bspatch.c in Sources */, 7223E7631AD1AEFF008E3161 /* sais.c in Sources */, @@ -1503,6 +1507,9 @@ 14652F7C19A9725300959E44 /* SUBinaryDeltaCommon.m in Sources */, 7268AC631AD634C200C3E0C1 /* SUBinaryDeltaCreate.m in Sources */, 5D06E8EA0FD68CDB005AE3F6 /* SUBinaryDeltaTool.m in Sources */, + 726F2CE81BC9C48F001971A4 /* SUConstants.m in Sources */, + 726F2CDE1BC9BE5B001971A4 /* SUFileManager.m in Sources */, + 726F2CE91BC9C499001971A4 /* SUOperatingSystem.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1513,6 +1520,7 @@ 721CF1A71AD7643600D9AC09 /* bsdiff.c in Sources */, 721CF1A81AD7644100D9AC09 /* bspatch.c in Sources */, 721CF1A91AD7644C00D9AC09 /* sais.c in Sources */, + 5A4094481C74EA5200983BE0 /* SUAppcastTest.swift in Sources */, 72D4DAA11AD7632900B211E2 /* SUBinaryDeltaCreate.m in Sources */, 142E0E0919A83AAC00E4312B /* SUBinaryDeltaTest.m in Sources */, F8761EB11ADC5068000C9034 /* SUCodeSigningVerifierTest.m in Sources */, @@ -1529,12 +1537,12 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 726F2CEB1BC9C733001971A4 /* SUConstants.m in Sources */, - 5A6D31EF1BF5325F009C5157 /* SUOperatingSystem.m in Sources */, - 5A6D31EE1BF53245009C5157 /* SUFileManager.m in Sources */, 61B5F93009C4CFDC00B25A18 /* main.m in Sources */, - A5BF4F1D1BC7668B007A052A /* SUTestWebServer.m in Sources */, + 726F2CEB1BC9C733001971A4 /* SUConstants.m in Sources */, + 5A6D31EE1BF53245009C5157 /* SUFileManager.m in Sources */, + 5A6D31EF1BF5325F009C5157 /* SUOperatingSystem.m in Sources */, 72E45CF31B640CDD005C701A /* SUTestApplicationDelegate.m in Sources */, + A5BF4F1D1BC7668B007A052A /* SUTestWebServer.m in Sources */, 72E45CF71B640DAE005C701A /* SUUpdateSettingsWindowController.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -1562,12 +1570,12 @@ 61EF67560E25B58D00F754E0 /* SUHost.m in Sources */, 618FA5020DAE88B40026945C /* SUInstaller.m in Sources */, 55C14F07136EF6DB00649790 /* SULog.m in Sources */, + 726F2CE61BC9C33D001971A4 /* SUOperatingSystem.m in Sources */, 618FA5230DAE8E8A0026945C /* SUPackageInstaller.m in Sources */, 61D85D6D0E10B2ED00F9B4A9 /* SUPipedUnarchiver.m in Sources */, 618FA5060DAE8AB80026945C /* SUPlainInstaller.m in Sources */, 6101347C0DD2541A0049ACDF /* SUProbingUpdateDriver.m in Sources */, 61B93C0A0DD112FF00DCD2F8 /* SUScheduledUpdateDriver.m in Sources */, - 726F2CE61BC9C33D001971A4 /* SUOperatingSystem.m in Sources */, 61A225A50D1C4AC000430CCD /* SUStandardVersionComparator.m in Sources */, 6196CFFA09C72149000DC222 /* SUStatusController.m in Sources */, 61A2279D0D1CEE7600430CCD /* SUSystemProfiler.m in Sources */, diff --git a/Sparkle/SUAppcast.m b/Sparkle/SUAppcast.m index 42254148..eec78666 100644 --- a/Sparkle/SUAppcast.m +++ b/Sparkle/SUAppcast.m @@ -92,6 +92,10 @@ - (void)downloadDidFinish:(NSURLDownload *)__unused aDownload { + [self parse]; +} + +- (void) parse { NSError *error = nil; NSXMLDocument *document = nil; diff --git a/Tests/Resources/testappcast.xml b/Tests/Resources/testappcast.xml new file mode 100644 index 00000000..0023508e --- /dev/null +++ b/Tests/Resources/testappcast.xml @@ -0,0 +1,17 @@ + + + + For unit test only + + Version 2.0 + desc + Sat, 26 Jul 2014 15:20:11 +0000 + + + + Version 3.0 + Sat, 26 Jul 2014 15:20:12 +0000 + + + + diff --git a/Tests/SUAppcastTest.swift b/Tests/SUAppcastTest.swift new file mode 100644 index 00000000..570745d0 --- /dev/null +++ b/Tests/SUAppcastTest.swift @@ -0,0 +1,38 @@ +// +// SUAppcastTest.swift +// Sparkle +// +// Created by Kornel on 17/02/2016. +// Copyright © 2016 Sparkle Project. All rights reserved. +// + +import XCTest +import Sparkle; + +class SUAppcastTest: XCTestCase { + + func testExample() { + let appcast = SUAppcast(); + let testFile = NSBundle(forClass: SUAppcastTest.self).pathForResource("testappcast", ofType: "xml")!; + let testFileUrl = NSURL(fileURLWithPath: testFile); + XCTAssertNotNil(testFileUrl); + + do { + appcast.completionBlock = {err -> () in}; + appcast.downloadFilename = testFile; + + appcast.parse(); + let items = appcast.items as! [SUAppcastItem]; + + XCTAssertEqual(2, items.count); + XCTAssertEqual("Version 3.0", items[0].title); + XCTAssertNil(items[0].itemDescription); + + XCTAssertEqual("Version 2.0", items[1].title); + XCTAssertEqual("desc", items[1].itemDescription); + } catch let err as NSError { + NSLog("%@", err); + XCTFail(err.localizedDescription); + } + } +} diff --git a/Tests/Sparkle Unit Tests-Bridging-Header.h b/Tests/Sparkle Unit Tests-Bridging-Header.h index ab678027..49507f83 100644 --- a/Tests/Sparkle Unit Tests-Bridging-Header.h +++ b/Tests/Sparkle Unit Tests-Bridging-Header.h @@ -6,6 +6,8 @@ #import "SUPipedUnarchiver.h" #import "SUBinaryDeltaCommon.h" #import "SUFileManager.h" +#import "SUAppcast.h" +#import "SUAppcastItem.h" // Duplicated to avoid exporting a private symbol from SUFileManager static const char *SUAppleQuarantineIdentifier = "com.apple.quarantine"; @@ -20,3 +22,13 @@ static const char *SUAppleQuarantineIdentifier = "com.apple.quarantine"; - (BOOL)_makeDirectoryAtURL:(NSURL *)url error:(NSError * __autoreleasing *)error; @end + + +@interface SUAppcast (Private) +@property (strong) void (^completionBlock)(NSError *); +@property (copy) NSString *downloadFilename; +@property (readonly, copy) NSArray *items; + +- (void)parse; +@end + From 2668d182664e7d8325ab7e286561fd67c68d393a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kornel=20Lesi=C5=84ski?= Date: Wed, 17 Feb 2016 18:34:28 +0100 Subject: [PATCH 3/4] Appcast test --- Tests/SUAppcastTest.swift | 6 +----- Tests/Sparkle Unit Tests-Bridging-Header.h | 6 +----- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/Tests/SUAppcastTest.swift b/Tests/SUAppcastTest.swift index 570745d0..5f39f795 100644 --- a/Tests/SUAppcastTest.swift +++ b/Tests/SUAppcastTest.swift @@ -18,11 +18,7 @@ class SUAppcastTest: XCTestCase { XCTAssertNotNil(testFileUrl); do { - appcast.completionBlock = {err -> () in}; - appcast.downloadFilename = testFile; - - appcast.parse(); - let items = appcast.items as! [SUAppcastItem]; + let items = try appcast.parseAppcastItemsFromXMLFile(testFileUrl) as! [SUAppcastItem]; XCTAssertEqual(2, items.count); XCTAssertEqual("Version 3.0", items[0].title); diff --git a/Tests/Sparkle Unit Tests-Bridging-Header.h b/Tests/Sparkle Unit Tests-Bridging-Header.h index 49507f83..512f4a58 100644 --- a/Tests/Sparkle Unit Tests-Bridging-Header.h +++ b/Tests/Sparkle Unit Tests-Bridging-Header.h @@ -25,10 +25,6 @@ static const char *SUAppleQuarantineIdentifier = "com.apple.quarantine"; @interface SUAppcast (Private) -@property (strong) void (^completionBlock)(NSError *); -@property (copy) NSString *downloadFilename; -@property (readonly, copy) NSArray *items; - -- (void)parse; +- (NSArray *)parseAppcastItemsFromXMLFile:(NSURL *)appcastFile error:(NSError *__autoreleasing*)errorp; @end From 9671f7f52df2425bfa922e8057e4116efb93d1da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kornel=20Lesi=C5=84ski?= Date: Thu, 18 Feb 2016 19:28:03 +0100 Subject: [PATCH 4/4] Fixed duplicated appcast item properties Corrected scope of per-node objects --- Sparkle/SUAppcast.m | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Sparkle/SUAppcast.m b/Sparkle/SUAppcast.m index 63f746e6..ac1c43bb 100644 --- a/Sparkle/SUAppcast.m +++ b/Sparkle/SUAppcast.m @@ -135,14 +135,14 @@ return nil; } - NSEnumerator *nodeEnum = [xmlItems objectEnumerator]; - - NSXMLNode *node; - NSMutableDictionary *nodesDict = [NSMutableDictionary dictionary]; - NSMutableDictionary *dict = [NSMutableDictionary dictionary]; NSMutableArray *appcastItems = [NSMutableArray array]; + NSEnumerator *nodeEnum = [xmlItems objectEnumerator]; + NSXMLNode *node; while((node = [nodeEnum nextObject])) { + NSMutableDictionary *nodesDict = [NSMutableDictionary dictionary]; + NSMutableDictionary *dict = [NSMutableDictionary dictionary]; + // First, we'll "index" all the first-level children of this appcast item so we can pick them out by language later. if ([[node children] count]) { node = [node childAtIndex:0];