[education/rkward] rkward: Ignore command line args during auotesting
Thomas Friedrichsmeier
null at kde.org
Sun Aug 31 13:51:37 BST 2025
Git commit 2711babbd98dd0046a639b61b477b1079d32f6cb by Thomas Friedrichsmeier.
Committed on 30/08/2025 at 21:38.
Pushed by tfry into branch 'master'.
Ignore command line args during auotesting
M +1 -1 rkward/autotests/core_test.cpp
M +7 -3 rkward/misc/rkcommandlineargs.cpp
M +2 -2 rkward/misc/rkcommandlineargs.h
https://invent.kde.org/education/rkward/-/commit/2711babbd98dd0046a639b61b477b1079d32f6cb
diff --git a/rkward/autotests/core_test.cpp b/rkward/autotests/core_test.cpp
index 8dc04d38d..f3f64cf45 100644
--- a/rkward/autotests/core_test.cpp
+++ b/rkward/autotests/core_test.cpp
@@ -180,7 +180,7 @@ class RKWardCoreTest : public QObject {
KLocalizedString::setApplicationDomain("rkward");
KAboutData about(QStringLiteral("rkward"), QStringLiteral("RKWard"), QStringLiteral(RKWARD_VERSION), QStringLiteral("Frontend to the R statistics language"), KAboutLicense::GPL); // component name needed for .rc files to load
KAboutData::setApplicationData(about);
- new RKCommandLineArgs(&about, qApp);
+ new RKCommandLineArgs(&about, qApp, true);
RK_Debug::RK_Debug_Level = DL_DEBUG;
testLog(R_EXECUTABLE);
RKSessionVars::r_binary = QStringLiteral(R_EXECUTABLE);
diff --git a/rkward/misc/rkcommandlineargs.cpp b/rkward/misc/rkcommandlineargs.cpp
index 67658e808..a8decf425 100644
--- a/rkward/misc/rkcommandlineargs.cpp
+++ b/rkward/misc/rkcommandlineargs.cpp
@@ -1,6 +1,6 @@
/*
rkcommandlineargs - This file is part of the RKWard project. Created: Tue May 21 2024
-SPDX-FileCopyrightText: 2024 by Thomas Friedrichsmeier <thomas.friedrichsmeier at kdemail.net>
+SPDX-FileCopyrightText: 2024-2025 by Thomas Friedrichsmeier <thomas.friedrichsmeier at kdemail.net>
SPDX-FileContributor: The RKWard Team <rkward-devel at kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
@@ -17,7 +17,7 @@ SPDX-License-Identifier: GPL-2.0-or-later
RKCommandLineArgs *RKCommandLineArgs::instance = nullptr;
-RKCommandLineArgs::RKCommandLineArgs(KAboutData *about, QCoreApplication *app) {
+RKCommandLineArgs::RKCommandLineArgs(KAboutData *about, QCoreApplication *app, bool fake_for_autotests) {
RK_TRACE(MISC);
RK_ASSERT(instance == nullptr);
@@ -38,7 +38,11 @@ RKCommandLineArgs::RKCommandLineArgs(KAboutData *about, QCoreApplication *app) {
parser.addOption(QCommandLineOption(QStringLiteral("setup"), i18n("Act as if the version of RKWard had changed (show setup wizard, and (re-)install rkward R package).")));
parser.addPositionalArgument(QStringLiteral("files"), i18n("File or files to open, typically a workspace, or an R script file. When loading several things, you should specify the workspace, first."), QStringLiteral("[Files...]"));
- parser.process(*app);
+ if (fake_for_autotests) {
+ parser.parse(app->arguments().mid(0, 1));
+ } else {
+ parser.process(*app);
+ }
about->processCommandLine(&parser);
storage.resize(NUM_OPTIONS);
diff --git a/rkward/misc/rkcommandlineargs.h b/rkward/misc/rkcommandlineargs.h
index b28cb68e2..da2e3c42a 100644
--- a/rkward/misc/rkcommandlineargs.h
+++ b/rkward/misc/rkcommandlineargs.h
@@ -1,6 +1,6 @@
/*
rkcommandlineargs - This file is part of the RKWard project. Created: Tue May 21 2024
-SPDX-FileCopyrightText: 2024 by Thomas Friedrichsmeier <thomas.friedrichsmeier at kdemail.net>
+SPDX-FileCopyrightText: 2024-2025 by Thomas Friedrichsmeier <thomas.friedrichsmeier at kdemail.net>
SPDX-FileContributor: The RKWard Team <rkward-devel at kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
@@ -18,7 +18,7 @@ class QCoreApplication;
class RKCommandLineArgs {
public:
- explicit RKCommandLineArgs(KAboutData *about, QCoreApplication *app);
+ explicit RKCommandLineArgs(KAboutData *about, QCoreApplication *app, bool fake_for_autotests = false);
~RKCommandLineArgs() {};
enum Option {
UrlArgs,
More information about the rkward-tracker
mailing list