You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gentoo-overlay/x11-misc/copyq/files/copyq-7.1.0-fix-test-failur...

99 lines
3.7 KiB

https://github.com/hluk/CopyQ/commit/42c02f2dc74b188ea7982a30c38acaf668bbf76a
From 42c02f2dc74b188ea7982a30c38acaf668bbf76a Mon Sep 17 00:00:00 2001
From: Lukas Holecek <hluk@email.cz>
Date: Mon, 4 Sep 2023 21:12:44 +0200
Subject: [PATCH] Avoid showing warnings about invalid regex
--- a/src/scriptable/scriptableitemselection.cpp
+++ b/src/scriptable/scriptableitemselection.cpp
@@ -46,10 +46,6 @@ QVector<int> toIntVector(const QJSValue &value)
QRegularExpression toRegularExpression(const QJSValue &value)
{
- // If argument is invalid/not-regexp, create an invalid regex to match nothing.
- if ( !value.isRegExp() )
- return QRegularExpression("(");
-
const QVariant variant = value.toVariant();
QRegularExpression regexp = variant.toRegularExpression();
@@ -136,7 +132,7 @@ QJSValue ScriptableItemSelection::selectAll()
QJSValue ScriptableItemSelection::select(const QJSValue &re, const QString &mimeFormat)
{
- const QVariant regexp = re.isUndefined() ? QVariant() : toRegularExpression(re);
+ const QVariant regexp = re.isRegExp() ? toRegularExpression(re) : QVariant();
m_proxy->selectionSelect(m_id, regexp, mimeFormat);
return m_self;
}
--- a/src/tests/testinterface.h
+++ b/src/tests/testinterface.h
@@ -85,9 +85,6 @@ class TestInterface {
/// Clean up tabs and items. Return error string on error.
virtual QByteArray cleanup() = 0;
- /// Ignore given text in logs for current unit test.
- virtual void setIgnoreError(const QByteArray &ignoreError) = 0;
-
/// Platform specific key to remove (usually Delete, Backspace on OS X).
virtual QString shortcutToRemove() = 0;
--- a/src/tests/tests.cpp
+++ b/src/tests/tests.cpp
@@ -150,8 +150,6 @@ bool testStderr(const QByteArray &stderrData, TestInterface::ReadStderrFlag flag
// Ignore exceptions and errors from clients in application log
// (these are expected in some tests).
static const std::vector<QRegularExpression> ignoreList{
- plain("[EXPECTED-IN-TEST]"),
-
regex(R"(CopyQ Note \[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{3}\] <Client-[^\n]*)"),
// X11 (Linux)
@@ -520,8 +518,6 @@ class TestInterfaceImpl final : public TestInterface {
if (m_server) {
QCoreApplication::processEvents();
QByteArray output = readLogFile(maxReadLogSize);
- if ( !m_ignoreError.isEmpty() )
- output.replace(m_ignoreError, "[EXPECTED-IN-TEST] " + m_ignoreError);
if ( flag == ReadAllStderr || !testStderr(output, flag) )
return decorateOutput("Server STDERR", output);
}
@@ -645,16 +641,10 @@ class TestInterfaceImpl final : public TestInterface {
QByteArray cleanup() override
{
- m_ignoreError.clear();
addFailedTest();
return QByteArray();
}
- void setIgnoreError(const QByteArray &ignoreError) override
- {
- m_ignoreError = ignoreError;
- }
-
QString shortcutToRemove() override
{
return ::shortcutToRemove();
@@ -771,8 +761,6 @@ class TestInterfaceImpl final : public TestInterface {
QStringList m_failed;
PlatformClipboardPtr m_clipboard;
-
- QByteArray m_ignoreError;
};
QString keyNameFor(QKeySequence::StandardKey standardKey)
@@ -2272,9 +2260,8 @@ void Tests::classItemSelection()
RUN(args << "ItemSelection().select(undefined, mimeItemNotes).str()", outRows.arg("0,2"));
// Match nothing if select() argument is not a regular expression.
- m_test->setIgnoreError("QtWarning: QString::contains: invalid QRegularExpression object");
+ RUN(args << "add" << "", "");
RUN(args << "ItemSelection().select('A').str()", outRows.arg(""));
- m_test->setIgnoreError(QByteArray());
}
void Tests::classItemSelectionGetCurrent()