fix(update): report the newest known version, not just the compiled one
Trusting the version compiled into the binary alone made the app report a stale release whenever the build predated a version bump: `version` is read at configure time, and bumping it is not by itself a reason to configure again, so `cmake --build` kept the previous number compiled in while the marker it installed next to the binary said otherwise. The update was then offered again even though it had just been applied. The version file is now a configure dependency, so a bump reconfigures the build, and the reported version is the newest of the two sources, so neither side can drag the app backwards. Generated with Codebuff 🤖 Co-Authored-By: Codebuff <noreply@codebuff.com>
This commit is contained in:
1 parent
fb5c11e153
commit
5216480d81
6 files changed
+75
-31
No files matched your search
@@ -119,12 +119,30 @@ static void testChooseMethod_noneWhenNothingAvailable() {
|
||||
"method_none_without_anything");
|
||||
}
|
||||
|
||||
// The version the app reports is the one compiled into it, so a stale `version`
|
||||
// file next to the executable can never make it re-offer an installed update.
|
||||
static void testCurrentVersion_isCompiledIn() {
|
||||
check(UpdateManager::currentVersion() == QStringLiteral(FWSPACMANAGE_VERSION),
|
||||
"current_version_compiled_in");
|
||||
check(!UpdateManager::currentVersion().isEmpty(), "current_version_not_empty");
|
||||
// Reconciliation of the two sources of truth: whichever is ahead wins, an empty
|
||||
// side never does. This is what stops a release from being offered again when the
|
||||
// binary and the installed marker disagree.
|
||||
static void testNewestVersion() {
|
||||
check(UpdateManager::newestVersion("1.3.1", "1.4.1") == "1.4.1",
|
||||
"newest_installed_ahead");
|
||||
check(UpdateManager::newestVersion("1.4.1", "1.3.1") == "1.4.1",
|
||||
"newest_compiled_ahead");
|
||||
check(UpdateManager::newestVersion("1.4.1", "1.4.1") == "1.4.1", "newest_equal");
|
||||
check(UpdateManager::newestVersion("v1.4.1", "1.3.1") == "v1.4.1",
|
||||
"newest_tag_prefix");
|
||||
check(UpdateManager::newestVersion("", "1.3.1") == "1.3.1", "newest_empty_compiled");
|
||||
check(UpdateManager::newestVersion("1.3.1", "") == "1.3.1", "newest_empty_installed");
|
||||
check(UpdateManager::newestVersion("1.10.0", "1.9.9") == "1.10.0",
|
||||
"newest_minor_beats_patch");
|
||||
}
|
||||
|
||||
// Whatever sits next to the test binary, the reported version never goes
|
||||
// backwards relative to the one compiled into it.
|
||||
static void testCurrentVersion_neverOlderThanCompiled() {
|
||||
const QString reported = UpdateManager::currentVersion();
|
||||
check(!reported.isEmpty(), "current_version_not_empty");
|
||||
check(!UpdateManager::isNewerVersion(QStringLiteral(FWSPACMANAGE_VERSION), reported),
|
||||
"current_version_not_older_than_compiled");
|
||||
}
|
||||
|
||||
// The staged install must replace an executable that is currently running,
|
||||
@@ -296,7 +314,8 @@ int main() {
|
||||
check(UpdateManager::isNewerVersion("", "1.3.1") == false, "empty_remote");
|
||||
|
||||
// Reported version
|
||||
testCurrentVersion_isCompiledIn();
|
||||
testNewestVersion();
|
||||
testCurrentVersion_neverOlderThanCompiled();
|
||||
|
||||
// Update-strategy choice
|
||||
testChooseMethod_checkoutWinsOverEverything();
|
||||
|
||||
Reference in new issue
Block a user