mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-24 04:38:16 +00:00
Don't let skipping a major version to skip subsequent major versions (#2079)
This commit is contained in:
4 files changed
+139
-3
No files matched your search
@@ -137,6 +137,7 @@
|
||||
720AC2C92618E89500E25A3E /* SUAppcastItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 61B5FC5409C5182000B25A18 /* SUAppcastItem.m */; };
|
||||
720AC2DC2618E8A500E25A3E /* SPUSecureCoding.m in Sources */ = {isa = PBXBuildFile; fileRef = 726E075B1CA3A6D6001A286B /* SPUSecureCoding.m */; };
|
||||
720B16451C66433D006985FB /* SUTestApplicationTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 720B16431C66433D006985FB /* SUTestApplicationTest.swift */; };
|
||||
720DC50427A51A6500DFF3EC /* testappcast_minimumAutoupdateVersionSkipping.xml in Resources */ = {isa = PBXBuildFile; fileRef = 720DC50327A51A6500DFF3EC /* testappcast_minimumAutoupdateVersionSkipping.xml */; };
|
||||
720E217B1D0D00BF003A311C /* SPUUpdaterCycle.h in Headers */ = {isa = PBXBuildFile; fileRef = 720E21791D0D00BF003A311C /* SPUUpdaterCycle.h */; };
|
||||
720E217C1D0D00BF003A311C /* SPUUpdaterCycle.m in Sources */ = {isa = PBXBuildFile; fileRef = 720E217A1D0D00BF003A311C /* SPUUpdaterCycle.m */; };
|
||||
7210C7681B9A9A1500EB90AC /* SUUnarchiverTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7210C7671B9A9A1500EB90AC /* SUUnarchiverTest.swift */; };
|
||||
@@ -973,6 +974,7 @@
|
||||
720B16431C66433D006985FB /* SUTestApplicationTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SUTestApplicationTest.swift; path = UITests/SUTestApplicationTest.swift; sourceTree = SOURCE_ROOT; };
|
||||
720B4C2325EBFAFD005A0592 /* link-tools.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "link-tools.sh"; sourceTree = "<group>"; };
|
||||
720C192827127A3800740C8E /* release-move-tag.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "release-move-tag.sh"; sourceTree = "<group>"; };
|
||||
720DC50327A51A6500DFF3EC /* testappcast_minimumAutoupdateVersionSkipping.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = testappcast_minimumAutoupdateVersionSkipping.xml; sourceTree = "<group>"; };
|
||||
720E21791D0D00BF003A311C /* SPUUpdaterCycle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPUUpdaterCycle.h; sourceTree = "<group>"; };
|
||||
720E217A1D0D00BF003A311C /* SPUUpdaterCycle.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPUUpdaterCycle.m; sourceTree = "<group>"; };
|
||||
7210C7671B9A9A1500EB90AC /* SUUnarchiverTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SUUnarchiverTest.swift; sourceTree = "<group>"; };
|
||||
@@ -1764,6 +1766,7 @@
|
||||
5AD0FA7E1C73F2E2004BCEFF /* testappcast.xml */,
|
||||
723EDC3E26885A8E000BCBA4 /* testappcast_channels.xml */,
|
||||
725B3A81263FBF0C0041AB8E /* testappcast_minimumAutoupdateVersion.xml */,
|
||||
720DC50327A51A6500DFF3EC /* testappcast_minimumAutoupdateVersionSkipping.xml */,
|
||||
7202DC99269ABD3500737EC4 /* testappcast_phasedRollout.xml */,
|
||||
722545B526805FF80036465C /* testappcast_info_updates.xml */,
|
||||
5F1510A11C96E591006E1629 /* testnamespaces.xml */,
|
||||
@@ -3036,6 +3039,7 @@
|
||||
725B3A82263FBF0C0041AB8E /* testappcast_minimumAutoupdateVersion.xml in Resources */,
|
||||
14958C6E19AEBC950061B14F /* signed-test-file.txt in Resources */,
|
||||
723EDC3F26885A8E000BCBA4 /* testappcast_channels.xml in Resources */,
|
||||
720DC50427A51A6500DFF3EC /* testappcast_minimumAutoupdateVersionSkipping.xml in Resources */,
|
||||
72AC6B2E1B9B218C00F62325 /* SparkleTestCodeSignApp.dmg in Resources */,
|
||||
C23E885B1BE7B24F0050BB73 /* SparkleTestCodeSignApp.enc.dmg in Resources */,
|
||||
72AC6B281B9AAD6700F62325 /* SparkleTestCodeSignApp.tar in Resources */,
|
||||
|
||||
Vendored
+2
-3
@@ -335,9 +335,8 @@
|
||||
{
|
||||
NSString *skippedMajorVersion = skippedUpdate.majorVersion;
|
||||
|
||||
if (!hostPassesSkippedMajorVersion && skippedMajorVersion != nil && [versionComparator compareVersion:skippedMajorVersion toVersion:ui.versionString] != NSOrderedDescending) {
|
||||
// Item is on a greater or equal version than a major version we've skipped
|
||||
// So we skip this item
|
||||
if (!hostPassesSkippedMajorVersion && skippedMajorVersion != nil && ui.minimumAutoupdateVersion != nil && [versionComparator compareVersion:skippedMajorVersion toVersion:(NSString * _Nonnull)ui.minimumAutoupdateVersion] != NSOrderedAscending) {
|
||||
// If skipped major version is >= than the item's minimumAutoupdateVersion, we can skip the item.
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<rss version="2.0" xmlns:sparkle="http://www.andymatuschak.org/xml-namespaces/sparkle">
|
||||
<channel>
|
||||
<title>For unit test only</title>
|
||||
<item>
|
||||
<title>Version 4.1</title>
|
||||
<sparkle:version>4.1</sparkle:version>
|
||||
<sparkle:minimumAutoupdateVersion>4.0</sparkle:minimumAutoupdateVersion>
|
||||
<enclosure url="http://localhost:1337/Sparkle_Test_App.zip" length="1346234" />
|
||||
</item>
|
||||
<item>
|
||||
<title>Version 4.0</title>
|
||||
<sparkle:version>4.0</sparkle:version>
|
||||
<sparkle:minimumAutoupdateVersion>4.0</sparkle:minimumAutoupdateVersion>
|
||||
<enclosure url="http://localhost:1337/Sparkle_Test_App.zip" length="1346234" />
|
||||
</item>
|
||||
<item>
|
||||
<title>Version 3.9</title>
|
||||
<sparkle:version>3.9</sparkle:version>
|
||||
<sparkle:minimumAutoupdateVersion>3.0</sparkle:minimumAutoupdateVersion>
|
||||
<enclosure url="http://localhost:1337/Sparkle_Test_App.zip" length="1346234" />
|
||||
</item>
|
||||
<item>
|
||||
<title>Version 3.0</title>
|
||||
<sparkle:version>3.0</sparkle:version>
|
||||
<sparkle:minimumAutoupdateVersion>3.0</sparkle:minimumAutoupdateVersion>
|
||||
<enclosure url="http://localhost:1337/Sparkle_Test_App.zip" length="1346234" />
|
||||
</item>
|
||||
<item>
|
||||
<title>Version 2.0</title>
|
||||
<sparkle:version>2.0</sparkle:version>
|
||||
<enclosure url="http://localhost:1337/Sparkle_Test_App.zip" length="1346234" />
|
||||
</item>
|
||||
</channel>
|
||||
</rss>
|
||||
@@ -472,6 +472,104 @@ class SUAppcastTest: XCTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
func testMinimumAutoupdateVersionAdvancedSkipping() {
|
||||
let testURL = Bundle(for: SUAppcastTest.self).url(forResource: "testappcast_minimumAutoupdateVersionSkipping", withExtension: "xml")!
|
||||
|
||||
do {
|
||||
let testData = try Data(contentsOf: testURL)
|
||||
|
||||
let versionComparator = SUStandardVersionComparator()
|
||||
|
||||
do {
|
||||
// Test appcast without a filter
|
||||
|
||||
let hostVersion = "1.0"
|
||||
|
||||
let stateResolver = SPUAppcastItemStateResolver(hostVersion: hostVersion, applicationVersionComparator: versionComparator, standardVersionComparator: versionComparator)
|
||||
let appcast = try SUAppcast(xmlData: testData, relativeTo: nil, stateResolver: stateResolver)
|
||||
|
||||
XCTAssertEqual(5, appcast.items.count)
|
||||
}
|
||||
|
||||
let currentDate = Date()
|
||||
// Because 3.0 has minimum autoupdate version of 3.0, and 4.0 has minimum autoupdate version of 4.0, we should be offered 2.0
|
||||
do {
|
||||
let hostVersion = "1.0"
|
||||
|
||||
let stateResolver = SPUAppcastItemStateResolver(hostVersion: hostVersion, applicationVersionComparator: versionComparator, standardVersionComparator: versionComparator)
|
||||
let appcast = try SUAppcast(xmlData: testData, relativeTo: nil, stateResolver: stateResolver)
|
||||
|
||||
let supportedAppcast = SUAppcastDriver.filterSupportedAppcast(appcast, phasedUpdateGroup: nil, skippedUpdate: nil, currentDate: currentDate, hostVersion: hostVersion, versionComparator: versionComparator, testOSVersion: true, testMinimumAutoupdateVersion: true)
|
||||
|
||||
XCTAssertEqual(1, supportedAppcast.items.count)
|
||||
|
||||
let bestAppcastItem = SUAppcastDriver.bestItem(fromAppcastItems: supportedAppcast.items, getDeltaItem: nil, withHostVersion: hostVersion, comparator: versionComparator)
|
||||
|
||||
XCTAssertEqual(bestAppcastItem.versionString, "2.0")
|
||||
}
|
||||
|
||||
// Allow minimum autoupdate version to fail and only skip major version "3.0"
|
||||
// This should skip all 3.x versions, but not 4.x versions nor 2.x versions
|
||||
do {
|
||||
let hostVersion = "1.0"
|
||||
|
||||
let stateResolver = SPUAppcastItemStateResolver(hostVersion: hostVersion, applicationVersionComparator: versionComparator, standardVersionComparator: versionComparator)
|
||||
let appcast = try SUAppcast(xmlData: testData, relativeTo: nil, stateResolver: stateResolver)
|
||||
|
||||
let skippedUpdate = SPUSkippedUpdate(minorVersion: nil, majorVersion: "3.0")
|
||||
|
||||
let supportedAppcast = SUAppcastDriver.filterSupportedAppcast(appcast, phasedUpdateGroup: nil, skippedUpdate: skippedUpdate, currentDate: currentDate, hostVersion: hostVersion, versionComparator: versionComparator, testOSVersion: true, testMinimumAutoupdateVersion: false)
|
||||
|
||||
XCTAssertEqual(3, supportedAppcast.items.count)
|
||||
|
||||
let bestAppcastItem = SUAppcastDriver.bestItem(fromAppcastItems: supportedAppcast.items, getDeltaItem: nil, withHostVersion: hostVersion, comparator: versionComparator)
|
||||
|
||||
XCTAssertEqual(bestAppcastItem.versionString, "4.1")
|
||||
}
|
||||
|
||||
// Allow minimum autoupdate version to pass and only skip major version "3.0"
|
||||
// This should only return back the latest minor version available
|
||||
do {
|
||||
let hostVersion = "1.0"
|
||||
|
||||
let stateResolver = SPUAppcastItemStateResolver(hostVersion: hostVersion, applicationVersionComparator: versionComparator, standardVersionComparator: versionComparator)
|
||||
let appcast = try SUAppcast(xmlData: testData, relativeTo: nil, stateResolver: stateResolver)
|
||||
|
||||
let skippedUpdate = SPUSkippedUpdate(minorVersion: nil, majorVersion: "3.0")
|
||||
|
||||
let supportedAppcast = SUAppcastDriver.filterSupportedAppcast(appcast, phasedUpdateGroup: nil, skippedUpdate: skippedUpdate, currentDate: currentDate, hostVersion: hostVersion, versionComparator: versionComparator, testOSVersion: true, testMinimumAutoupdateVersion: true)
|
||||
|
||||
XCTAssertEqual(1, supportedAppcast.items.count)
|
||||
|
||||
let bestAppcastItem = SUAppcastDriver.bestItem(fromAppcastItems: supportedAppcast.items, getDeltaItem: nil, withHostVersion: hostVersion, comparator: versionComparator)
|
||||
|
||||
XCTAssertEqual(bestAppcastItem.versionString, "2.0")
|
||||
}
|
||||
|
||||
// Allow minimum autoupdate version to fail and only skip major version "4.0"
|
||||
// This should skip all 3.x versions and 4.x versions but not 2.x versions
|
||||
do {
|
||||
let hostVersion = "1.0"
|
||||
|
||||
let stateResolver = SPUAppcastItemStateResolver(hostVersion: hostVersion, applicationVersionComparator: versionComparator, standardVersionComparator: versionComparator)
|
||||
let appcast = try SUAppcast(xmlData: testData, relativeTo: nil, stateResolver: stateResolver)
|
||||
|
||||
let skippedUpdate = SPUSkippedUpdate(minorVersion: nil, majorVersion: "4.0")
|
||||
|
||||
let supportedAppcast = SUAppcastDriver.filterSupportedAppcast(appcast, phasedUpdateGroup: nil, skippedUpdate: skippedUpdate, currentDate: currentDate, hostVersion: hostVersion, versionComparator: versionComparator, testOSVersion: true, testMinimumAutoupdateVersion: false)
|
||||
|
||||
XCTAssertEqual(1, supportedAppcast.items.count)
|
||||
|
||||
let bestAppcastItem = SUAppcastDriver.bestItem(fromAppcastItems: supportedAppcast.items, getDeltaItem: nil, withHostVersion: hostVersion, comparator: versionComparator)
|
||||
|
||||
XCTAssertEqual(bestAppcastItem.versionString, "2.0")
|
||||
}
|
||||
} catch let err as NSError {
|
||||
NSLog("%@", err)
|
||||
XCTFail(err.localizedDescription)
|
||||
}
|
||||
}
|
||||
|
||||
func testPhasedGroupRollouts() {
|
||||
let testURL = Bundle(for: SUAppcastTest.self).url(forResource: "testappcast_phasedRollout", withExtension: "xml")!
|
||||
|
||||
|
||||
Reference in new issue
Block a user