From 2c3617dfcb4a5230f51f2d2b2eac0e1fb26206cd Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Mon, 4 Oct 2021 17:16:51 +0200 Subject: [PATCH] Always enable QRegularExpression's JIT when testing Given on most CI configurations we run tests only on debug builds, this means that effectively we don't test JIT paths (JIT is kept disabled in debug builds). To keep it enabled in a test, we have a few options: * export a developer-build-only variable from QtCore, to force JIT usage, and set it in the test. This is still suboptimal as many configurations aren't using developer builds in the first place; * use the already existing QT_REGEXP_USE_JIT environment variable, setting it from CMake/CTest. The problem here is that although add_test does support it, we don't expose it through our wrapper functions; * just set that env variable from within the test itself. I went for this option. Change-Id: I73abfb7fc0d76ec77e881f24c5daf5be304ab948 Reviewed-by: Thiago Macieira --- .../qregularexpression/tst_qregularexpression.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/auto/corelib/text/qregularexpression/tst_qregularexpression.cpp b/tests/auto/corelib/text/qregularexpression/tst_qregularexpression.cpp index 684727758c3..6d844c18440 100644 --- a/tests/auto/corelib/text/qregularexpression/tst_qregularexpression.cpp +++ b/tests/auto/corelib/text/qregularexpression/tst_qregularexpression.cpp @@ -37,6 +37,7 @@ #include #include +#include #include Q_DECLARE_METATYPE(QRegularExpression::PatternOptions) @@ -47,6 +48,9 @@ class tst_QRegularExpression : public QObject { Q_OBJECT +public: + static void initMain(); + private slots: void defaultConstructors(); void moveSemantics(); @@ -469,6 +473,16 @@ void tst_QRegularExpression::provideRegularExpressions() | QRegularExpression::InvertedGreedinessOption); } +static const char enableJitEnvironmentVariable[] = "QT_ENABLE_REGEXP_JIT"; + +void tst_QRegularExpression::initMain() +{ + if (!qEnvironmentVariableIsSet(enableJitEnvironmentVariable)) { + std::cerr << "Enabling QRegularExpression JIT for testing; set QT_ENABLE_REGEXP_JIT to 0 to disable it.\n"; + qputenv(enableJitEnvironmentVariable, "1"); + } +} + void tst_QRegularExpression::defaultConstructors() { QRegularExpression re;