From 209d6db3a195c134f21c36da32fb8ab111b84fac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kornel=20Lesin=CC=81ski?= Date: Fri, 24 Apr 2015 11:10:41 +0100 Subject: [PATCH] Test guided installation --- Sparkle.xcodeproj/project.pbxproj | 10 +++- Sparkle/SUInstaller.m | 7 +++ Tests/Resources/test.sparkle_guided.pkg | Bin 0 -> 4956 bytes Tests/SUInstallerTest.m | 65 ++++++++++++++++++++++++ 4 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 Tests/Resources/test.sparkle_guided.pkg create mode 100644 Tests/SUInstallerTest.m diff --git a/Sparkle.xcodeproj/project.pbxproj b/Sparkle.xcodeproj/project.pbxproj index e0a5985a..b84c79ed 100644 --- a/Sparkle.xcodeproj/project.pbxproj +++ b/Sparkle.xcodeproj/project.pbxproj @@ -73,8 +73,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, ); }; }; - 5AF6C1E91AE86E270014A3AB /* test archive.zip in Resources */ = {isa = PBXBuildFile; fileRef = 5AF6C1E81AE86E270014A3AB /* test archive.zip */; }; 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 */; }; 5D06E8E90FD68CDB005AE3F6 /* bsdiff.c in Sources */ = {isa = PBXBuildFile; fileRef = 5D06E8DB0FD68CB9005AE3F6 /* bsdiff.c */; settings = {COMPILER_FLAGS = "-w"; }; }; 5D06E8EA0FD68CDB005AE3F6 /* SUBinaryDeltaTool.m in Sources */ = {isa = PBXBuildFile; fileRef = 5D06E8E30FD68CC7005AE3F6 /* SUBinaryDeltaTool.m */; }; @@ -415,6 +417,8 @@ 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 = ""; }; 5D06E8D00FD68C7C005AE3F6 /* BinaryDelta */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = BinaryDelta; sourceTree = BUILT_PRODUCTS_DIR; }; 5D06E8DB0FD68CB9005AE3F6 /* bsdiff.c */ = {isa = PBXFileReference; comments = "-Wno-shorten-64-to-32"; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bsdiff.c; sourceTree = ""; }; @@ -787,6 +791,7 @@ F8761EB21ADC50EB000C9034 /* SparkleTestCodeSignApp.zip */, 5AF6C1E81AE86E270014A3AB /* test archive.zip */, 14958C6C19AEBC610061B14F /* test-pubkey.pem */, + 5AF6C74E1AEA46D10014A3AB /* test.sparkle_guided.pkg */, ); path = Resources; sourceTree = ""; @@ -839,6 +844,7 @@ 142E0E0819A83AAC00E4312B /* SUBinaryDeltaTest.m */, F8761EB01ADC5068000C9034 /* SUCodeSigningVerifierTest.m */, 5AF9DC3B1981DBEE001EA135 /* SUDSAVerifierTest.m */, + 5AF6C74C1AEA40760014A3AB /* SUInstallerTest.m */, 5AF6C1EA1AE870A90014A3AB /* SUPipedUnarchiverTest.m */, 14950074195FDF5900BC5B5B /* SUUpdaterTest.m */, 61227A150DB548B800AB99EA /* SUVersionComparisonTest.m */, @@ -1276,6 +1282,7 @@ F8761EB31ADC50EB000C9034 /* SparkleTestCodeSignApp.zip in Resources */, 5AF6C1E91AE86E270014A3AB /* test archive.zip in Resources */, 14958C6F19AEBC980061B14F /* test-pubkey.pem in Resources */, + 5AF6C74F1AEA46D10014A3AB /* test.sparkle_guided.pkg in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1443,6 +1450,7 @@ 142E0E0919A83AAC00E4312B /* SUBinaryDeltaTest.m in Sources */, F8761EB11ADC5068000C9034 /* SUCodeSigningVerifierTest.m in Sources */, 5AF9DC3C1981DBEE001EA135 /* SUDSAVerifierTest.m in Sources */, + 5AF6C7541AEA49840014A3AB /* SUInstallerTest.m in Sources */, 14652F8219A9746000959E44 /* SULog.m in Sources */, 5AF6C1E51AE86A410014A3AB /* SUPipedUnarchiverTest.m in Sources */, ); diff --git a/Sparkle/SUInstaller.m b/Sparkle/SUInstaller.m index 19d1a718..2513973a 100644 --- a/Sparkle/SUInstaller.m +++ b/Sparkle/SUInstaller.m @@ -44,6 +44,9 @@ static NSString *sUpdateFolder = nil; + (NSString *)installSourcePathInUpdateFolder:(NSString *)inUpdateFolder forHost:(SUHost *)host isPackage:(BOOL *)isPackagePtr isGuided:(BOOL *)isGuidedPtr { + NSParameterAssert(inUpdateFolder); + NSParameterAssert(host); + // Search subdirectories for the application NSString *currentFile, *newAppDownloadPath = nil, @@ -111,6 +114,10 @@ static NSString *sUpdateFolder = nil; *isPackagePtr = isPackage; if (isGuidedPtr) *isGuidedPtr = isGuided; + + if (!newAppDownloadPath) { + SULog(@"Searched %@ for %@.(app|pkg)", inUpdateFolder, bundleFileNameNoExtension); + } return newAppDownloadPath; } diff --git a/Tests/Resources/test.sparkle_guided.pkg b/Tests/Resources/test.sparkle_guided.pkg new file mode 100644 index 0000000000000000000000000000000000000000..f4933a800335c8f921ec271b53f14fe791e8c412 GIT binary patch literal 4956 zcmeH~d03Oj*1+Eoh!7KGmqj45C}A=Ch5-Uf2^e-<5D~HyfrOHvEFwV^v4Da>t!OJE zf(ivu!CFBNUHl(Lc&b$O9BJ;t>vQWiCx=H)wa?gpgR$Csg`T<>5jX;n0bWPl}^DAsE z+j+7~)YaWY2$cQAEI02;Qd=0}I9*TDnCsUoYToweDjz=N`}M}>v}|5-ygzaHOvI_X z%lppFa$K7|+4!B?Xlg=y%H`&zH+72^+j*1 z?ZzFq^hqcsvx3?l7&EL|Z(Xe&5zI+z;Kq6`n=pP?htG-?2}2_HDW69+Z2$I1*X>7z?;q8&`KLCl4vU>hMcF#(CE4IZ;Dw={EDQeeT6g6tB2@j~@4~ zo9Z-9aINHfI(+Ww*PGh$>D17IH^)|q(oePig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LjJ{%awR!AgDu}b^!(_NijDa!^Mq%j!a z!L)syT0DKHa7tBHirB{qzHKrg$go0A$n+9q%hJeB1nufLHn@W6e4*-hclFm<$|OG6 zBZ(*>^XW_yiB1MNqS8eSrclTfN+=Wo$Qwx{rU@7zu^`+38EJZn|EPvPuE6Khm~;V2 zL}G~rB8Ei7pn!jUz*_)jYD)Jy{{Q){2bM7aKZf8vU<5z|W&*IF?o9w@084;1U=FB# z9Kadi1z>~yMgU4c3~*3?C>W+U^?xlG-4nvk{C{om_YCl*<9GX>4fbaXa0IvkNMN5q zfK1>AUoW^${;XjBW~Gj+&jZe2dvL-0*qoj_1;*bx>h$og;W!=B`Uad%ZwB=6t*@Ha zLtyPcYaj%{95}%7Y^SjX5(fUeYz6rDW&#vw0K67F7xO!ofj}@3fF*!vfEd_$K=Oek z0l1(a0uX^d0?5Sx`m~J*B}1d<0N|K# zd^ip~5B4_z5?+G|;70BvEU?34ZvecWDHy~1kpSR*z_GmmNr1oFUm5r-1AolG FKLMVTQnvsA literal 0 HcmV?d00001 diff --git a/Tests/SUInstallerTest.m b/Tests/SUInstallerTest.m new file mode 100644 index 00000000..ceee0b6c --- /dev/null +++ b/Tests/SUInstallerTest.m @@ -0,0 +1,65 @@ +// +// SUInstallerTest.m +// Sparkle +// +// Created by Kornel on 24/04/2015. +// Copyright (c) 2015 Sparkle Project. All rights reserved. +// + +#import +#import +#import "SUHost.h" +#import "SUInstaller.h" +#import + +@interface SUInstallerTest : XCTestCase + +@end + +@implementation SUInstallerTest + +- (void)setUp +{ + [super setUp]; + // Put setup code here. This method is called before the invocation of each test method in the class. +} + +- (void)tearDown +{ + // Put teardown code here. This method is called after the invocation of each test method in the class. + [super tearDown]; +} + +- (void)testInstallIfRoot +{ + uid_t uid = getuid(); + + if (uid) { + NSLog(@"Test must be run as root: sudo xctest -XCTest SUInstallerTest 'Sparkle Unit Tests.xctest'"); + return; + } + + NSString *expectedDestination = @"/tmp/sparklepkgtest.app"; + NSFileManager *fm = [NSFileManager defaultManager]; + [fm removeItemAtPath:expectedDestination error:nil]; + XCTAssertFalse([fm fileExistsAtPath:expectedDestination isDirectory:nil]); + + XCTestExpectation *done = [self expectationWithDescription:@"install finished"]; + + NSBundle *bundle = [NSBundle bundleForClass:[self class]]; + NSString *path = [bundle pathForResource:@"test.sparkle_guided" ofType:@"pkg"]; + XCTAssertNotNil(path); + + SUHost *host = [[SUHost alloc] initWithBundle:bundle]; + + [SUInstaller installFromUpdateFolder:[path stringByDeletingLastPathComponent] overHost:host installationPath:@"/tmp" versionComparator:nil completionHandler:^(NSError *error) { + XCTAssertNil(error); + XCTAssertTrue([fm fileExistsAtPath:expectedDestination isDirectory:nil]); + [done fulfill]; + }]; + + [self waitForExpectationsWithTimeout:40 handler:nil]; + [fm removeItemAtPath:expectedDestination error:nil]; +} + +@end