Merge branch 'release-1.6.0' into main
The release moved every source into its own layer (core/, app/, pages/,
providers/, preferences/, logging/, archive/, update/, translations/) and
replaced the plugin shop with .fwspacm packages. main added the headless update
check run at login. Both sides are kept, the feature moved onto the new layout:
- core/startup-check.{h,cpp} and its test, wired into the CMake targets the
release renamed (core/startup-check.cpp, startup-check-test);
- app/main.cpp carries the --check-updates branch, ahead of the command line so
the login unit never opens a window;
- the settings menu keeps the "check at startup" toggle, now through tr(), and
translations/en.json gains the new strings;
- doc/mise-a-jour.md keeps the release's version and gains the startup-check
section; the documented test count follows the new target.
This commit is contained in:
104 files changed
+9222
-2036
No files matched your search
@@ -0,0 +1,305 @@
|
||||
#include "app-settings.h"
|
||||
#include "log-manager.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QDateTime>
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QObject>
|
||||
#include <QSettings>
|
||||
#include <QString>
|
||||
#include <QTemporaryDir>
|
||||
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
|
||||
// The preferences model, on its own and without a display: what a preference
|
||||
// reads back, what it signals, and the two decisions that are pure functions
|
||||
// (how long a block lasts, when it is in force).
|
||||
namespace {
|
||||
|
||||
// Counts one signal so a test can assert it fired exactly once per real change.
|
||||
// QSignalSpy would need Qt Test, which this target deliberately does not link.
|
||||
//
|
||||
// It is a QObject used as the connection's context: the settings object is a
|
||||
// singleton that outlives every test, so without that the counter would be
|
||||
// dangling by the time the *next* test changed a value.
|
||||
class SignalCounter : public QObject {
|
||||
public:
|
||||
explicit SignalCounter(AppSettings* prefs) {
|
||||
QObject::connect(prefs, &AppSettings::logDirectoryChanged, this,
|
||||
[this](const QString&) { ++m_count; });
|
||||
QObject::connect(prefs, &AppSettings::logMaxBytesChanged, this,
|
||||
[this](qint64) { ++m_count; });
|
||||
QObject::connect(prefs, &AppSettings::dragDropEnabledChanged, this,
|
||||
[this](bool) { ++m_count; });
|
||||
QObject::connect(prefs, &AppSettings::languageChanged, this,
|
||||
[this](const QString&) { ++m_count; });
|
||||
QObject::connect(prefs, &AppSettings::autoUpdateCheckEnabledChanged, this,
|
||||
[this](bool) { ++m_count; });
|
||||
QObject::connect(prefs, &AppSettings::updateBlockChanged, this,
|
||||
[this] { ++m_count; });
|
||||
}
|
||||
int count() const { return m_count; }
|
||||
|
||||
private:
|
||||
int m_count = 0;
|
||||
};
|
||||
|
||||
// Every test starts from a known settings file: the model is a singleton, so
|
||||
// what one test writes would otherwise leak into the next.
|
||||
void resetSettings() {
|
||||
QSettings().clear();
|
||||
}
|
||||
|
||||
void testLogDirectoryDefaultsAndSanitizes() {
|
||||
resetSettings();
|
||||
AppSettings& prefs = AppSettings::instance();
|
||||
|
||||
// No preference saved: the journal goes to the user's own config tree.
|
||||
assert(prefs.logDirectory() == AppSettings::defaultLogDirectory());
|
||||
assert(!prefs.logDirectory().isEmpty());
|
||||
|
||||
// A home-relative path is what a user types; nothing else in the app would
|
||||
// expand it for them.
|
||||
assert(AppSettings::sanitizeLogDirectory(QStringLiteral("~/journaux")) ==
|
||||
QDir::homePath() + QStringLiteral("/journaux"));
|
||||
assert(AppSettings::sanitizeLogDirectory(QStringLiteral("~")) ==
|
||||
QDir::homePath());
|
||||
// An empty or blank directory is refused rather than leaving the app with
|
||||
// nowhere to log.
|
||||
assert(AppSettings::sanitizeLogDirectory(QString()).isEmpty() == false);
|
||||
assert(AppSettings::sanitizeLogDirectory(QStringLiteral(" ")) ==
|
||||
AppSettings::defaultLogDirectory());
|
||||
|
||||
SignalCounter counter(&prefs);
|
||||
const QString wanted = QDir::homePath() + QStringLiteral("/journaux-pacmgr");
|
||||
prefs.setLogDirectory(wanted);
|
||||
assert(prefs.logDirectory() == wanted);
|
||||
assert(counter.count() == 1);
|
||||
|
||||
// Setting the same value again says nothing new.
|
||||
prefs.setLogDirectory(wanted);
|
||||
assert(counter.count() == 1);
|
||||
|
||||
// Back to the default the key is dropped, not pinned: a later change of
|
||||
// XDG_CONFIG_HOME must follow the user.
|
||||
prefs.setLogDirectory(AppSettings::defaultLogDirectory());
|
||||
assert(prefs.logDirectory() == AppSettings::defaultLogDirectory());
|
||||
assert(!QSettings().contains(QStringLiteral("settings/logDirectory")));
|
||||
}
|
||||
|
||||
void testLogSizeCap() {
|
||||
resetSettings();
|
||||
AppSettings& prefs = AppSettings::instance();
|
||||
|
||||
// No cap until the user picks one.
|
||||
assert(prefs.logMaxBytes() == 0);
|
||||
|
||||
// A cap that would rotate on every line is raised to the floor rather than
|
||||
// honoured; a negative cap means "no cap".
|
||||
assert(AppSettings::sanitizeLogMaxBytes(-1) == 0);
|
||||
assert(AppSettings::sanitizeLogMaxBytes(0) == 0);
|
||||
assert(AppSettings::sanitizeLogMaxBytes(1024) == 64 * 1024);
|
||||
assert(AppSettings::sanitizeLogMaxBytes(5LL * 1024 * 1024) == 5LL * 1024 * 1024);
|
||||
|
||||
SignalCounter counter(&prefs);
|
||||
prefs.setLogMaxBytes(5LL * 1024 * 1024);
|
||||
assert(prefs.logMaxBytes() == 5LL * 1024 * 1024);
|
||||
assert(counter.count() == 1);
|
||||
// The value stored is the one that will be read back, not what was asked for.
|
||||
prefs.setLogMaxBytes(10);
|
||||
assert(prefs.logMaxBytes() == 64 * 1024);
|
||||
}
|
||||
|
||||
void testDragDropIsOnByDefault() {
|
||||
resetSettings();
|
||||
AppSettings& prefs = AppSettings::instance();
|
||||
|
||||
// Dropping a .flatpakref on the window is the quickest way to install one:
|
||||
// turning it off has to be a deliberate act.
|
||||
assert(prefs.dragDropEnabled());
|
||||
|
||||
SignalCounter counter(&prefs);
|
||||
prefs.setDragDropEnabled(false);
|
||||
assert(!prefs.dragDropEnabled());
|
||||
assert(counter.count() == 1);
|
||||
prefs.setDragDropEnabled(false);
|
||||
assert(counter.count() == 1);
|
||||
prefs.setDragDropEnabled(true);
|
||||
assert(prefs.dragDropEnabled());
|
||||
}
|
||||
|
||||
void testLanguage() {
|
||||
resetSettings();
|
||||
AppSettings& prefs = AppSettings::instance();
|
||||
|
||||
// No preference: follow the desktop, which the model records as "system".
|
||||
assert(prefs.language() == QStringLiteral("system"));
|
||||
|
||||
// An unknown code must not be stored: the interface would then be in a
|
||||
// language nothing can translate. An empty one is not unknown, it is unset.
|
||||
assert(AppSettings::sanitizeLanguage(QString()).isEmpty() == false);
|
||||
assert(AppSettings::sanitizeLanguage(QString()) == QStringLiteral("system"));
|
||||
assert(AppSettings::sanitizeLanguage(QStringLiteral("klingon")) == QStringLiteral("fr"));
|
||||
assert(AppSettings::sanitizeLanguage(QStringLiteral("EN")) == QStringLiteral("en"));
|
||||
assert(AppSettings::sanitizeLanguage(QStringLiteral("system")) == QStringLiteral("system"));
|
||||
|
||||
SignalCounter counter(&prefs);
|
||||
prefs.setLanguage(QStringLiteral("en"));
|
||||
assert(prefs.language() == QStringLiteral("en"));
|
||||
assert(counter.count() == 1);
|
||||
prefs.setLanguage(QStringLiteral("en"));
|
||||
assert(counter.count() == 1);
|
||||
assert(AppSettings::knownLanguages().contains(QStringLiteral("fr")));
|
||||
assert(AppSettings::knownLanguages().contains(QStringLiteral("en")));
|
||||
}
|
||||
|
||||
void testUpdateBlockPolicyIsPure() {
|
||||
const QDateTime now(QDate(2026, 9, 28), QTime(12, 0));
|
||||
|
||||
// Hours add up; "until cancelled" has no end and says so with an invalid date.
|
||||
assert(AppSettings::blockTarget(now, 1) == now.addSecs(3600));
|
||||
assert(AppSettings::blockTarget(now, 24 * 7) == now.addSecs(7 * 24 * 3600));
|
||||
assert(!AppSettings::blockTarget(now, 0).isValid());
|
||||
assert(!AppSettings::blockTarget(now, -5).isValid());
|
||||
|
||||
// Not blocked, blocked for a while, blocked for ever.
|
||||
assert(!AppSettings::isBlocked(now, false, QDateTime()));
|
||||
assert(AppSettings::isBlocked(now, false, now.addSecs(3600)));
|
||||
assert(!AppSettings::isBlocked(now, false, now.addSecs(-1)));
|
||||
assert(AppSettings::isBlocked(now, true, QDateTime()));
|
||||
|
||||
// The instant the block ends, it is over: a snooze that outlived itself
|
||||
// must not keep the user from ever checking again.
|
||||
assert(!AppSettings::isBlocked(now.addSecs(3600), false, now.addSecs(3600)));
|
||||
|
||||
// What it means, for the screen: nothing when no block is in force.
|
||||
assert(AppSettings::blockDescription(false, QDateTime(), now).isEmpty());
|
||||
assert(!AppSettings::blockDescription(true, QDateTime(), now).isEmpty());
|
||||
assert(!AppSettings::blockDescription(false, now.addSecs(3600), now).isEmpty());
|
||||
assert(!AppSettings::blockDescription(false, now.addSecs(180), now).isEmpty());
|
||||
assert(AppSettings::blockDescription(false, now.addSecs(-1), now).isEmpty());
|
||||
}
|
||||
|
||||
void testUpdateBlockIsPersistedAndCleared() {
|
||||
resetSettings();
|
||||
AppSettings& prefs = AppSettings::instance();
|
||||
|
||||
assert(!prefs.autoUpdateCheckEnabled() == false); // checked once a day by default
|
||||
assert(!prefs.updatesBlocked());
|
||||
|
||||
SignalCounter counter(&prefs);
|
||||
prefs.blockUpdatesFor(1);
|
||||
assert(prefs.updatesBlocked());
|
||||
assert(!prefs.updatesBlockedIndefinitely());
|
||||
assert(prefs.updateBlockedUntil().isValid());
|
||||
assert(counter.count() == 1);
|
||||
|
||||
// The block survives being read back: a new process sees the same block.
|
||||
AppSettings fresh;
|
||||
assert(fresh.updatesBlocked());
|
||||
assert(fresh.updateBlockedUntil() == prefs.updateBlockedUntil());
|
||||
|
||||
// "Until cancelled" keeps no deadline and still blocks.
|
||||
prefs.blockUpdatesFor(0);
|
||||
assert(prefs.updatesBlocked());
|
||||
assert(prefs.updatesBlockedIndefinitely());
|
||||
assert(!prefs.updateBlockedUntil().isValid());
|
||||
|
||||
prefs.unblockUpdates();
|
||||
assert(!prefs.updatesBlocked());
|
||||
assert(!prefs.updatesBlockedIndefinitely());
|
||||
assert(!prefs.updateBlockedUntil().isValid());
|
||||
}
|
||||
|
||||
void testAutomaticCheckCanBeTurnedOff() {
|
||||
resetSettings();
|
||||
AppSettings& prefs = AppSettings::instance();
|
||||
|
||||
SignalCounter counter(&prefs);
|
||||
prefs.setAutoUpdateCheckEnabled(false);
|
||||
assert(!prefs.autoUpdateCheckEnabled());
|
||||
assert(counter.count() == 1);
|
||||
// Turning it back on is not blocked by a block still in force: the two
|
||||
// settings are independent.
|
||||
prefs.setAutoUpdateCheckEnabled(true);
|
||||
assert(prefs.autoUpdateCheckEnabled());
|
||||
assert(counter.count() == 2);
|
||||
}
|
||||
|
||||
// The journal is the one thing the preferences change on disk, so it is
|
||||
// exercised for real: it must land in the chosen directory, carry the previous
|
||||
// one along, and rotate once the cap is reached.
|
||||
void testJournalMovesAndRotates() {
|
||||
resetSettings();
|
||||
AppSettings& prefs = AppSettings::instance();
|
||||
LogManager& journal = LogManager::instance();
|
||||
|
||||
// Cleared before the directory is chosen: a leftover from a previous run
|
||||
// would be carried over by the move and read as this run's.
|
||||
const QString first = QDir::homePath() + QStringLiteral("/journal-a");
|
||||
QFile::remove(first + QStringLiteral("/operations.log"));
|
||||
|
||||
prefs.setLogDirectory(first);
|
||||
journal.logEvent(QStringLiteral("test"), QStringLiteral("premier"));
|
||||
assert(QFile::exists(first + QStringLiteral("/operations.log")));
|
||||
assert(journal.filePath() == first + QStringLiteral("/operations.log"));
|
||||
|
||||
// Switching directory carries the journal along: the user did not ask to
|
||||
// lose the record of what the app did.
|
||||
const QString second = QDir::homePath() + QStringLiteral("/journal-b");
|
||||
QFile::remove(second + QStringLiteral("/operations.log"));
|
||||
prefs.setLogDirectory(second);
|
||||
assert(QFile::exists(second + QStringLiteral("/operations.log")));
|
||||
assert(!QFile::exists(first + QStringLiteral("/operations.log")));
|
||||
assert(journal.readFile().contains(QStringLiteral("premier")));
|
||||
|
||||
// The cap is a real ceiling, and the journal that came before is kept.
|
||||
prefs.setLogMaxBytes(64 * 1024);
|
||||
for (int i = 0; i < 2000; ++i) {
|
||||
journal.logEvent(QStringLiteral("test"),
|
||||
QStringLiteral("ligne de remplissage numéro %1").arg(i));
|
||||
}
|
||||
assert(QFile::exists(second + QStringLiteral("/operations.log.1")));
|
||||
assert(journal.currentSizeBytes() <= 64 * 1024);
|
||||
|
||||
// Back to no cap, and the log goes on growing.
|
||||
prefs.setLogMaxBytes(0);
|
||||
const qint64 before = journal.currentSizeBytes();
|
||||
journal.logEvent(QStringLiteral("test"), QStringLiteral("dernière"));
|
||||
assert(journal.currentSizeBytes() > before);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
// The model reads and writes QSettings, so the whole run has to happen
|
||||
// against a throwaway configuration.
|
||||
QTemporaryDir home;
|
||||
assert(home.isValid());
|
||||
qputenv("HOME", home.path().toLocal8Bit());
|
||||
qputenv("XDG_CONFIG_HOME", QDir(home.path()).filePath("config").toLocal8Bit());
|
||||
qputenv("XDG_DATA_HOME", QDir(home.path()).filePath("data").toLocal8Bit());
|
||||
|
||||
QCoreApplication app(argc, argv);
|
||||
app.setApplicationName("PacManagerSettingsTest");
|
||||
app.setOrganizationName("FWSTest");
|
||||
// The model is a singleton: one format, one place, decided before the first
|
||||
// QSettings is built.
|
||||
QSettings::setDefaultFormat(QSettings::IniFormat);
|
||||
QSettings::setPath(QSettings::IniFormat, QSettings::UserScope,
|
||||
QDir(home.path()).filePath("settings"));
|
||||
|
||||
testLogDirectoryDefaultsAndSanitizes();
|
||||
testLogSizeCap();
|
||||
testDragDropIsOnByDefault();
|
||||
testLanguage();
|
||||
testUpdateBlockPolicyIsPure();
|
||||
testUpdateBlockIsPersistedAndCleared();
|
||||
testAutomaticCheckCanBeTurnedOff();
|
||||
testJournalMovesAndRotates();
|
||||
|
||||
std::cout << "app-settings: all tests passed" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
// Unit tests for the command-line grammar (cli/cli-command.*): which arguments
|
||||
// ask for the command line rather than the window, and what each keyword parses
|
||||
// into. Pure parsing — no package manager, no display, nothing spawned.
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
#include "cli-command.h"
|
||||
|
||||
static QStringList args(std::initializer_list<const char*> words) {
|
||||
QStringList list;
|
||||
for (const char* word : words) list << QString::fromUtf8(word);
|
||||
return list;
|
||||
}
|
||||
|
||||
static void testInvocationRouting() {
|
||||
// No arguments, or a file the desktop handed over: the window is wanted.
|
||||
assert(!cli::isCliInvocation({}));
|
||||
assert(!cli::isCliInvocation(args({"/home/user/app.flatpak"})));
|
||||
assert(!cli::isCliInvocation(args({"app.flatpakref"})));
|
||||
assert(!cli::isCliInvocation(args({"./bundle.fwspacm"})));
|
||||
|
||||
// A keyword, or any leading option, is aimed at the command line.
|
||||
assert(cli::isCliInvocation(args({"recherche", "vlc"})));
|
||||
assert(cli::isCliInvocation(args({"install", "vlc"})));
|
||||
assert(cli::isCliInvocation(args({"search", "vlc"})));
|
||||
assert(cli::isCliInvocation(args({"--help"})));
|
||||
assert(cli::isCliInvocation(args({"-y", "install", "vlc"})));
|
||||
|
||||
// A bare word that is not a path is a mistyped command, not a file: the
|
||||
// command line reports it instead of opening a window that cannot use it.
|
||||
assert(cli::isCliInvocation(args({"frobnicate"})));
|
||||
}
|
||||
|
||||
static void testSearchParsing() {
|
||||
const cli::Parsed parsed = cli::parse(args({"recherche", "vlc"}));
|
||||
assert(parsed.command == cli::Command::Search);
|
||||
assert(parsed.operands == args({"vlc"}));
|
||||
|
||||
// The search word may hold spaces: the term is everything that follows.
|
||||
const cli::Parsed multi = cli::parse(args({"search", "gtk", "theme"}));
|
||||
assert(multi.command == cli::Command::Search);
|
||||
assert(multi.operands.join(QLatin1Char(' ')) == QLatin1String("gtk theme"));
|
||||
|
||||
// The keyword is not a search term on its own.
|
||||
const cli::Parsed missing = cli::parse(args({"recherche"}));
|
||||
assert(missing.command == cli::Command::Unknown);
|
||||
assert(!missing.error.isEmpty());
|
||||
}
|
||||
|
||||
static void testInstallAndRemoveParsing() {
|
||||
const cli::Parsed install = cli::parse(args({"install", "vlc"}));
|
||||
assert(install.command == cli::Command::Install);
|
||||
assert(install.operands == args({"vlc"}));
|
||||
|
||||
const cli::Parsed several = cli::parse(args({"installer", "vlc", "vim"}));
|
||||
assert(several.command == cli::Command::Install);
|
||||
assert(several.operands == args({"vlc", "vim"}));
|
||||
|
||||
const cli::Parsed remove = cli::parse(args({"supprimer", "-y", "vlc"}));
|
||||
assert(remove.command == cli::Command::Remove);
|
||||
assert(remove.assumeYes);
|
||||
assert(remove.operands == args({"vlc"}));
|
||||
|
||||
assert(cli::parse(args({"remove"})).command == cli::Command::Unknown);
|
||||
}
|
||||
|
||||
static void testUpdateParsing() {
|
||||
// No operand means everything; one operand means that package.
|
||||
const cli::Parsed all = cli::parse(args({"maj"}));
|
||||
assert(all.command == cli::Command::Update);
|
||||
assert(all.operands.isEmpty());
|
||||
|
||||
const cli::Parsed one = cli::parse(args({"update", "vlc"}));
|
||||
assert(one.command == cli::Command::Update);
|
||||
assert(one.operands == args({"vlc"}));
|
||||
|
||||
assert(cli::parse(args({"maj", "vlc", "vim"})).command == cli::Command::Unknown);
|
||||
}
|
||||
|
||||
static void testReadOnlyCommands() {
|
||||
assert(cli::parse(args({"liste"})).command == cli::Command::List);
|
||||
assert(cli::parse(args({"list"})).command == cli::Command::List);
|
||||
assert(cli::parse(args({"maj-dispo"})).command == cli::Command::Updates);
|
||||
assert(cli::parse(args({"cleanup"})).command == cli::Command::Cleanup);
|
||||
assert(cli::parse(args({"refresh"})).command == cli::Command::Refresh);
|
||||
|
||||
const cli::Parsed info = cli::parse(args({"info", "vlc"}));
|
||||
assert(info.command == cli::Command::Info);
|
||||
assert(info.operands == args({"vlc"}));
|
||||
assert(cli::parse(args({"info"})).command == cli::Command::Unknown);
|
||||
|
||||
// A listing takes no operand.
|
||||
assert(cli::parse(args({"liste", "vlc"})).command == cli::Command::Unknown);
|
||||
}
|
||||
|
||||
static void testHelpAndVersion() {
|
||||
assert(cli::parse(args({"--help"})).command == cli::Command::Help);
|
||||
assert(cli::parse(args({"aide"})).command == cli::Command::Help);
|
||||
// An option wins wherever it stands.
|
||||
assert(cli::parse(args({"install", "--help"})).command == cli::Command::Help);
|
||||
|
||||
assert(cli::parse(args({"--version"})).command == cli::Command::Version);
|
||||
assert(cli::parse(args({"-v"})).command == cli::Command::Version);
|
||||
|
||||
// The help names the keywords the parser accepts.
|
||||
assert(cli::helpText().contains(QLatin1String("recherche")));
|
||||
assert(cli::helpText().contains(QLatin1String("install")));
|
||||
}
|
||||
|
||||
static void testUnknownCommands() {
|
||||
const cli::Parsed word = cli::parse(args({"frobnicate"}));
|
||||
assert(word.command == cli::Command::Unknown);
|
||||
assert(word.error.contains(QLatin1String("frobnicate")));
|
||||
|
||||
const cli::Parsed option = cli::parse(args({"--nope"}));
|
||||
assert(option.command == cli::Command::Unknown);
|
||||
assert(option.error.contains(QLatin1String("--nope")));
|
||||
|
||||
// No argument at all is not an error: it is the window.
|
||||
assert(cli::parse({}).command == cli::Command::None);
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
QCoreApplication app(argc, argv);
|
||||
|
||||
testInvocationRouting();
|
||||
testSearchParsing();
|
||||
testInstallAndRemoveParsing();
|
||||
testUpdateParsing();
|
||||
testReadOnlyCommands();
|
||||
testHelpAndVersion();
|
||||
testUnknownCommands();
|
||||
|
||||
std::cout << "All cli-command tests passed" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,244 @@
|
||||
// Unit tests for LanguageManager: which language the setting resolves to, that
|
||||
// a catalogue installed at runtime really translates, that a bad one is
|
||||
// refused rather than half-applied, and that the English catalogue shipped in
|
||||
// translations/ covers every string the code base asks for.
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QSettings>
|
||||
#include <QRegularExpression>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QTemporaryDir>
|
||||
|
||||
#include "app-settings.h"
|
||||
#include "language-manager.h"
|
||||
|
||||
static int failures = 0;
|
||||
|
||||
static void check(bool cond, const char* name) {
|
||||
if (cond) {
|
||||
std::cout << "PASS " << name << std::endl;
|
||||
} else {
|
||||
std::cout << "FAIL " << name << std::endl;
|
||||
++failures;
|
||||
}
|
||||
}
|
||||
|
||||
static bool writeFile(const QString& path, const QByteArray& content) {
|
||||
QFile file(path);
|
||||
if (!file.open(QIODevice::WriteOnly)) return false;
|
||||
return file.write(content) == content.size();
|
||||
}
|
||||
|
||||
// A catalogue only counts as installed when it can actually translate: an
|
||||
// empty folder, a truncated file or plain prose must all leave the interface
|
||||
// untranslated rather than half of it.
|
||||
static void testCatalogueIsAcceptedOnlyWhenUsable(const QString& dir) {
|
||||
const QString path = dir + QStringLiteral("/translations");
|
||||
|
||||
check(!LanguageManager::isTranslationAvailable(QStringLiteral("zz")),
|
||||
"no_catalogue_means_unavailable");
|
||||
|
||||
writeFile(path + QStringLiteral("/zz.json"),
|
||||
R"({"Nettoyage": "Cleanup"})");
|
||||
check(LanguageManager::isTranslationAvailable(QStringLiteral("zz")) ||
|
||||
!AppSettings::knownLanguages().contains(QStringLiteral("zz")),
|
||||
"unknown_code_is_never_offered");
|
||||
|
||||
// French is the language the wording is written in, so it needs no
|
||||
// catalogue: resolve() keeps it whatever is on disk.
|
||||
writeFile(path + QStringLiteral("/fr.json"), R"({"Nettoyage": "Nettoyage FR"})");
|
||||
check(LanguageManager::resolve(QStringLiteral("fr")) == QLatin1String("fr"),
|
||||
"fr_needs_no_catalogue_to_stay_french");
|
||||
}
|
||||
|
||||
// The setting is either a code the app knows or "system"; resolve() then maps
|
||||
// "system" onto a language the app knows, never onto something exotic.
|
||||
static void testResolveFollowsTheSetting() {
|
||||
check(LanguageManager::resolve(QStringLiteral("en")) == QLatin1String("en"),
|
||||
"explicit_code_is_kept");
|
||||
check(LanguageManager::resolve(QStringLiteral("klingon")) == QLatin1String("fr"),
|
||||
"unknown_code_falls_back_to_the_written_language");
|
||||
|
||||
// With the environment asking for a known language, "system" follows it.
|
||||
qputenv("LC_ALL", "en_US.UTF-8");
|
||||
check(LanguageManager::resolve(QStringLiteral("system")) == QLatin1String("en"),
|
||||
"system_follows_the_environment");
|
||||
check(LanguageManager::systemLanguage().startsWith(QLatin1String("en")),
|
||||
"system_language_reads_the_environment");
|
||||
|
||||
// A @modifier is not part of the language.
|
||||
qputenv("LC_ALL", "fr_FR.UTF-8@euro");
|
||||
check(LanguageManager::systemLanguage() == QLatin1String("fr_FR.UTF-8"),
|
||||
"locale_modifier_is_dropped");
|
||||
|
||||
// An environment the app has no catalogue for leaves its own language.
|
||||
qputenv("LC_ALL", "eo_UTF-8");
|
||||
check(LanguageManager::resolve(QStringLiteral("system")) == QLatin1String("fr"),
|
||||
"unsupported_system_locale_falls_back");
|
||||
qunsetenv("LC_ALL");
|
||||
}
|
||||
|
||||
// The catalogue is a plain text file read at runtime, so apply() has to
|
||||
// translate without any build step having happened.
|
||||
static void testEnglishCatalogueTranslates() {
|
||||
if (!LanguageManager::isTranslationAvailable(QStringLiteral("en"))) {
|
||||
std::cout << "SKIP english_catalogue_missing" << std::endl;
|
||||
return;
|
||||
}
|
||||
check(LanguageManager::apply(QStringLiteral("en")),
|
||||
"english_catalogue_is_installed");
|
||||
|
||||
// Asked through a class context, like tr() does.
|
||||
const QString translated = QCoreApplication::translate(
|
||||
"BrowsePage", "Nettoyage", nullptr, -1);
|
||||
check(translated == QLatin1String("Cleanup"),
|
||||
"english_catalogue_translates_a_known_string");
|
||||
check(QCoreApplication::translate("BrowsePage", "Paquet jamais vu",
|
||||
nullptr, -1) == QLatin1String("Paquet jamais vu"),
|
||||
"untranslated_string_falls_back_to_the_source");
|
||||
|
||||
// A bare key serves every context, so a string two classes share needs one
|
||||
// entry, not one per class.
|
||||
check(QCoreApplication::translate("Inconnu", "Nettoyage", nullptr, -1) ==
|
||||
QLatin1String("Cleanup"),
|
||||
"a_bare_key_serves_every_context");
|
||||
|
||||
// A "Context::source" key wins over the bare one, which is how two classes
|
||||
// are given different wording for the same string.
|
||||
check(QCoreApplication::translate("LogManager", "Nettoyage", nullptr, -1) ==
|
||||
QLatin1String("Cleanup"),
|
||||
"bare_key_used_when_no_contextual_entry");
|
||||
|
||||
// Going back to French restores the wording the code was written in.
|
||||
LanguageManager::apply(QStringLiteral("fr"));
|
||||
check(QCoreApplication::translate("BrowsePage", "Nettoyage", nullptr, -1) ==
|
||||
QLatin1String("Nettoyage"),
|
||||
"switching_back_restores_the_original_wording");
|
||||
}
|
||||
|
||||
// A broken catalogue must not be installed: the interface has to stay whole,
|
||||
// in the language it is written in.
|
||||
static void testBrokenCatalogueIsRefused() {
|
||||
QTemporaryDir home;
|
||||
assert(home.isValid());
|
||||
const QString path = home.path() + QStringLiteral("/translations");
|
||||
QDir().mkpath(path);
|
||||
|
||||
writeFile(path + QStringLiteral("/fr.json"), "{ this is not json");
|
||||
check(!LanguageManager::isTranslationAvailable(QStringLiteral("fr")) ||
|
||||
true, "unreadable_catalogue_does_not_crash");
|
||||
|
||||
QDir(path).removeRecursively();
|
||||
QDir().mkpath(path);
|
||||
writeFile(path + QStringLiteral("/fr.json"), R"({"a": 1, "b": [2]})");
|
||||
check(!LanguageManager::apply(QStringLiteral("fr")),
|
||||
"catalogue_without_strings_is_refused");
|
||||
check(QCoreApplication::translate("BrowsePage", "Nettoyage", nullptr, -1) ==
|
||||
QLatin1String("Nettoyage"),
|
||||
"interface_stays_intact_after_a_refused_catalogue");
|
||||
}
|
||||
|
||||
// The catalogue in the repository has to cover what the code asks for: a
|
||||
// missing key is a string the user reads in French inside an English
|
||||
// interface, which is exactly what this issue is about.
|
||||
static void testEnglishCatalogueCoversTheSource() {
|
||||
const QString path = QStringLiteral(PACMANAGER_TRANSLATIONS_DIR) +
|
||||
QStringLiteral("/en.json");
|
||||
QFile file(path);
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
std::cout << "SKIP catalogue_not_found" << std::endl;
|
||||
return;
|
||||
}
|
||||
const QJsonObject catalogue =
|
||||
QJsonDocument::fromJson(file.readAll()).object();
|
||||
|
||||
QDir dir(QStringLiteral(PACMANAGER_TRANSLATIONS_DIR));
|
||||
const QFileInfoList sources = dir.entryInfoList(
|
||||
QStringList() << QStringLiteral("*.cpp") << QStringLiteral("*.h"),
|
||||
QDir::Files, QDir::Name);
|
||||
|
||||
QStringList missing;
|
||||
for (const QFileInfo& info : sources) {
|
||||
QFile cpp(info.absoluteFilePath());
|
||||
if (!cpp.open(QIODevice::ReadOnly)) continue;
|
||||
const QString text = QString::fromUtf8(cpp.readAll());
|
||||
cpp.close();
|
||||
|
||||
// Every tr(...) written in this file, adjacent literals joined.
|
||||
QRegularExpression call(
|
||||
QStringLiteral("\\b(?:tr|QT_TRANSLATE_NOOP|QCoreApplication::translate)"
|
||||
"\\s*\\(\\s*\"((?:[^\"\\\\]|\\\\.)*)\""),
|
||||
QRegularExpression::DotMatchesEverythingOption);
|
||||
QRegularExpression tail(
|
||||
QStringLiteral("^((?:\\s*\"(?:[^\"\\\\]|\\\\.)*\")+)"),
|
||||
QRegularExpression::DotMatchesEverythingOption);
|
||||
QRegularExpression literal(QStringLiteral("\"((?:[^\"\\\\]|\\\\.)*)\""));
|
||||
|
||||
auto it = call.globalMatch(text);
|
||||
while (it.hasNext()) {
|
||||
const QRegularExpressionMatch match = it.next();
|
||||
QString source = match.captured(1);
|
||||
const QString rest = text.mid(match.capturedEnd(0));
|
||||
// Adjacent literals continue the same sentence.
|
||||
QRegularExpressionMatch more = tail.match(rest);
|
||||
if (more.hasMatch()) {
|
||||
auto lit = literal.globalMatch(more.captured(0));
|
||||
while (lit.hasNext()) source += lit.next().captured(1);
|
||||
}
|
||||
source = source.replace(QStringLiteral("\\n"), QStringLiteral("\n"))
|
||||
.replace(QStringLiteral("\\t"), QStringLiteral("\t"))
|
||||
.replace(QStringLiteral("\\\""), QStringLiteral("\""));
|
||||
if (source.size() < 2) continue;
|
||||
if (catalogue.contains(source)) continue;
|
||||
// A string two classes share may be keyed per context instead.
|
||||
bool contextual = false;
|
||||
for (const QString& key : catalogue.keys()) {
|
||||
if (key.endsWith(QStringLiteral("::") + source)) {
|
||||
contextual = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!contextual) missing << source;
|
||||
}
|
||||
}
|
||||
|
||||
check(missing.isEmpty(), "english_catalogue_covers_every_string");
|
||||
for (const QString& source : missing) {
|
||||
std::cout << " missing: " << source.toStdString() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
QTemporaryDir home;
|
||||
assert(home.isValid());
|
||||
qputenv("HOME", home.path().toLocal8Bit());
|
||||
qputenv("XDG_CONFIG_HOME", QDir(home.path()).filePath("config").toLocal8Bit());
|
||||
qputenv("XDG_DATA_HOME", QDir(home.path()).filePath("data").toLocal8Bit());
|
||||
|
||||
QCoreApplication app(argc, argv);
|
||||
app.setApplicationName("PacManagerLanguageTest");
|
||||
app.setOrganizationName("FWSTest");
|
||||
QSettings::setDefaultFormat(QSettings::IniFormat);
|
||||
QSettings::setPath(QSettings::IniFormat, QSettings::UserScope,
|
||||
QDir(home.path()).filePath("settings"));
|
||||
|
||||
// A folder the search path can find, so the "no catalogue" case is real.
|
||||
const QString dir = QDir(home.path()).filePath("data/catalogues");
|
||||
QDir().mkpath(dir + QStringLiteral("/translations"));
|
||||
|
||||
testCatalogueIsAcceptedOnlyWhenUsable(dir);
|
||||
testResolveFollowsTheSetting();
|
||||
testEnglishCatalogueTranslates();
|
||||
testBrokenCatalogueIsRefused();
|
||||
testEnglishCatalogueCoversTheSource();
|
||||
|
||||
if (failures == 0) std::cout << "All language-manager tests passed" << std::endl;
|
||||
return failures == 0 ? 0 : 1;
|
||||
}
|
||||
@@ -0,0 +1,615 @@
|
||||
// Unit tests for PluginPackage: the .fwspacm format, and the bookkeeping that
|
||||
// decides what an uninstall is allowed to delete.
|
||||
//
|
||||
// The archives are built here (both a stored and a deflated entry, so both
|
||||
// compression methods are exercised), every file operation runs in a temporary
|
||||
// directory, and the settings go to a temporary INI: no network, no real
|
||||
// plugin, nothing of the user's is touched.
|
||||
#include "plugin-package.h"
|
||||
|
||||
#include <QCryptographicHash>
|
||||
#include <QCoreApplication>
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QSettings>
|
||||
#include <QTemporaryDir>
|
||||
#include <QTextStream>
|
||||
|
||||
#include <zlib.h>
|
||||
|
||||
#include <cassert>
|
||||
|
||||
namespace {
|
||||
|
||||
// --- Building archives -----------------------------------------------------
|
||||
|
||||
void writeU16(QByteArray* out, quint16 value) {
|
||||
out->append(static_cast<char>(value & 0xff));
|
||||
out->append(static_cast<char>((value >> 8) & 0xff));
|
||||
}
|
||||
|
||||
void writeU32(QByteArray* out, quint32 value) {
|
||||
out->append(static_cast<char>(value & 0xff));
|
||||
out->append(static_cast<char>((value >> 8) & 0xff));
|
||||
out->append(static_cast<char>((value >> 16) & 0xff));
|
||||
out->append(static_cast<char>((value >> 24) & 0xff));
|
||||
}
|
||||
|
||||
// A minimal ZIP writer, so the reader is tested against bytes rather than
|
||||
// against a library that would agree with it by construction. `stored` writes
|
||||
// the payload uncompressed (method 0), otherwise a deflate stream is required
|
||||
// from the caller and written as-is (method 8).
|
||||
class ZipBuilder {
|
||||
public:
|
||||
void addFile(const QString& name, const QByteArray& payload, bool stored) {
|
||||
m_entries.append({name, payload, stored});
|
||||
}
|
||||
|
||||
// Adds a directory entry, which a reader has to skip rather than treat as a
|
||||
// file.
|
||||
void addDirectory(const QString& name) {
|
||||
m_entries.append({name, QByteArray(), true, true});
|
||||
}
|
||||
|
||||
QByteArray build() const {
|
||||
QByteArray out;
|
||||
QList<int> offsets;
|
||||
for (const auto& entry : m_entries) {
|
||||
offsets.append(out.size());
|
||||
const QByteArray name = entry.name.toUtf8();
|
||||
const QByteArray payload =
|
||||
entry.directory ? QByteArray() : entry.payload;
|
||||
|
||||
writeU32(&out, 0x04034b50);
|
||||
writeU16(&out, 20); // version needed
|
||||
writeU16(&out, 0); // flags
|
||||
writeU16(&out, entry.directory ? 0 : (entry.stored ? 0 : 8));
|
||||
writeU16(&out, 0); // mod time
|
||||
writeU16(&out, 0); // mod date
|
||||
writeU32(&out, 0); // crc (not verified on read)
|
||||
writeU32(&out, static_cast<quint32>(payload.size()));
|
||||
writeU32(&out, static_cast<quint32>(entry.rawSize()));
|
||||
writeU16(&out, static_cast<quint16>(name.size()));
|
||||
writeU16(&out, 0); // extra
|
||||
out.append(name);
|
||||
if (entry.stored || entry.directory) {
|
||||
out.append(payload);
|
||||
} else {
|
||||
out.append(entry.deflated);
|
||||
}
|
||||
}
|
||||
|
||||
const int directoryOffset = out.size();
|
||||
for (int i = 0; i < m_entries.size(); ++i) {
|
||||
const auto& entry = m_entries[i];
|
||||
const QByteArray name = entry.name.toUtf8();
|
||||
const QByteArray payload = entry.directory ? QByteArray() : entry.payload;
|
||||
const int compressedSize =
|
||||
entry.directory ? 0
|
||||
: (entry.stored ? payload.size() : entry.deflated.size());
|
||||
|
||||
writeU32(&out, 0x02014b50);
|
||||
writeU16(&out, 20); // version made by
|
||||
writeU16(&out, 20); // version needed
|
||||
writeU16(&out, 0); // flags
|
||||
writeU16(&out, entry.directory ? 0 : (entry.stored ? 0 : 8));
|
||||
writeU16(&out, 0);
|
||||
writeU16(&out, 0);
|
||||
writeU32(&out, 0); // crc
|
||||
writeU32(&out, static_cast<quint32>(compressedSize));
|
||||
writeU32(&out, static_cast<quint32>(entry.directory ? 0 : payload.size()));
|
||||
writeU16(&out, static_cast<quint16>(name.size()));
|
||||
writeU16(&out, 0); // extra
|
||||
writeU16(&out, 0); // comment
|
||||
writeU16(&out, 0); // disk
|
||||
writeU16(&out, 0); // internal attributes
|
||||
writeU32(&out, 0); // external attributes
|
||||
writeU32(&out, static_cast<quint32>(offsets[i]));
|
||||
out.append(name);
|
||||
}
|
||||
const int directorySize = out.size() - directoryOffset;
|
||||
|
||||
writeU32(&out, 0x06054b50);
|
||||
writeU16(&out, 0);
|
||||
writeU16(&out, 0);
|
||||
writeU16(&out, static_cast<quint16>(m_entries.size()));
|
||||
writeU16(&out, static_cast<quint16>(m_entries.size()));
|
||||
writeU32(&out, static_cast<quint32>(directorySize));
|
||||
writeU32(&out, static_cast<quint32>(directoryOffset));
|
||||
writeU16(&out, 0); // comment
|
||||
return out;
|
||||
}
|
||||
|
||||
// A deflate stream for a payload, produced by zlib the same way a real ZIP
|
||||
// writer would. Raw deflate, not the zlib-wrapped stream compress2() emits:
|
||||
// a ZIP entry has no zlib header and no trailing checksum, which is why the
|
||||
// reader in zip-archive.cpp calls inflateInit2() with a negative window.
|
||||
static QByteArray rawDeflate(const QByteArray& payload) {
|
||||
z_stream stream{};
|
||||
if (deflateInit2(&stream, Z_DEFAULT_COMPRESSION, Z_DEFLATED, -MAX_WBITS, 8,
|
||||
Z_DEFAULT_STRATEGY) != Z_OK) {
|
||||
return {};
|
||||
}
|
||||
stream.next_in = const_cast<Bytef*>(reinterpret_cast<const Bytef*>(payload.constData()));
|
||||
stream.avail_in = static_cast<uInt>(payload.size());
|
||||
|
||||
QByteArray out;
|
||||
char buffer[16384];
|
||||
int status = Z_OK;
|
||||
do {
|
||||
stream.next_out = reinterpret_cast<Bytef*>(buffer);
|
||||
stream.avail_out = sizeof(buffer);
|
||||
status = deflate(&stream, Z_FINISH);
|
||||
assert(status == Z_OK || status == Z_STREAM_END);
|
||||
out.append(buffer, static_cast<int>(sizeof(buffer)) - static_cast<int>(stream.avail_out));
|
||||
} while (status != Z_STREAM_END);
|
||||
deflateEnd(&stream);
|
||||
return out;
|
||||
}
|
||||
|
||||
private:
|
||||
struct Entry {
|
||||
QString name;
|
||||
QByteArray payload;
|
||||
bool stored = true;
|
||||
bool directory = false;
|
||||
QByteArray deflated;
|
||||
|
||||
Entry() = default;
|
||||
Entry(QString entryName, QByteArray entryPayload, bool isStored)
|
||||
: name(std::move(entryName)),
|
||||
payload(std::move(entryPayload)),
|
||||
stored(isStored) {
|
||||
if (!stored) deflated = rawDeflate(payload);
|
||||
}
|
||||
Entry(QString entryName, QByteArray, bool, bool isDirectory)
|
||||
: name(std::move(entryName)), stored(true), directory(isDirectory) {}
|
||||
|
||||
int rawSize() const { return static_cast<int>(payload.size()); }
|
||||
};
|
||||
|
||||
QList<Entry> m_entries;
|
||||
};
|
||||
|
||||
QByteArray sha256Of(const QByteArray& payload) {
|
||||
return QCryptographicHash::hash(payload, QCryptographicHash::Sha256).toHex();
|
||||
}
|
||||
|
||||
// Writes an archive and closes it, so the file is complete on disk before any
|
||||
// test reads it back.
|
||||
QString writeArchive(const QString& path, const ZipBuilder& zip) {
|
||||
QFile file(path);
|
||||
assert(file.open(QIODevice::WriteOnly));
|
||||
file.write(zip.build());
|
||||
file.close();
|
||||
return path;
|
||||
}
|
||||
|
||||
// A package with a manifest and a library, written to `path`.
|
||||
QString writePackage(const QString& path, const QByteArray& library,
|
||||
const QByteArray& manifest, bool deflated = true) {
|
||||
ZipBuilder zip;
|
||||
zip.addFile(QStringLiteral("plugin.json"), manifest, false);
|
||||
zip.addFile(QStringLiteral("libsample.so"), library, !deflated);
|
||||
return writeArchive(path, zip);
|
||||
}
|
||||
|
||||
QByteArray manifestJson(const QByteArray& library, bool withChecksum = true) {
|
||||
QByteArray json = "{\"format\": 1, \"id\": \"sample\", \"name\": \"Sample\", "
|
||||
"\"kind\": \"provider\", \"version\": \"1.0.0\", "
|
||||
"\"library\": \"libsample.so\"";
|
||||
if (withChecksum) {
|
||||
json += ", \"sha256\": \"" + sha256Of(library) + "\"";
|
||||
}
|
||||
json += "}";
|
||||
return json;
|
||||
}
|
||||
|
||||
const QByteArray kLibrary = QByteArray("\x7f"
|
||||
"ELF-fake-shared-library-payload");
|
||||
|
||||
// --- Tests -----------------------------------------------------------------
|
||||
|
||||
// A well-formed package is read whole: manifest fields, library bytes, and the
|
||||
// name the library is written under.
|
||||
static void testPackageIsRead() {
|
||||
QTemporaryDir dir;
|
||||
const QString path = writePackage(dir.path() + "/sample.fwspacm", kLibrary,
|
||||
manifestJson(kLibrary));
|
||||
|
||||
QString error;
|
||||
const PluginPackage::Contents contents = PluginPackage::read(path, &error);
|
||||
assert(error.isEmpty());
|
||||
assert(contents.manifest.id == QStringLiteral("sample"));
|
||||
assert(contents.manifest.name == QStringLiteral("Sample"));
|
||||
assert(contents.manifest.version == QStringLiteral("1.0.0"));
|
||||
assert(contents.manifest.kind == QStringLiteral("provider"));
|
||||
assert(contents.library == kLibrary);
|
||||
assert(contents.libraryName == QStringLiteral("libsample.so"));
|
||||
}
|
||||
|
||||
// A deflated entry and a stored one must give the same bytes back: the format
|
||||
// allows both, and a plugin author picks whichever their zip tool defaults to.
|
||||
static void testBothCompressionMethodsAreRead() {
|
||||
QTemporaryDir dir;
|
||||
|
||||
QString error;
|
||||
const PluginPackage::Contents deflated = PluginPackage::read(
|
||||
writePackage(dir.path() + "/deflated.fwspacm", kLibrary, manifestJson(kLibrary), true),
|
||||
&error);
|
||||
assert(error.isEmpty());
|
||||
assert(deflated.library == kLibrary);
|
||||
|
||||
const PluginPackage::Contents stored = PluginPackage::read(
|
||||
writePackage(dir.path() + "/stored.fwspacm", kLibrary, manifestJson(kLibrary), false),
|
||||
&error);
|
||||
assert(error.isEmpty());
|
||||
assert(stored.library == kLibrary);
|
||||
}
|
||||
|
||||
// A library whose bytes do not match the announced checksum never reaches the
|
||||
// plugin directory: that check is the only guarantee about *which* code runs.
|
||||
static void testChecksumMismatchIsRefused() {
|
||||
QTemporaryDir dir;
|
||||
// The manifest announces the checksum of other bytes than the ones zipped.
|
||||
const QByteArray other = QByteArray("some other library");
|
||||
QByteArray manifest = "{\"format\": 1, \"id\": \"sample\", "
|
||||
"\"library\": \"libsample.so\", \"sha256\": \"" +
|
||||
sha256Of(other) + "\"}";
|
||||
|
||||
QString error;
|
||||
const PluginPackage::Contents contents = PluginPackage::read(
|
||||
writePackage(dir.path() + "/sample.fwspacm", kLibrary, manifest), &error);
|
||||
assert(contents.library.isEmpty());
|
||||
assert(error.contains(QStringLiteral("Somme de contrôle")));
|
||||
}
|
||||
|
||||
// Without a checksum the package still installs: the manifest is free to omit
|
||||
// it, and refusing would make the format unusable for a local build.
|
||||
static void testChecksumIsOptional() {
|
||||
QTemporaryDir dir;
|
||||
QString error;
|
||||
const PluginPackage::Contents contents = PluginPackage::read(
|
||||
writePackage(dir.path() + "/sample.fwspacm", kLibrary, manifestJson(kLibrary, false)),
|
||||
&error);
|
||||
assert(error.isEmpty());
|
||||
assert(contents.library == kLibrary);
|
||||
}
|
||||
|
||||
// Every way a package can be unusable must be refused with a reason, and never
|
||||
// half-installed.
|
||||
static void testInvalidPackagesAreRefused() {
|
||||
QTemporaryDir dir;
|
||||
QString error;
|
||||
|
||||
// Not a ZIP at all.
|
||||
const QString plain = dir.path() + "/plain.fwspacm";
|
||||
{
|
||||
QFile file(plain);
|
||||
assert(file.open(QIODevice::WriteOnly));
|
||||
file.write("this is not an archive");
|
||||
file.close();
|
||||
}
|
||||
assert(PluginPackage::read(plain, &error).library.isEmpty());
|
||||
assert(!error.isEmpty());
|
||||
|
||||
// A ZIP with no manifest: the library is right there, and it is still
|
||||
// refused, because a package without a manifest says nothing about what it
|
||||
// would install.
|
||||
{
|
||||
ZipBuilder zip;
|
||||
zip.addFile(QStringLiteral("libsample.so"), kLibrary, true);
|
||||
const QString path = writeArchive(dir.path() + "/nomanifest.fwspacm", zip);
|
||||
assert(PluginPackage::read(path, &error).library.isEmpty());
|
||||
assert(error.contains(QStringLiteral("plugin.json")));
|
||||
}
|
||||
|
||||
// A manifest that is not JSON, and one that is JSON but not an object.
|
||||
assert(PluginPackage::read(
|
||||
writePackage(dir.path() + "/badjson.fwspacm", kLibrary, "{ not json"),
|
||||
&error).library.isEmpty());
|
||||
assert(!error.isEmpty());
|
||||
assert(PluginPackage::read(
|
||||
writePackage(dir.path() + "/array.fwspacm", kLibrary, "[]"), &error)
|
||||
.library.isEmpty());
|
||||
assert(!error.isEmpty());
|
||||
|
||||
// A manifest of another version: read as-is would mean reading a package as
|
||||
// something it is not.
|
||||
assert(PluginPackage::read(
|
||||
writePackage(dir.path() + "/format2.fwspacm", kLibrary,
|
||||
"{\"format\": 2, \"id\": \"sample\", "
|
||||
"\"library\": \"libsample.so\"}"),
|
||||
&error).library.isEmpty());
|
||||
assert(error.contains(QStringLiteral("Format de paquet")));
|
||||
|
||||
// A manifest with no id.
|
||||
assert(PluginPackage::read(
|
||||
writePackage(dir.path() + "/noid.fwspacm", kLibrary,
|
||||
"{\"format\": 1, \"library\": \"libsample.so\"}"),
|
||||
&error).library.isEmpty());
|
||||
assert(error.contains(QStringLiteral("id")));
|
||||
|
||||
// An id holding a slash would need quoting as a settings key.
|
||||
assert(PluginPackage::read(
|
||||
writePackage(dir.path() + "/badid.fwspacm", kLibrary,
|
||||
"{\"format\": 1, \"id\": \"a/b\", "
|
||||
"\"library\": \"libsample.so\"}"),
|
||||
&error).library.isEmpty());
|
||||
assert(error.contains(QStringLiteral("Identifiant refusé")));
|
||||
|
||||
// A manifest naming a library the archive does not contain.
|
||||
assert(PluginPackage::read(
|
||||
writePackage(dir.path() + "/nolib.fwspacm", kLibrary,
|
||||
"{\"format\": 1, \"id\": \"sample\", "
|
||||
"\"library\": \"libabsent.so\"}"),
|
||||
&error).library.isEmpty());
|
||||
assert(!error.isEmpty());
|
||||
|
||||
// A manifest naming a path instead of a file name: the package would be
|
||||
// writing outside the directory it is installed into.
|
||||
assert(PluginPackage::read(
|
||||
writePackage(dir.path() + "/escape.fwspacm", kLibrary,
|
||||
"{\"format\": 1, \"id\": \"sample\", "
|
||||
"\"library\": \"../libsample.so\"}"),
|
||||
&error).library.isEmpty());
|
||||
assert(!error.isEmpty());
|
||||
|
||||
// An archive with no shared library at all. The manifest names none, so the
|
||||
// reader has to find it by suffix and finds nothing.
|
||||
{
|
||||
ZipBuilder zip;
|
||||
zip.addFile(QStringLiteral("plugin.json"),
|
||||
"{\"format\": 1, \"id\": \"sample\", \"name\": \"Sample\"}", false);
|
||||
zip.addFile(QStringLiteral("readme.txt"), "nothing to load", true);
|
||||
const QString path = writeArchive(dir.path() + "/nolibrary.fwspacm", zip);
|
||||
assert(PluginPackage::read(path, &error).library.isEmpty());
|
||||
assert(error.contains(QStringLiteral("bibliothèque partagée")));
|
||||
}
|
||||
|
||||
// An empty library is refused: writing a zero-byte file into the scanned
|
||||
// directory would fail later, at load time, with a worse message.
|
||||
assert(PluginPackage::read(
|
||||
writePackage(dir.path() + "/emptylib.fwspacm", QByteArray(),
|
||||
manifestJson(QByteArray(), false)),
|
||||
&error).library.isEmpty());
|
||||
assert(error.contains(QStringLiteral("vide")));
|
||||
}
|
||||
|
||||
// With no "library" in the manifest, the archive's single shared library is
|
||||
// the one to install; with several, the package has to say which, because
|
||||
// picking one silently is how the wrong file gets installed.
|
||||
static void testLibraryIsFoundBySuffix() {
|
||||
ZipArchive archive;
|
||||
QString error;
|
||||
assert(archive.openData(
|
||||
[] {
|
||||
ZipBuilder zip;
|
||||
zip.addFile(QStringLiteral("readme.txt"), "docs", true);
|
||||
zip.addFile(QStringLiteral("libonly.so"), kLibrary, true);
|
||||
return zip.build();
|
||||
}(),
|
||||
&error));
|
||||
assert(error.isEmpty());
|
||||
|
||||
PluginPackage::Manifest manifest;
|
||||
manifest.id = QStringLiteral("sample");
|
||||
const QString found = PluginPackage::targetFileName(manifest, archive, &error);
|
||||
assert(error.isEmpty());
|
||||
assert(found == QStringLiteral("libonly.so"));
|
||||
|
||||
// Two candidates: refused rather than guessed.
|
||||
ZipArchive ambiguous;
|
||||
assert(ambiguous.openData(
|
||||
[] {
|
||||
ZipBuilder zip;
|
||||
zip.addFile(QStringLiteral("libone.so"), kLibrary, true);
|
||||
zip.addFile(QStringLiteral("libtwo.so"), kLibrary, true);
|
||||
return zip.build();
|
||||
}(),
|
||||
&error));
|
||||
assert(PluginPackage::targetFileName(manifest, ambiguous, &error).isEmpty());
|
||||
assert(error.contains(QStringLiteral("library")));
|
||||
|
||||
// A directory entry is not a library, whatever it is called.
|
||||
ZipArchive onlyDir;
|
||||
assert(onlyDir.openData(
|
||||
[] {
|
||||
ZipBuilder zip;
|
||||
zip.addDirectory(QStringLiteral("libdir.so/"));
|
||||
return zip.build();
|
||||
}(),
|
||||
&error));
|
||||
assert(PluginPackage::targetFileName(manifest, onlyDir, &error).isEmpty());
|
||||
assert(!error.isEmpty());
|
||||
}
|
||||
|
||||
// Entry names that would escape the directory they are written to.
|
||||
static void testUnsafeEntryNamesAreRefused() {
|
||||
assert(ZipArchive::isSafeEntryName(QStringLiteral("libsample.so")));
|
||||
assert(ZipArchive::isSafeEntryName(QStringLiteral("subdir/libsample.so")));
|
||||
|
||||
assert(!ZipArchive::isSafeEntryName(QString()));
|
||||
assert(!ZipArchive::isSafeEntryName(QStringLiteral("/etc/passwd")));
|
||||
assert(!ZipArchive::isSafeEntryName(QStringLiteral("../escape.so")));
|
||||
assert(!ZipArchive::isSafeEntryName(QStringLiteral("subdir/../../escape.so")));
|
||||
assert(!ZipArchive::isSafeEntryName(QStringLiteral("\\windows\\system32")));
|
||||
assert(!ZipArchive::isSafeEntryName(QStringLiteral("C:/windows")));
|
||||
}
|
||||
|
||||
// Installing writes the library in the install directory and records it;
|
||||
// removing takes back exactly that file, and refuses anything else.
|
||||
static void testInstallAndRemove() {
|
||||
QTemporaryDir dir;
|
||||
PluginPackage packages;
|
||||
const QString pluginsDir = dir.path() + "/plugins";
|
||||
packages.setInstallDirectory(pluginsDir);
|
||||
|
||||
const QString path = writePackage(dir.path() + "/sample.fwspacm", kLibrary,
|
||||
manifestJson(kLibrary));
|
||||
|
||||
QString id;
|
||||
bool success = false;
|
||||
QObject::connect(&packages, &PluginPackage::installFinished, &packages,
|
||||
[&](const QString& installedId, bool ok, const QString&) {
|
||||
id = installedId;
|
||||
success = ok;
|
||||
});
|
||||
|
||||
// Nothing installed yet: a removal must fail rather than delete anything.
|
||||
// A separate flag, since removeFinished is the signal a removal reports on.
|
||||
bool removed = true;
|
||||
QObject::connect(&packages, &PluginPackage::removeFinished, &packages,
|
||||
[&](const QString&, bool ok, const QString&) { removed = ok; });
|
||||
|
||||
packages.remove(QStringLiteral("sample"));
|
||||
assert(!removed);
|
||||
|
||||
packages.install(path);
|
||||
assert(success);
|
||||
assert(id == QStringLiteral("sample"));
|
||||
assert(packages.isInstalled(QStringLiteral("sample")));
|
||||
|
||||
const QString written = pluginsDir + "/libsample.so";
|
||||
assert(packages.installedPath(QStringLiteral("sample")) == written);
|
||||
QFile file(written);
|
||||
assert(file.open(QIODevice::ReadOnly));
|
||||
assert(file.readAll() == kLibrary);
|
||||
file.close();
|
||||
|
||||
// The id shows up in the list the page renders.
|
||||
assert(packages.installedIds() == QStringList{QStringLiteral("sample")});
|
||||
|
||||
success = false;
|
||||
removed = false;
|
||||
packages.remove(QStringLiteral("sample"));
|
||||
assert(removed);
|
||||
assert(!QFile::exists(written));
|
||||
assert(!packages.isInstalled(QStringLiteral("sample")));
|
||||
assert(packages.installedIds().isEmpty());
|
||||
}
|
||||
|
||||
// A file the user copied in by hand is not the installer's to delete.
|
||||
static void testUninstallOnlyRemovesWhatItInstalled() {
|
||||
QTemporaryDir dir;
|
||||
PluginPackage packages;
|
||||
packages.setInstallDirectory(dir.path() + "/plugins");
|
||||
assert(QDir().mkpath(dir.path() + "/plugins"));
|
||||
|
||||
// A library present in the directory, with no install recorded for it.
|
||||
const QString handPlaced = dir.path() + "/plugins/libmanual.so";
|
||||
QFile manual(handPlaced);
|
||||
assert(manual.open(QIODevice::WriteOnly));
|
||||
manual.write(kLibrary);
|
||||
manual.close();
|
||||
|
||||
bool success = true;
|
||||
QObject::connect(&packages, &PluginPackage::removeFinished, &packages,
|
||||
[&](const QString&, bool ok, const QString&) { success = ok; });
|
||||
|
||||
packages.remove(QStringLiteral("manual"));
|
||||
assert(!success);
|
||||
assert(QFile::exists(handPlaced));
|
||||
}
|
||||
|
||||
// A file deleted behind the installer's back is not installed any more, even
|
||||
// though the setting still names it: the state follows the disk.
|
||||
static void testMissingFileCountsAsNotInstalled() {
|
||||
QTemporaryDir dir;
|
||||
PluginPackage packages;
|
||||
packages.setInstallDirectory(dir.path() + "/plugins");
|
||||
|
||||
QSettings settings;
|
||||
settings.setValue("packages/installed/gone", dir.path() + "/plugins/libgone.so");
|
||||
settings.sync();
|
||||
|
||||
assert(!packages.isInstalled(QStringLiteral("gone")));
|
||||
assert(packages.installedPath(QStringLiteral("gone")).isEmpty());
|
||||
// A recorded but missing library is not listed either, so the page never
|
||||
// offers to remove something that is not there.
|
||||
assert(!packages.installedIds().contains(QStringLiteral("gone")));
|
||||
}
|
||||
|
||||
// Reinstalling a package overwrites the previous library, in place.
|
||||
static void testReinstallOverwrites() {
|
||||
QTemporaryDir dir;
|
||||
PluginPackage packages;
|
||||
packages.setInstallDirectory(dir.path() + "/plugins");
|
||||
|
||||
bool success = false;
|
||||
QObject::connect(&packages, &PluginPackage::installFinished, &packages,
|
||||
[&](const QString&, bool ok, const QString&) { success = ok; });
|
||||
|
||||
packages.install(writePackage(dir.path() + "/v1.fwspacm", kLibrary,
|
||||
manifestJson(kLibrary)));
|
||||
assert(success);
|
||||
|
||||
const QByteArray newer = kLibrary + "-v2";
|
||||
packages.install(writePackage(dir.path() + "/v2.fwspacm", newer,
|
||||
manifestJson(newer)));
|
||||
assert(success);
|
||||
|
||||
QFile file(dir.path() + "/plugins/libsample.so");
|
||||
assert(file.open(QIODevice::ReadOnly));
|
||||
assert(file.readAll() == newer);
|
||||
}
|
||||
|
||||
// A file that is not a package is refused before it is even opened.
|
||||
static void testNonPackageIsRefused() {
|
||||
assert(PluginPackage::isPackagePath(QStringLiteral("/tmp/sample.fwspacm")));
|
||||
assert(PluginPackage::isPackagePath(QStringLiteral("/tmp/SAMPLE.FWSPACM")));
|
||||
assert(!PluginPackage::isPackagePath(QStringLiteral("/tmp/sample.fwspacm.zip")));
|
||||
assert(!PluginPackage::isPackagePath(QStringLiteral("/tmp/sample.so")));
|
||||
assert(!PluginPackage::isPackagePath(QString()));
|
||||
|
||||
QTemporaryDir dir;
|
||||
PluginPackage packages;
|
||||
packages.setInstallDirectory(dir.path() + "/plugins");
|
||||
|
||||
bool success = true;
|
||||
QString message;
|
||||
QObject::connect(&packages, &PluginPackage::installFinished, &packages,
|
||||
[&](const QString&, bool ok, const QString& detail) {
|
||||
success = ok;
|
||||
message = detail;
|
||||
});
|
||||
|
||||
// Written under a .fwspacm name, so the extension is not what refuses it:
|
||||
// the content is.
|
||||
const QString path = writePackage(dir.path() + "/bogus.fwspacm", kLibrary,
|
||||
QByteArray("{\"format\": 9, \"id\": \"x\"}"));
|
||||
packages.install(path);
|
||||
assert(!success);
|
||||
assert(!message.isEmpty());
|
||||
assert(!packages.installedIds().contains(QStringLiteral("x")));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
QCoreApplication app(argc, argv);
|
||||
app.setOrganizationName(QStringLiteral("PacManagerTests"));
|
||||
app.setApplicationName(QStringLiteral("plugin-package-test"));
|
||||
|
||||
// Settings and the install directory go to a temporary INI, so the recorded
|
||||
// installs of these tests never reach the user's real configuration.
|
||||
QTemporaryDir settingsDir;
|
||||
QSettings::setDefaultFormat(QSettings::IniFormat);
|
||||
QSettings::setPath(QSettings::IniFormat, QSettings::UserScope, settingsDir.path());
|
||||
|
||||
testPackageIsRead();
|
||||
testBothCompressionMethodsAreRead();
|
||||
testChecksumMismatchIsRefused();
|
||||
testChecksumIsOptional();
|
||||
testInvalidPackagesAreRefused();
|
||||
testLibraryIsFoundBySuffix();
|
||||
testUnsafeEntryNamesAreRefused();
|
||||
testInstallAndRemove();
|
||||
testUninstallOnlyRemovesWhatItInstalled();
|
||||
testMissingFileCountsAsNotInstalled();
|
||||
testReinstallOverwrites();
|
||||
testNonPackageIsRefused();
|
||||
|
||||
QTextStream(stdout) << "All plugin-package tests passed." << Qt::endl;
|
||||
return 0;
|
||||
}
|
||||
@@ -1,181 +0,0 @@
|
||||
// Unit tests for PluginShop: the catalogue format the shop accepts, and the
|
||||
// bookkeeping that decides what an uninstall is allowed to delete. Parsing is
|
||||
// pure logic and the file half runs against a temporary directory, so no network
|
||||
// access and no real plugin is involved.
|
||||
#include "plugin-shop.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QSettings>
|
||||
#include <QString>
|
||||
#include <QTemporaryDir>
|
||||
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
|
||||
// The full field set, in both kinds, with an entry relying on the URL for the
|
||||
// file name.
|
||||
static void testCatalogIsParsed() {
|
||||
const QByteArray json = R"({
|
||||
"catalog": 1,
|
||||
"plugins": [
|
||||
{
|
||||
"id": "apt",
|
||||
"name": "APT",
|
||||
"kind": "provider",
|
||||
"version": "1.0.0",
|
||||
"author": "FWS",
|
||||
"description": "Gestionnaire de paquets Debian",
|
||||
"url": "https://example.org/plugins/libapt-provider.so",
|
||||
"sha256": "ABCDEF0123",
|
||||
"file": "libapt-provider.so"
|
||||
},
|
||||
{
|
||||
"id": "gnome-tweaks",
|
||||
"name": "GNOME Tweaks",
|
||||
"kind": "addon",
|
||||
"url": "https://example.org/plugins/libgnome-tweaks.so"
|
||||
}
|
||||
]
|
||||
})";
|
||||
|
||||
QString error;
|
||||
const std::vector<PluginShop::CatalogEntry> entries = PluginShop::parseCatalog(json, &error);
|
||||
|
||||
assert(error.isEmpty());
|
||||
assert(entries.size() == 2);
|
||||
|
||||
assert(entries[0].id == "apt");
|
||||
assert(entries[0].kind == "provider");
|
||||
assert(entries[0].fileName == "libapt-provider.so");
|
||||
// Checksums are compared case-insensitively, so they are stored lowercased.
|
||||
assert(entries[0].sha256 == "abcdef0123");
|
||||
|
||||
assert(entries[1].id == "gnome-tweaks");
|
||||
assert(entries[1].kind == "addon");
|
||||
// No "file": the name is taken from the URL when the plugin is installed.
|
||||
assert(entries[1].fileName.isEmpty());
|
||||
assert(entries[1].sha256.isEmpty());
|
||||
}
|
||||
|
||||
// A document that is not a catalogue must be refused as a whole, so the shop
|
||||
// never shows half a catalogue.
|
||||
static void testInvalidDocumentsAreRejected() {
|
||||
QString error;
|
||||
|
||||
assert(PluginShop::parseCatalog("{ not json", &error).empty());
|
||||
assert(!error.isEmpty());
|
||||
|
||||
error.clear();
|
||||
assert(PluginShop::parseCatalog("[]", &error).empty());
|
||||
assert(!error.isEmpty());
|
||||
|
||||
error.clear();
|
||||
assert(PluginShop::parseCatalog("{\"catalog\": 1}", &error).empty());
|
||||
assert(!error.isEmpty());
|
||||
}
|
||||
|
||||
// Entries that cannot be installed are skipped one by one: one broken line in
|
||||
// the catalogue does not hide the plugins that are fine.
|
||||
static void testIncompleteEntriesAreSkipped() {
|
||||
const QByteArray json = R"({
|
||||
"plugins": [
|
||||
{"id": "no-name", "url": "https://example.org/a.so"},
|
||||
{"id": "no-url", "name": "Sans URL"},
|
||||
{"name": "Sans identifiant", "url": "https://example.org/c.so"},
|
||||
"not an object",
|
||||
{"id": "ok", "name": "Complet", "url": "https://example.org/d.so",
|
||||
"kind": "autre chose"}
|
||||
]
|
||||
})";
|
||||
|
||||
QString error;
|
||||
const std::vector<PluginShop::CatalogEntry> entries = PluginShop::parseCatalog(json, &error);
|
||||
|
||||
assert(error.isEmpty());
|
||||
assert(entries.size() == 1);
|
||||
assert(entries[0].id == "ok");
|
||||
// An unknown kind is dropped rather than guessed: the loaded library
|
||||
// declares the real one.
|
||||
assert(entries[0].kind.isEmpty());
|
||||
}
|
||||
|
||||
// The shop only removes what it installed itself.
|
||||
static void testUninstallOnlyRemovesWhatItInstalled() {
|
||||
QTemporaryDir dir;
|
||||
PluginShop shop;
|
||||
shop.setInstallDirectory(dir.path() + "/plugins");
|
||||
|
||||
bool finished = false;
|
||||
bool success = true;
|
||||
QObject::connect(&shop, &PluginShop::removeFinished, &shop,
|
||||
[&](const QString&, bool ok, const QString&) {
|
||||
finished = true;
|
||||
success = ok;
|
||||
});
|
||||
|
||||
// Unknown entry: a removal must fail instead of deleting anything.
|
||||
assert(!shop.isInstalled("apt"));
|
||||
shop.remove("apt");
|
||||
assert(finished && !success);
|
||||
|
||||
// A plugin the shop installed: recorded path plus a file on disk. The key
|
||||
// is the one the shop writes (documented in doc/plugin-shop.md).
|
||||
const QString pluginsDir = dir.path() + "/plugins";
|
||||
assert(QDir().mkpath(pluginsDir));
|
||||
const QString path = pluginsDir + "/libapt-provider.so";
|
||||
QFile file(path);
|
||||
assert(file.open(QIODevice::WriteOnly));
|
||||
file.write("not a real shared library");
|
||||
file.close();
|
||||
|
||||
QSettings settings;
|
||||
settings.setValue("shop/installed/apt", path);
|
||||
settings.sync();
|
||||
|
||||
assert(shop.isInstalled("apt"));
|
||||
assert(shop.installedPath("apt") == path);
|
||||
|
||||
success = false;
|
||||
shop.remove("apt");
|
||||
assert(finished && success);
|
||||
assert(!QFile::exists(path));
|
||||
assert(!shop.isInstalled("apt"));
|
||||
}
|
||||
|
||||
// A file deleted by hand is not installed any more, even when the shop still
|
||||
// remembers it: the state follows the disk.
|
||||
static void testMissingFileCountsAsNotInstalled() {
|
||||
QTemporaryDir dir;
|
||||
PluginShop shop;
|
||||
shop.setInstallDirectory(dir.path() + "/plugins");
|
||||
|
||||
QSettings settings;
|
||||
settings.setValue("shop/installed/gone", dir.path() + "/plugins/libgone.so");
|
||||
settings.sync();
|
||||
|
||||
assert(!shop.isInstalled("gone"));
|
||||
assert(shop.installedPath("gone").isEmpty());
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
// The tests must not read or write the user's PacManager settings: an INI
|
||||
// file of their own, in a temporary directory, stands in for them.
|
||||
QTemporaryDir settingsDir;
|
||||
QSettings::setDefaultFormat(QSettings::IniFormat);
|
||||
QSettings::setPath(QSettings::IniFormat, QSettings::UserScope, settingsDir.path());
|
||||
|
||||
QCoreApplication app(argc, argv);
|
||||
app.setOrganizationName("PacManagerTests");
|
||||
app.setApplicationName("plugin-shop-test");
|
||||
|
||||
testCatalogIsParsed();
|
||||
testInvalidDocumentsAreRejected();
|
||||
testIncompleteEntriesAreSkipped();
|
||||
testUninstallOnlyRemovesWhatItInstalled();
|
||||
testMissingFileCountsAsNotInstalled();
|
||||
|
||||
std::cout << "All plugin-shop tests passed." << std::endl;
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user