Răsfoiți Sursa

Updater: going back works from the released build and into 0.1.27 (round 190hl)

- A version without a prerelease equals every prerelease of the same
  numbers: the running build (CMake 0.1.28) is its release v0.1.28-alpha,
  so Help > Go back no longer reinstalls the running version and update
  checks stay up to date with the own tag.
- Versions may have a fourth number (0.1.28.1); 0.1.28 and older drop such
  tags.
- installing.txt writes version= last: 0.1.27 read everything after it as
  the version and said "updated to 0.0.0".
- Going back with the Windows installer skips the version left in
  updates.txt before the installer runs: older versions never recorded it
  after their restart and offered it again at once.
- Tests for 0.1.28 vs 0.1.28-alpha vs 0.1.27-alpha vs 0.1.29-alpha, the
  0.1.27 and 0.1.28 readers of installing.txt and the skip as 0.1.27 reads it.
Ka1-S 2 săptămâni în urmă
părinte
comite
d0d57c4fa1

+ 45 - 6
src/core/UpdateCheck.cpp

@@ -16,6 +16,8 @@ namespace lynx::update
 std::string Version::text() const
 {
     std::string s = std::to_string (major) + "." + std::to_string (minor) + "." + std::to_string (patch);
+    if (revision != 0)
+        s += "." + std::to_string (revision);
     for (std::size_t i = 0; i < pre.size(); ++i)
         s += (i == 0 ? "-" : ".") + pre[i];
     return s;
@@ -85,9 +87,9 @@ Version parseVersion (const std::string& input)
             return v;
     }
     const auto numbers = split (core, '.');
-    if (numbers.size() < 2 || numbers.size() > 3)
+    if (numbers.size() < 2 || numbers.size() > 4)
         return v;
-    int values[3] = { 0, 0, 0 };
+    int values[4] = { 0, 0, 0, 0 };
     for (std::size_t i = 0; i < numbers.size(); ++i)
     {
         if (! allDigits (numbers[i]) || numbers[i].size() > 6)
@@ -104,17 +106,18 @@ Version parseVersion (const std::string& input)
     v.major = values[0];
     v.minor = values[1];
     v.patch = values[2];
+    v.revision = values[3];
     v.valid = true;
     return v;
 }
 
 int compare (const Version& a, const Version& b)
 {
-    for (auto [x, y] : { std::pair { a.major, b.major }, { a.minor, b.minor }, { a.patch, b.patch } })
+    for (auto [x, y] : { std::pair { a.major, b.major }, { a.minor, b.minor }, { a.patch, b.patch }, { a.revision, b.revision } })
         if (x != y)
             return x < y ? -1 : 1;
-    if (a.pre.empty() || b.pre.empty())
-        return a.pre.empty() == b.pre.empty() ? 0 : (a.pre.empty() ? 1 : -1);
+    if (a.pre.empty() || b.pre.empty()) // (round 190hl: the build of a release equals its tag, see the header)
+        return 0;
     for (std::size_t i = 0; i < a.pre.size() && i < b.pre.size(); ++i)
     {
         const auto& x = a.pre[i];
@@ -977,15 +980,51 @@ Settings afterUpdate (Settings settings, const Version& from)
     return settings;
 }
 
-Settings afterRollback (Settings settings, const Version& left)
+Settings skipLeft (Settings settings, const Version& left)
 {
     const auto skipped = parseVersion (settings.skipped);
     if (left.valid && (! skipped.valid || compare (left, skipped) > 0))
         settings.skipped = left.text();
+    return settings;
+}
+
+Settings afterRollback (Settings settings, const Version& left)
+{
+    settings = skipLeft (std::move (settings), left);
     settings.previous.clear();
     return settings;
 }
 
+std::string formatInstalling (const InstallingNote& note)
+{
+    std::string out;
+    if (! note.from.empty())
+        out += "from=" + note.from + "\n";
+    out += "rollback=" + std::string (note.rollback ? "1" : "0") + "\n";
+    return out + "version=" + note.version + "\n"; // (last: see the header)
+}
+
+InstallingNote parseInstalling (const std::string& text)
+{
+    InstallingNote note;
+    std::istringstream in (text);
+    std::string line;
+    while (std::getline (in, line))
+    {
+        const auto eq = line.find ('=');
+        if (eq == std::string::npos)
+            continue;
+        const auto key = trim (line.substr (0, eq)), value = trim (line.substr (eq + 1));
+        if (key == "version" && note.version.empty())
+            note.version = value;
+        else if (key == "from")
+            note.from = value;
+        else if (key == "rollback")
+            note.rollback = value == "1";
+    }
+    return note;
+}
+
 bool cacheFresh (std::int64_t lastCheckMs, std::int64_t nowMs)
 {
     return lastCheckMs > 0 && nowMs >= lastCheckMs && nowMs - lastCheckMs < cacheLifetimeMs;

+ 31 - 5
src/core/UpdateCheck.h

@@ -21,17 +21,24 @@ namespace lynx::update
 struct Version
 {
     int major = 0, minor = 0, patch = 0;
+    int revision = 0;             // round 190hl: a fourth number ("0.1.28.1", a hotfix of 0.1.28); 0 when absent
     std::vector<std::string> pre; // "alpha", "1" for "-alpha.1"; empty for a release
     bool valid = false;
-    std::string text() const;     // "0.1.21-alpha"
+    std::string text() const;     // "0.1.21-alpha"; "0.1.28.1-alpha" (the fourth number only when it is not 0)
 };
 
-// "v0.1.21-alpha", "0.1.21", "0.1" (patch 0), "V1.2.3-rc.1+build.5" (build metadata ignored); invalid otherwise.
+// "v0.1.21-alpha", "0.1.21", "0.1" (patch 0), "0.1.28.1" (round 190hl), "V1.2.3-rc.1+build.5" (build metadata
+// ignored); invalid otherwise. (LYNX SHARE 0.1.28 and older read only two or three numbers: they drop a release whose
+// tag has four, so they never offer it.)
 Version parseVersion (const std::string& text);
 
-// <0, 0, >0 like strcmp, by semver 2.0 precedence: numbers first, then a prerelease sorts before the release of the
-// same numbers ("0.1.21-alpha" < "0.1.21"), prerelease identifiers compared one by one (numeric ones as numbers,
-// below alphanumeric ones; a shorter list sorts first when equal so far).
+// <0, 0, >0 like strcmp: the numbers first (major, minor, patch, revision), then the prerelease identifiers compared
+// one by one by semver 2.0 precedence (numeric ones as numbers, below alphanumeric ones; a shorter list sorts first
+// when equal so far: "1.0.0-alpha" < "1.0.0-alpha.1" < "1.0.0-beta").
+// Round 190hl: a version WITHOUT a prerelease equals every prerelease of the same numbers ("0.1.28" == "0.1.28-alpha").
+// LYNX SHARE builds carry CMake's bare "0.1.28" while their release tag is "v0.1.28-alpha": the running build IS that
+// release, so it is neither an update for it nor a version to go back to (under strict semver "0.1.28-alpha" <
+// "0.1.28" and Help › "Go back to..." in 0.1.28 reinstalled 0.1.28 itself). Two prereleases still order by semver.
 int compare (const Version& a, const Version& b);
 
 // --- releases ---------------------------------------------------------------------------------------------------
@@ -145,6 +152,8 @@ struct Settings
 };
 Settings parseSettings (const std::string& text);
 std::string formatSettings (const Settings&);
+// (Every version since 0.1.21 reads updates.txt line by line and ignores keys it does not know; "skipped" is read by
+// all of them, so a version left by going back is skipped in the older version too.)
 
 // Whether the bar shows `release`: a manual check always, an automatic one unless that version (or a newer one)
 // was skipped.
@@ -161,6 +170,23 @@ Settings afterUpdate (Settings settings, const Version& from);
 // The settings after going back from `left`: `left` is skipped, so the automatic check does not offer it again at once
 // (Help › Check for updates still does), and the recorded previous version is used up.
 Settings afterRollback (Settings settings, const Version& left);
+// Round 190hl: only the skip of afterRollback (an already skipped newer version stays). Written BEFORE the Windows
+// installer of the older version runs: 0.1.27 and older don't know about going back and never record the skip after
+// their restart, so without this their automatic check offered the version just left again at once.
+Settings skipLeft (Settings settings, const Version& left);
+
+// --- installing.txt (round 190hl) -------------------------------------------------------------------------------
+// The note the Windows installer path leaves in the update folder for the version it installs (read after the
+// restart): the version installed, the one it replaced, whether it went back. LYNX SHARE 0.1.27 and older read
+// everything after the first "version=" as the version, so "version=" is written LAST (round 190gh wrote it first
+// and 0.1.27 said "updated to 0.0.0"); 0.1.28 and newer read the lines in any order.
+struct InstallingNote
+{
+    std::string version, from;
+    bool rollback = false;
+};
+std::string formatInstalling (const InstallingNote&);
+InstallingNote parseInstalling (const std::string& text);
 
 // An automatic check reuses the cached release list for this long (GitHub allows 60 unauthenticated calls an hour
 // per address; LYNX started many times a day asks once every few hours).

+ 23 - 13
src/ui/Updater.cpp

@@ -585,11 +585,20 @@ void installAndRestart (const juce::File& setup)
         }
         updateFolder().getChildFile ("result.txt").deleteFile();
         // the version being installed, for the "was updated to" bar on the next start
-        // (round 190gh: the version it replaces, and whether it goes back, for the settings after the restart)
-        updateFolder().getChildFile ("installing.txt").replaceWithText ("version=" + juce::String (c.release.version.text()) + "\nfrom="
-                                                                          + juce::String (runningVersion().text()) + "\nrollback="
-                                                                          + (c.rollingBack ? "1" : "0") + "\n");
+        // (round 190gh: the version it replaces, and whether it goes back, for the settings after the restart;
+        // round 190hl: in a layout 0.1.27 and older read too, core/UpdateCheck.h formatInstalling)
+        update::InstallingNote note;
+        note.version = c.release.version.text();
+        note.from = runningVersion().text();
+        note.rollback = c.rollingBack;
+        updateFolder().getChildFile ("installing.txt").replaceWithText (fromUtf8 (update::formatInstalling (note)));
         updateFolder().getChildFile ("installing-notes.md").replaceWithText (fromUtf8 (c.release.body));
+        // round 190hl: going back skips the version left NOW, in the settings every older version reads; the older
+        // version that starts after the installer may not know about going back (0.1.27 and older) and would offer
+        // this one again at once. (The previous version is used up after the restart, by versions that know it.)
+        const auto settingsBefore = loadSettings();
+        if (c.rollingBack)
+            saveSettings (update::skipLeft (settingsBefore, runningVersion()));
         juce::StringArray args { helper.getFullPathName(), "--apply-update", setup.getFullPathName(), exe.getParentDirectory().getFullPathName(),
                                  juce::String ((juce::int64) currentPid()) };
         if (const auto project = c.host.currentProject ? c.host.currentProject() : juce::File(); project.existsAsFile())
@@ -598,9 +607,13 @@ void installAndRestart (const juce::File& setup)
         juce::ChildProcess child;
         if (! child.start (args, 0))
         {
+            if (c.rollingBack)
+                saveSettings (settingsBefore); // (nothing was installed: the skip goes again)
             fail (tr ("can't start {0}", { helper.getFullPathName() }));
             return;
         }
+        if (c.rollingBack)
+            log ("skipped " + fromUtf8 (runningVersion().text()) + " before the installer of " + versionText (c.release) + " runs");
         juce::JUCEApplication::quit();
     });
 }
@@ -917,15 +930,12 @@ void afterStart()
         }
         resultFile.deleteFile();
         const auto installing = folder.getChildFile ("installing.txt");
-        // round 190gh (B2): the version it replaced and whether it went back
-        juce::String from;
-        bool wentBack = false;
-        for (const auto& line : juce::StringArray::fromLines (installing.loadFileAsString()))
-        {
-            if (line.startsWith ("version=") && version.isEmpty()) version = line.fromFirstOccurrenceOf ("=", false, false).trim();
-            if (line.startsWith ("from=")) from = line.fromFirstOccurrenceOf ("=", false, false).trim();
-            if (line.startsWith ("rollback=")) wentBack = line.fromFirstOccurrenceOf ("=", false, false).trim() == "1";
-        }
+        // round 190gh (B2): the version it replaced and whether it went back (any line order: round 190hl)
+        const auto note = update::parseInstalling (utf8 (installing.loadFileAsString()));
+        if (version.isEmpty())
+            version = fromUtf8 (note.version);
+        const auto from = fromUtf8 (note.from);
+        const bool wentBack = note.rollback;
         log ("after start: update result " + result + (detail.isNotEmpty() ? " (" + detail + ")" : juce::String()));
         if (result == "ok")
         {

+ 175 - 0
tests/GoBack190hlTests.inc

@@ -0,0 +1,175 @@
+// Round 190hl (hotfix of 0.1.28): Help › "Go back to <version>..." (round 190gh) in the released 0.1.28
+// (/mnt/e/lynx-work/upd0128: shots s01–s15, update.log):
+// (a) the running "0.1.28" (CMake, no suffix) compared newer than its own tag "v0.1.28-alpha", so going back picked
+//     0.1.28 itself: a version without a prerelease now equals every prerelease of the same numbers;
+// (b) 0.1.27 read the new 3-line installing.txt as version "0.0.0" ("updated to 0.0.0"): "version=" is written last;
+// (c) the skip of the version left was saved only after the restart, by the version installed, and 0.1.27 does not
+//     know that step: the skip is written into updates.txt ("skipped", which every version reads) before the installer.
+#include "core/UpdateCheck.h"
+
+namespace hl190
+{
+// the release list of 0.1.29 time: the hotfix as a four-number tag too, and a draft
+const char* releasesJson = R"json([
+  {"tag_name":"v0.1.30-alpha","draft":true,"prerelease":true,"assets":[]},
+  {"tag_name":"v0.1.29-alpha","draft":false,"prerelease":true,"assets":[]},
+  {"tag_name":"v0.1.28.1-alpha","draft":false,"prerelease":true,"assets":[]},
+  {"tag_name":"v0.1.28-alpha","draft":false,"prerelease":true,"assets":[]},
+  {"tag_name":"v0.1.27-alpha","draft":false,"prerelease":true,"assets":[]}
+])json";
+
+// LYNX SHARE 0.1.27's reader of installing.txt (src/ui/Updater.cpp at v0.1.27-alpha, afterStart): everything after
+// the first "version=", trimmed
+std::string versionAsRead0127 (const std::string& installing)
+{
+    const auto at = installing.find ("version=");
+    if (at == std::string::npos)
+        return {};
+    auto rest = installing.substr (at + 8);
+    const auto a = rest.find_first_not_of (" \t\r\n"), b = rest.find_last_not_of (" \t\r\n");
+    return a == std::string::npos ? std::string() : rest.substr (a, b - a + 1);
+}
+
+// LYNX SHARE 0.1.28's reader (round 190gh): line by line, "version=" / "from=" / "rollback=" at the line start
+lynx::update::InstallingNote asRead0128 (const std::string& installing)
+{
+    lynx::update::InstallingNote note;
+    std::size_t start = 0;
+    while (start <= installing.size())
+    {
+        auto end = installing.find ('\n', start);
+        if (end == std::string::npos)
+            end = installing.size();
+        const auto line = installing.substr (start, end - start);
+        auto value = [&line] { return line.substr (line.find ('=') + 1); };
+        if (line.rfind ("version=", 0) == 0 && note.version.empty()) note.version = value();
+        if (line.rfind ("from=", 0) == 0) note.from = value();
+        if (line.rfind ("rollback=", 0) == 0) note.rollback = value() == "1";
+        start = end + 1;
+    }
+    return note;
+}
+} // namespace hl190
+
+TEST (goback190hl_a_the_running_build_equals_its_release_tag)
+{
+    using namespace lynx::update;
+    auto cmp = [] (const char* a, const char* b) { return compare (parseVersion (a), parseVersion (b)); };
+    // the build of 0.1.28 (CMake "0.1.28") is the release v0.1.28-alpha
+    CHECK (cmp ("0.1.28", "0.1.28-alpha") == 0 && cmp ("0.1.28-alpha", "0.1.28") == 0);
+    CHECK (cmp ("0.1.27-alpha", "0.1.28") < 0 && cmp ("0.1.28", "0.1.27-alpha") > 0);
+    CHECK (cmp ("0.1.29-alpha", "0.1.28") > 0 && cmp ("0.1.28", "0.1.29-alpha") < 0);
+    CHECK (cmp ("0.1.27-alpha", "0.1.29-alpha") < 0);
+    // two prereleases still order by semver
+    CHECK (cmp ("0.1.28-alpha", "0.1.28-beta") < 0 && cmp ("0.1.28-alpha.2", "0.1.28-alpha.10") < 0);
+    // four numbers (a hotfix "0.1.28.1"): above 0.1.28 in every form, below 0.1.29
+    const auto hot = parseVersion ("v0.1.28.1-alpha");
+    CHECK (hot.valid && hot.revision == 1 && hot.text() == "0.1.28.1-alpha" && parseVersion ("0.1.28.1").text() == "0.1.28.1");
+    CHECK (parseVersion ("0.1.28.0").text() == "0.1.28" && cmp ("0.1.28.0", "0.1.28") == 0);
+    CHECK (cmp ("0.1.28.1", "0.1.28-alpha") > 0 && cmp ("0.1.28.1", "0.1.28") > 0 && cmp ("0.1.28.1", "0.1.28.1-alpha") == 0);
+    CHECK (cmp ("0.1.28.1-alpha", "0.1.29-alpha") < 0 && cmp ("0.1.28.2", "0.1.28.10") < 0);
+
+    const auto releases = parseReleases (hl190::releasesJson);
+    CHECK (releases.size() == 5);
+    if (releases.size() != 5)
+        return;
+    auto at = [&] (int i) { return i >= 0 ? releases[(std::size_t) i].version.text() : std::string ("none"); };
+    auto atIn = [] (const std::vector<Release>& list, int i) { return i >= 0 ? list[(std::size_t) i].version.text() : std::string ("none"); };
+    // update checks: the running build is up to date with its own tag, the next one is offered
+    CHECK (at (newestIndex (releases, parseVersion ("0.1.29"))) == "none");
+    CHECK (at (newestIndex (releases, parseVersion ("0.1.28.1"))) == "0.1.29-alpha");
+    CHECK (at (newestIndex (releases, parseVersion ("0.1.28"))) == "0.1.29-alpha");
+    CHECK (at (newestIndex (releases, parseVersion ("0.1.27"))) == "0.1.29-alpha");
+    const std::vector<Release> upTo0128 (releases.begin() + 2, releases.end()); // 0.1.28.1, 0.1.28, 0.1.27
+    CHECK (atIn (upTo0128, newestIndex (upTo0128, parseVersion ("0.1.28"))) == "0.1.28.1-alpha");
+    CHECK (newestIndex (upTo0128, parseVersion ("0.1.28.1")) < 0);
+    const std::vector<Release> upTo0128only (releases.begin() + 3, releases.end()); // 0.1.28, 0.1.27
+    CHECK (newestIndex (upTo0128only, parseVersion ("0.1.28")) < 0); // "You're up to date" (as 0.1.28 said)
+
+    // going back: never the running release itself (0.1.28 picked 0.1.28-alpha), never a newer one or the draft
+    CHECK (atIn (upTo0128only, rollbackIndex (upTo0128only, parseVersion ("0.1.28"), "")) == "0.1.27-alpha");
+    CHECK (atIn (upTo0128only, rollbackIndex (upTo0128only, parseVersion ("0.1.28"), "0.1.27")) == "0.1.27-alpha");
+    // (s08–s10: after 0.1.28 reinstalled itself the recorded previous was "0.1.28-alpha", its own tag)
+    CHECK (atIn (upTo0128only, rollbackIndex (upTo0128only, parseVersion ("0.1.28"), "0.1.28-alpha")) == "0.1.27-alpha");
+    CHECK (at (rollbackIndex (releases, parseVersion ("0.1.29"), "")) == "0.1.28.1-alpha");
+    CHECK (at (rollbackIndex (releases, parseVersion ("0.1.29"), "0.1.28")) == "0.1.28-alpha"); // recorded bare by 0.1.28
+    CHECK (at (rollbackIndex (releases, parseVersion ("0.1.28.1"), "0.1.28")) == "0.1.28-alpha");
+    CHECK (at (rollbackIndex (releases, parseVersion ("0.1.28.1"), "")) == "0.1.28-alpha");
+    CHECK (at (rollbackIndex (releases, parseVersion ("0.1.28.1"), "0.1.27")) == "0.1.27-alpha");
+    CHECK (at (rollbackIndex (releases, parseVersion ("0.1.28.1"), "0.1.29-alpha")) == "0.1.28-alpha"); // (newer: ignored)
+    CHECK (rollbackIndex (releases, parseVersion ("0.1.27"), "") < 0);
+
+    // the skip: "0.1.28" (left by going back) hides its tag on the automatic check, not the next release
+    Settings s;
+    s = afterRollback (s, parseVersion ("0.1.28"));
+    Release r;
+    r.version = parseVersion ("v0.1.28-alpha");
+    CHECK (! shouldShow (r, s, false) && shouldShow (r, s, true));
+    r.version = parseVersion ("v0.1.28.1-alpha");
+    CHECK (shouldShow (r, s, false));
+    // a skipped tag and the bare version of the same release are the same: no change
+    Settings tagged;
+    tagged.skipped = "0.1.28-alpha";
+    CHECK (skipLeft (tagged, parseVersion ("0.1.28")).skipped == "0.1.28-alpha");
+}
+
+TEST (goback190hl_b_installing_txt_reads_right_in_0127_0128_and_now)
+{
+    using namespace lynx::update;
+    InstallingNote note;
+    note.version = "0.1.27-alpha";
+    note.from = "0.1.29";
+    note.rollback = true;
+    const auto text = formatInstalling (note);
+    CHECK (text.size() >= 21 && text.compare (text.size() - 21, 21, "version=0.1.27-alpha\n") == 0); // (the last line)
+    // 0.1.27: the version, not "0.0.0"
+    CHECK (hl190::versionAsRead0127 (text) == "0.1.27-alpha" && parseVersion (hl190::versionAsRead0127 (text)).valid);
+    // round 190gh's layout (version first) is what 0.1.27 misread
+    const std::string old190gh = "version=0.1.27-alpha\nfrom=0.1.28\nrollback=1\n";
+    CHECK (! parseVersion (hl190::versionAsRead0127 (old190gh)).valid);
+    // 0.1.28 and this version read all three, in either layout
+    const auto by0128 = hl190::asRead0128 (text);
+    CHECK (by0128.version == "0.1.27-alpha" && by0128.from == "0.1.29" && by0128.rollback);
+    const auto now = parseInstalling (text);
+    CHECK (now.version == "0.1.27-alpha" && now.from == "0.1.29" && now.rollback);
+    const auto legacy = parseInstalling (old190gh);
+    CHECK (legacy.version == "0.1.27-alpha" && legacy.from == "0.1.28" && legacy.rollback);
+    const auto plain = parseInstalling ("version=0.1.28-alpha\n"); // 0.1.27's own note
+    CHECK (plain.version == "0.1.28-alpha" && plain.from.empty() && ! plain.rollback);
+    CHECK (parseInstalling ("version= 0.1.28-alpha \r\nfrom=0.1.27\r\nrollback=0\r\n").from == "0.1.27");
+    // an update (not going back) from an unknown version: still readable by 0.1.27
+    InstallingNote up;
+    up.version = "0.1.29-alpha";
+    const auto upText = formatInstalling (up);
+    CHECK (hl190::versionAsRead0127 (upText) == "0.1.29-alpha" && ! parseInstalling (upText).rollback && parseInstalling (upText).from.empty());
+}
+
+TEST (goback190hl_c_the_skip_is_in_the_settings_older_versions_read)
+{
+    using namespace lynx::update;
+    Settings s;
+    s.previous = "0.1.28";
+    s.lastCheckMs = 1763200000000LL;
+    // before the installer of the older version runs: only the skip, the previous stays until the restart
+    const auto before = skipLeft (s, parseVersion ("0.1.29"));
+    CHECK (before.skipped == "0.1.29" && before.previous == "0.1.28" && before.lastCheckMs == s.lastCheckMs);
+    const auto text = formatSettings (before);
+    CHECK (text.find ("\nskipped=0.1.29\n") != std::string::npos); // the key and value 0.1.21+ read (three numbers)
+    // what 0.1.27 does with it: parse, then hide v0.1.29-alpha on the automatic check, offer it on a manual one
+    const auto read = parseSettings (text);
+    Release next;
+    next.version = parseVersion ("v0.1.29-alpha");
+    CHECK (read.skipped == "0.1.29" && ! shouldShow (next, read, false) && shouldShow (next, read, true));
+    next.version = parseVersion ("v0.1.30-alpha");
+    CHECK (shouldShow (next, read, false)); // the release after it is offered
+    // after the restart a version that knows going back uses the previous up; the skip stays the same
+    const auto after = afterRollback (before, parseVersion ("0.1.29"));
+    CHECK (after.skipped == "0.1.29" && after.previous.empty());
+    // an already skipped newer version stays; a version that is no version changes nothing
+    Settings later;
+    later.skipped = "0.1.31-alpha";
+    CHECK (skipLeft (later, parseVersion ("0.1.29")).skipped == "0.1.31-alpha");
+    CHECK (skipLeft (s, Version {}).skipped.empty());
+    // a hotfix with four numbers is skipped as written (0.1.28 and older can't read it, nor see its release: consistent)
+    CHECK (skipLeft (Settings {}, parseVersion ("0.1.28.1")).skipped == "0.1.28.1" && parseSettings ("skipped=0.1.28.1\n").skipped == "0.1.28.1");
+}

+ 4 - 3
tests/Update166bTests.inc

@@ -36,19 +36,20 @@ TEST (update166b_versions_compare_like_semver)
     CHECK (v.text() == "0.1.21-alpha");
     CHECK (parseVersion ("0.1").valid && parseVersion ("0.1").patch == 0);
     CHECK (parseVersion (" V1.2.3-rc.1+build.5 ").valid && parseVersion ("V1.2.3-rc.1+build.5").pre.size() == 2);
-    for (const char* bad : { "", "nightly", "v1", "1.2.3.4", "1.x.3", "1.2.3-", "1.2.3-a..b", "1.2.3-ä" })
+    for (const char* bad : { "", "nightly", "v1", "1.2.3.4.5", "1.x.3", "1.2.3-", "1.2.3-a..b", "1.2.3-ä" }) // (four numbers: round 190hl)
         CHECK (! parseVersion (bad).valid);
 
     auto lt = [] (const char* a, const char* b) { return compare (parseVersion (a), parseVersion (b)) < 0 && compare (parseVersion (b), parseVersion (a)) > 0; };
     CHECK (lt ("0.1.20", "0.1.21-alpha"));   // a newer prerelease is an update for the running 0.1.20
-    CHECK (lt ("0.1.20-alpha", "0.1.20"));   // the release a build's CMake version names is not older than its tag
+    // the release a build's CMake version names IS its tag (round 190hl; strict semver had "0.1.20-alpha" < "0.1.20")
+    CHECK (compare (parseVersion ("0.1.20-alpha"), parseVersion ("0.1.20")) == 0);
     CHECK (lt ("0.1.9", "0.1.10"));          // numbers, not text
     CHECK (lt ("0.9.99", "1.0.0"));
     CHECK (lt ("1.0.0-alpha", "1.0.0-alpha.1"));
     CHECK (lt ("1.0.0-alpha.1", "1.0.0-alpha.beta"));
     CHECK (lt ("1.0.0-alpha.beta", "1.0.0-beta"));
     CHECK (lt ("1.0.0-beta.2", "1.0.0-beta.11"));
-    CHECK (lt ("1.0.0-rc.1", "1.0.0"));
+    CHECK (compare (parseVersion ("1.0.0-rc.1"), parseVersion ("1.0.0")) == 0); // (round 190hl: as above)
     CHECK (compare (parseVersion ("v0.1.20"), parseVersion ("0.1.20+build7")) == 0);
 }
 

+ 1 - 0
tests/tests.cpp

@@ -17791,6 +17791,7 @@ TEST (fl_low_lifter_matches_fl_engine)
 #include "Stability190ggTests.inc"
 #include "StemPass190gjTests.inc"
 #include "Small190ghTests.inc"
+#include "GoBack190hlTests.inc"
 #include "Link190glTests.inc"
 #include "SynthLanes190gpTests.inc"
 #include "SchedIndex190gpTests.inc"