Compare commits
5
Commits
fb5c11e153
...
V1.4.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
576daf2fae | ||
|
|
6c4a715d73 | ||
|
|
31b1ccb8d6 | ||
|
|
5216480d81 | ||
|
|
605cb5bc26 |
No files matched your search
@@ -1,145 +0,0 @@
|
|||||||
# Gitea Actions — Release
|
|
||||||
#
|
|
||||||
# Triggered whenever the `version` file at the repository root is bumped.
|
|
||||||
# Creates a Gitea release tagged with the new version — but ONLY if the
|
|
||||||
# version in `version` differs from the latest released tag.
|
|
||||||
#
|
|
||||||
# The release also uploads a prebuilt binary archive
|
|
||||||
# (PacManager-<version>-x86_64.tar.gz with the binary, version file and
|
|
||||||
# plugins) so installed apps without a build toolchain can self-update
|
|
||||||
# WITHOUT recompiling. UpdateManager uses it as a fallback when git/cmake/a
|
|
||||||
# compiler are unavailable; otherwise it clones the repo and rebuilds. The
|
|
||||||
# upload is best-effort, so a failed build never blocks the release itself.
|
|
||||||
#
|
|
||||||
# No secret is required: `secrets.GITEA_TOKEN` is the built-in automatic
|
|
||||||
# token provided by Gitea on every run. The `permissions: contents: write`
|
|
||||||
# block below asks for write access to contents and releases, so the release
|
|
||||||
# can be created without configuring any secret in the repository settings.
|
|
||||||
# Tests are deliberately not run here; they live in the separate `tests`
|
|
||||||
# workflow and do not gate releases.
|
|
||||||
|
|
||||||
name: release
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
paths:
|
|
||||||
- version
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: write
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
# Reads the new version and publishes a release + git tag when the version
|
|
||||||
# genuinely changed. Runs without any test step.
|
|
||||||
release:
|
|
||||||
runs-on: linux
|
|
||||||
steps:
|
|
||||||
- name: Checkout with full history and tags
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
fetch-tags: true
|
|
||||||
|
|
||||||
- name: Read version
|
|
||||||
id: version
|
|
||||||
run: |
|
|
||||||
VERSION=$(tr -d ' \n' < version)
|
|
||||||
echo "value=${VERSION}" >> "$GITHUB_OUTPUT"
|
|
||||||
|
|
||||||
- name: Check whether the version already has a release
|
|
||||||
id: check
|
|
||||||
run: |
|
|
||||||
VERSION="${{ steps.version.outputs.value }}"
|
|
||||||
TAG="v${VERSION}"
|
|
||||||
if git tag --list | grep -qx "${TAG}"; then
|
|
||||||
echo "Tag ${TAG} already exists — nothing to release"
|
|
||||||
echo "new=false" >> "$GITHUB_OUTPUT"
|
|
||||||
else
|
|
||||||
echo "new=true" >> "$GITHUB_OUTPUT"
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Create release
|
|
||||||
if: steps.check.outputs.new == 'true'
|
|
||||||
id: create
|
|
||||||
env:
|
|
||||||
# Built-in automatic token, no secret to configure. The
|
|
||||||
# `permissions` block at the top grants it write access to
|
|
||||||
# contents/releases for this run.
|
|
||||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
|
||||||
run: |
|
|
||||||
VERSION="${{ steps.version.outputs.value }}"
|
|
||||||
TAG="v${VERSION}"
|
|
||||||
BODY=$(cat <<'EOF'
|
|
||||||
Release automatically generated by the `release` workflow when the
|
|
||||||
`version` file was bumped.
|
|
||||||
EOF
|
|
||||||
)
|
|
||||||
RESP=$(curl -sS -X POST "$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/releases" \
|
|
||||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
-d @- <<JSON
|
|
||||||
{
|
|
||||||
"tag_name": "${TAG}",
|
|
||||||
"target_commitish": "main",
|
|
||||||
"name": "v${VERSION}",
|
|
||||||
"body": "${BODY}"
|
|
||||||
}
|
|
||||||
JSON
|
|
||||||
)
|
|
||||||
echo "${RESP}"
|
|
||||||
ID=$(echo "${RESP}" | grep -o '"id":[0-9]*' | head -n 1 | cut -d: -f2)
|
|
||||||
echo "release_id=${ID}" >> "$GITHUB_OUTPUT"
|
|
||||||
|
|
||||||
- name: Build prebuilt binary archive
|
|
||||||
if: steps.check.outputs.new == 'true'
|
|
||||||
id: build
|
|
||||||
run: |
|
|
||||||
VERSION="${{ steps.version.outputs.value }}"
|
|
||||||
if command -v pacman >/dev/null 2>&1; then
|
|
||||||
sudo pacman -S --noconfirm --needed git cmake gcc make qt6-base
|
|
||||||
elif command -v apt-get >/dev/null 2>&1; then
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y git cmake g++ make qt6-base-dev
|
|
||||||
elif command -v dnf >/dev/null 2>&1; then
|
|
||||||
sudo dnf install -y git cmake gcc-c++ make qt6-qtbase-devel
|
|
||||||
else
|
|
||||||
echo "Unsupported package manager — skipping prebuilt archive"
|
|
||||||
echo "ok=false" >> "$GITHUB_OUTPUT"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
cmake -B build -DCMAKE_BUILD_TYPE=Release
|
|
||||||
cmake --build build -j$(nproc)
|
|
||||||
STAGE="pacmanager-dist"
|
|
||||||
rm -rf "${STAGE}" && mkdir -p "${STAGE}/bin" "${STAGE}/plugins"
|
|
||||||
cp build/PacManager "${STAGE}/bin/"
|
|
||||||
cp version "${STAGE}/bin/"
|
|
||||||
if ls build/plugins/*.so >/dev/null 2>&1; then
|
|
||||||
cp build/plugins/*.so "${STAGE}/plugins/"
|
|
||||||
fi
|
|
||||||
# Layout consumed by UpdateManager's prebuilt path: bin/PacManager,
|
|
||||||
# bin/version and plugins/ (unpacked next to the running executable,
|
|
||||||
# wherever it lives).
|
|
||||||
ARCHIVE="PacManager-${VERSION}-x86_64.tar.gz"
|
|
||||||
tar czf "${ARCHIVE}" -C "${STAGE}" bin plugins
|
|
||||||
echo "archive=${ARCHIVE}" >> "$GITHUB_OUTPUT"
|
|
||||||
echo "ok=true" >> "$GITHUB_OUTPUT"
|
|
||||||
|
|
||||||
- name: Upload prebuilt archive to release
|
|
||||||
if: steps.check.outputs.new == 'true' && steps.build.outputs.ok == 'true'
|
|
||||||
env:
|
|
||||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
|
||||||
run: |
|
|
||||||
ARCHIVE="${{ steps.build.outputs.archive }}"
|
|
||||||
RELEASE_ID="${{ steps.create.outputs.release_id }}"
|
|
||||||
if [ -z "${RELEASE_ID}" ]; then
|
|
||||||
echo "No release id — skipping upload"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
curl -sS -X POST \
|
|
||||||
"$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/releases/${RELEASE_ID}/assets?name=$(basename ${ARCHIVE})" \
|
|
||||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
|
||||||
-H "Content-Type: application/gzip" \
|
|
||||||
--data-binary "@${ARCHIVE}" || echo "Asset upload failed — release still valid without prebuilt binary"
|
|
||||||
@@ -1,84 +0,0 @@
|
|||||||
# Gitea Actions — Tests
|
|
||||||
#
|
|
||||||
# Dedicated test workflow: builds the application and runs the full test suite
|
|
||||||
# (ctest) on every push and pull request. Kept separate from the release
|
|
||||||
# workflow so a failing test never blocks a release. Also guards the
|
|
||||||
# `version` file: it must match the latest git tag (if any), otherwise the
|
|
||||||
# self-update check would report a phantom update.
|
|
||||||
|
|
||||||
name: tests
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
pull_request:
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
version-guard:
|
|
||||||
runs-on: linux
|
|
||||||
steps:
|
|
||||||
- name: Checkout with full history and tags
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
fetch-tags: true
|
|
||||||
|
|
||||||
- name: Check version file matches latest tag (when tags exist)
|
|
||||||
run: |
|
|
||||||
VERSION=$(tr -d ' \n' < version)
|
|
||||||
echo "version file: ${VERSION}"
|
|
||||||
LATEST=$(git describe --tags --abbrev=0 2>/dev/null || true)
|
|
||||||
if [ -z "${LATEST}" ]; then
|
|
||||||
echo "No tags yet — skipping version guard"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
# Tags are like v1.3.1 / V1.3.1 ; the file holds 1.3.1
|
|
||||||
NORMALIZED=$(echo "${LATEST}" | sed -E 's/^[vV]//')
|
|
||||||
echo "latest tag: ${LATEST} (normalized: ${NORMALIZED})"
|
|
||||||
if [ "${VERSION}" != "${NORMALIZED}" ]; then
|
|
||||||
echo "::error::version file (${VERSION}) does not match latest tag ${LATEST} (expected ${NORMALIZED}). Bump the version file before tagging."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
echo "version file matches latest tag"
|
|
||||||
|
|
||||||
build-test:
|
|
||||||
runs-on: linux
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
run: |
|
|
||||||
# Host-mode runners execute jobs directly on the runner machine, so
|
|
||||||
# detect its package manager instead of hardcoding apt (which only
|
|
||||||
# exists on Debian/Ubuntu hosts).
|
|
||||||
if command -v pacman >/dev/null 2>&1; then
|
|
||||||
sudo pacman -S --noconfirm --needed \
|
|
||||||
git cmake gcc make qt6-base
|
|
||||||
elif command -v apt-get >/dev/null 2>&1; then
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y \
|
|
||||||
git cmake g++ make qt6-base-dev
|
|
||||||
elif command -v dnf >/dev/null 2>&1; then
|
|
||||||
sudo dnf install -y \
|
|
||||||
git cmake gcc-c++ make qt6-qtbase-devel
|
|
||||||
else
|
|
||||||
echo "Unsupported package manager: install git, cmake, a C++ compiler, make and Qt6 manually" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Configure
|
|
||||||
run: |
|
|
||||||
cmake -B build \
|
|
||||||
-DFWS_BUILD_EXAMPLE_PLUGIN=ON \
|
|
||||||
-DFWS_BUILD_EXAMPLE_ADDON=ON \
|
|
||||||
-DCMAKE_BUILD_TYPE=Release
|
|
||||||
|
|
||||||
- name: Build
|
|
||||||
run: |
|
|
||||||
cmake --build build -j$(nproc)
|
|
||||||
|
|
||||||
- name: Run all tests
|
|
||||||
run: |
|
|
||||||
cd build
|
|
||||||
ctest --output-on-failure
|
|
||||||
+8
-3
@@ -8,12 +8,17 @@ set(CMAKE_AUTORCC ON)
|
|||||||
set(CMAKE_AUTOUIC ON)
|
set(CMAKE_AUTOUIC ON)
|
||||||
|
|
||||||
# The repo-root `version` file is the single source of truth for release
|
# The repo-root `version` file is the single source of truth for release
|
||||||
# versioning. It is compiled into the binaries as well as installed next to
|
# versioning. It is read at configure time and compiled into the binaries, so a
|
||||||
# them, so a running app always reports the release it was built from instead
|
# running app knows which release it was built from.
|
||||||
# of trusting a `version` file that an update may have left stale.
|
|
||||||
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/version PACMANAGER_VERSION)
|
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/version PACMANAGER_VERSION)
|
||||||
string(STRIP "${PACMANAGER_VERSION}" PACMANAGER_VERSION)
|
string(STRIP "${PACMANAGER_VERSION}" PACMANAGER_VERSION)
|
||||||
|
|
||||||
|
# Reading it above only happens during configuration, and bumping the file is
|
||||||
|
# not otherwise a reason to configure again: without this, `cmake --build` after
|
||||||
|
# a version bump kept building the previous version into the binary.
|
||||||
|
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/version)
|
||||||
|
|
||||||
# Find Qt6
|
# Find Qt6
|
||||||
find_package(Qt6 REQUIRED COMPONENTS Widgets Network)
|
find_package(Qt6 REQUIRED COMPONENTS Widgets Network)
|
||||||
|
|
||||||
|
|||||||
+11
-4
@@ -131,17 +131,24 @@ The method is picked automatically (no configuration):
|
|||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| **Checkout** | a source checkout surrounds the binary (dev) | `git pull`, rebuild, install into the binary's directory |
|
| **Checkout** | a source checkout surrounds the binary (dev) | `git pull`, rebuild, install into the binary's directory |
|
||||||
| **Clone** | installed app with no checkout, and `git` + `cmake` + a compiler | the repo is cloned/updated in `~/.local/share/PacManager/src`, rebuilt and installed in place |
|
| **Clone** | installed app with no checkout, and `git` + `cmake` + a compiler | the repo is cloned/updated in `~/.local/share/PacManager/src`, rebuilt and installed in place |
|
||||||
| **Prebuilt** | no build toolchain available | the release's prebuilt archive is downloaded and unpacked |
|
| **Prebuilt** | no build toolchain available, and the release has a prebuilt archive attached | that archive is downloaded and unpacked |
|
||||||
| **Tarball** | no `git`, but `cmake` + a compiler | the release sources are built and installed |
|
| **Tarball** | no `git`, but `cmake` + a compiler | the release sources are built and installed |
|
||||||
|
|
||||||
Everything builds in a temporary directory: only the final replacement of the
|
Everything builds in a temporary directory: only the final replacement of the
|
||||||
binary (and plugins) needs `sudo`, and only when the target directory is owned
|
binary (and plugins) needs `sudo`, and only when the target directory is owned
|
||||||
by root. PacManager then restarts automatically on the new version.
|
by root. PacManager then restarts automatically on the new version.
|
||||||
|
|
||||||
|
Nothing produces a prebuilt archive automatically: without one attached to the
|
||||||
|
release, **Clone** or **Tarball** applies instead (so `git`, `cmake` and a
|
||||||
|
compiler are needed on the machine).
|
||||||
|
|
||||||
All four methods install to the same place — the running binary's directory —
|
All four methods install to the same place — the running binary's directory —
|
||||||
and rewrite the `version` file there. On top of that, the app reports the
|
and rewrite the `version` file there. To know which release is really installed,
|
||||||
version **compiled into the binary** (from the repo's `version` file) first, so
|
PacManager keeps the **newest** of two sources: the version compiled into the
|
||||||
the same update is never offered again once it has been applied.
|
binary (read from the repo's `version` file at configure time) and the one in the
|
||||||
|
`version` file next to the executable. An applied update is therefore never
|
||||||
|
offered again, even when one of the two lags behind (a binary rebuilt without
|
||||||
|
configuring again, an install older than the binary).
|
||||||
|
|
||||||
## Graphical interface
|
## Graphical interface
|
||||||
|
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ La méthode est choisie automatiquement (aucune configuration) :
|
|||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| **Checkout** | un dépôt source entoure le binaire (dev) | `git pull`, recompilation puis installation dans le dossier du binaire |
|
| **Checkout** | un dépôt source entoure le binaire (dev) | `git pull`, recompilation puis installation dans le dossier du binaire |
|
||||||
| **Clone** | app installée sans dépôt, avec `git` + `cmake` + compilateur | le dépôt est cloné puis mis à jour dans `~/.local/share/PacManager/src`, recompilé et installé en place |
|
| **Clone** | app installée sans dépôt, avec `git` + `cmake` + compilateur | le dépôt est cloné puis mis à jour dans `~/.local/share/PacManager/src`, recompilé et installé en place |
|
||||||
| **Prebuilt** | pas d'outillage de compilation | l'archive précompilée de la release est téléchargée et décompressée |
|
| **Prebuilt** | pas d'outillage de compilation et une archive précompilée est attachée à la release | l'archive est téléchargée et décompressée |
|
||||||
| **Tarball** | `git` absent mais `cmake` + compilateur présents | les sources de la release sont compilées puis installées |
|
| **Tarball** | `git` absent mais `cmake` + compilateur présents | les sources de la release sont compilées puis installées |
|
||||||
|
|
||||||
Tout se compile dans un dossier temporaire : seul le remplacement final du
|
Tout se compile dans un dossier temporaire : seul le remplacement final du
|
||||||
@@ -139,10 +139,18 @@ binaire (et des plugins) demande `sudo`, et uniquement si le dossier cible
|
|||||||
appartient à root. PacManager redémarre ensuite automatiquement sur la nouvelle
|
appartient à root. PacManager redémarre ensuite automatiquement sur la nouvelle
|
||||||
version.
|
version.
|
||||||
|
|
||||||
|
Rien ne produit d'archive précompilée automatiquement : sans archive attachée à
|
||||||
|
la release, ce sont **Clone** ou **Tarball** qui s'appliquent (donc `git`, `cmake`
|
||||||
|
et un compilateur sur la machine).
|
||||||
|
|
||||||
Les quatre méthodes installent au même endroit — le dossier du binaire en cours
|
Les quatre méthodes installent au même endroit — le dossier du binaire en cours
|
||||||
— et y réécrivent le fichier `version`. L'application lit de plus en priorité la
|
— et y réécrivent le fichier `version`. Pour savoir quelle version est réellement
|
||||||
version **compilée dans le binaire** (à partir du fichier `version` du dépôt) :
|
installée, PacManager retient la **plus récente** des deux sources : la version
|
||||||
une mise à jour déjà appliquée n'est donc jamais reproposée au lancement.
|
compilée dans le binaire (lue dans le fichier `version` du dépôt au moment de la
|
||||||
|
configuration) et celle du fichier `version` posé à côté de l'exécutable. Une mise
|
||||||
|
à jour déjà appliquée n'est donc jamais reproposée, même quand l'une des deux
|
||||||
|
retarde (binaire recompilé sans reconfiguration, installation plus ancienne que
|
||||||
|
le binaire).
|
||||||
|
|
||||||
## Interface graphique
|
## Interface graphique
|
||||||
|
|
||||||
|
|||||||
@@ -26,11 +26,17 @@ class UpdateManager : public QObject {
|
|||||||
public:
|
public:
|
||||||
explicit UpdateManager(QObject* parent = nullptr);
|
explicit UpdateManager(QObject* parent = nullptr);
|
||||||
|
|
||||||
// Current app version, compiled in from the repo-root `version` file (see
|
// Current app version: the newest of the version compiled in from the
|
||||||
// CMakeLists.txt), falling back to the `version` file installed next to the
|
// repo-root `version` file (see CMakeLists.txt) and the one recorded in the
|
||||||
// executable when the build bypassed CMake.
|
// `version` file installed next to the executable.
|
||||||
static QString currentVersion();
|
static QString currentVersion();
|
||||||
|
|
||||||
|
// Highest of two dotted versions. Used to reconcile the two places that know
|
||||||
|
// the version: either can lag behind (a build made without configuring
|
||||||
|
// again, or a marker left by an older install), and reporting the lower one
|
||||||
|
// would offer an already installed release for ever.
|
||||||
|
static QString newestVersion(const QString& a, const QString& b);
|
||||||
|
|
||||||
// Path of the state file storing the last check date and the latest
|
// Path of the state file storing the last check date and the latest
|
||||||
// known remote version (e.g. ~/.local/share/PacManager/update-state.json).
|
// known remote version (e.g. ~/.local/share/PacManager/update-state.json).
|
||||||
static QString stateFilePath();
|
static QString stateFilePath();
|
||||||
|
|||||||
+18
-11
@@ -51,21 +51,28 @@ UpdateManager::UpdateManager(QObject* parent) : QObject(parent) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString UpdateManager::newestVersion(const QString& a, const QString& b) {
|
||||||
|
// isNewerVersion() also normalises a leading "v", so "v1.4.1" wins over
|
||||||
|
// "1.3.1" and an empty side always loses.
|
||||||
|
return isNewerVersion(b, a) ? b : a;
|
||||||
|
}
|
||||||
|
|
||||||
QString UpdateManager::currentVersion() {
|
QString UpdateManager::currentVersion() {
|
||||||
// The compiled-in version wins: it describes the code that is actually
|
// Two places know the version, and either can lag behind: the version
|
||||||
// running, so a `version` file left behind (or never refreshed) by an
|
// compiled into the binary (a build made without configuring again keeps the
|
||||||
// update cannot make the app re-offer a release it already installed.
|
// previous one) and the marker installed next to the executable (an install
|
||||||
QString version = QStringLiteral(FWSPACMANAGE_VERSION).trimmed();
|
// made before an update left the old one behind). Reporting the lower of the
|
||||||
|
// two would offer an already installed release again at every launch, so the
|
||||||
|
// newest one known wins.
|
||||||
|
const QString compiled = QStringLiteral(FWSPACMANAGE_VERSION).trimmed();
|
||||||
|
|
||||||
// Fallback for builds that bypass CMake: the `version` file installed next
|
QString installed;
|
||||||
// to the executable.
|
QFile file(QCoreApplication::applicationDirPath() + "/version");
|
||||||
if (version.isEmpty()) {
|
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||||
QFile f(QCoreApplication::applicationDirPath() + "/version");
|
installed = QString::fromUtf8(file.readAll()).trimmed();
|
||||||
if (f.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
|
||||||
version = QString::fromUtf8(f.readAll()).trimmed();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QString version = newestVersion(compiled, installed);
|
||||||
return version.isEmpty() ? QStringLiteral("1.0.0") : version;
|
return version.isEmpty() ? QStringLiteral("1.0.0") : version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -119,12 +119,30 @@ static void testChooseMethod_noneWhenNothingAvailable() {
|
|||||||
"method_none_without_anything");
|
"method_none_without_anything");
|
||||||
}
|
}
|
||||||
|
|
||||||
// The version the app reports is the one compiled into it, so a stale `version`
|
// Reconciliation of the two sources of truth: whichever is ahead wins, an empty
|
||||||
// file next to the executable can never make it re-offer an installed update.
|
// side never does. This is what stops a release from being offered again when the
|
||||||
static void testCurrentVersion_isCompiledIn() {
|
// binary and the installed marker disagree.
|
||||||
check(UpdateManager::currentVersion() == QStringLiteral(FWSPACMANAGE_VERSION),
|
static void testNewestVersion() {
|
||||||
"current_version_compiled_in");
|
check(UpdateManager::newestVersion("1.3.1", "1.4.1") == "1.4.1",
|
||||||
check(!UpdateManager::currentVersion().isEmpty(), "current_version_not_empty");
|
"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,
|
// 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");
|
check(UpdateManager::isNewerVersion("", "1.3.1") == false, "empty_remote");
|
||||||
|
|
||||||
// Reported version
|
// Reported version
|
||||||
testCurrentVersion_isCompiledIn();
|
testNewestVersion();
|
||||||
|
testCurrentVersion_neverOlderThanCompiled();
|
||||||
|
|
||||||
// Update-strategy choice
|
// Update-strategy choice
|
||||||
testChooseMethod_checkoutWinsOverEverything();
|
testChooseMethod_checkoutWinsOverEverything();
|
||||||
|
|||||||
Reference in new issue
Block a user