Fix tst_qlocale compilation when jalalicalendar is disabled
The 'syslocaleapp' test helper application was built only when jalalicalendar is enabled. The tst_qlocale on the other hand depends on 'syslocaleapp' if process-support is enabled. Thus if jalalicalendar was disabled and process-support enabled, the CMake configure fails because tst_qlocale won't meet its 'syslocaleapp' dependency. Fix by building a more limited version of the syslocaleapp when jalalicalendar isn't supported, and adjust the testcase accordingly. Pick-to: 6.9 6.8 Task-number: QTBUG-136101 Change-Id: Ic809b0124d47754105ca09b69e2b3c12856ba63a Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
parent
776dbdce7b
commit
3bbe9d8ec7
@ -8,6 +8,6 @@ if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_subdirectory(test)
|
add_subdirectory(test)
|
||||||
if(QT_FEATURE_jalalicalendar)
|
if(QT_FEATURE_process)
|
||||||
add_subdirectory(syslocaleapp)
|
add_subdirectory(syslocaleapp)
|
||||||
endif()
|
endif()
|
||||||
|
@ -11,11 +11,15 @@ int main(int argc, char** argv)
|
|||||||
// Setting a default locale should not mess up the system one.
|
// Setting a default locale should not mess up the system one.
|
||||||
QLocale::setDefault(QLocale::Persian);
|
QLocale::setDefault(QLocale::Persian);
|
||||||
QLocale l = QLocale::system();
|
QLocale l = QLocale::system();
|
||||||
|
QTextStream str(stdout);
|
||||||
|
#if QT_CONFIG(jalalicalendar)
|
||||||
// A non-Roman calendar will use CLDR data instead of system data, so needs
|
// A non-Roman calendar will use CLDR data instead of system data, so needs
|
||||||
// to have got the right locale index to look that up.
|
// to have got the right locale index to look that up.
|
||||||
QCalendar cal = QCalendar(QCalendar::System::Jalali);
|
QCalendar cal = QCalendar(QCalendar::System::Jalali);
|
||||||
QTextStream str(stdout);
|
|
||||||
str << l.name() << ' ' << cal.standaloneMonthName(l, 2);
|
str << l.name() << ' ' << cal.standaloneMonthName(l, 2);
|
||||||
|
#else
|
||||||
|
str << l.name();
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -664,7 +664,13 @@ void tst_QLocale::systemLocale_data()
|
|||||||
|
|
||||||
QTest::addColumn<QString>("expected");
|
QTest::addColumn<QString>("expected");
|
||||||
|
|
||||||
#define ADD_CTOR_TEST(give, expect) QTest::newRow(give) << QStringLiteral(expect);
|
#if QT_CONFIG(jalalicalendar)
|
||||||
|
#define ADD_CTOR_TEST(input, localePart, monthName) \
|
||||||
|
QTest::newRow(input) << QStringLiteral(localePart) + " "_L1 + QStringLiteral(monthName);
|
||||||
|
#else
|
||||||
|
#define ADD_CTOR_TEST(input, localePart, monthName) \
|
||||||
|
QTest::newRow(input) << QStringLiteral(localePart);
|
||||||
|
#endif
|
||||||
|
|
||||||
// For format and meaning, see:
|
// For format and meaning, see:
|
||||||
// http://pubs.opengroup.org/onlinepubs/7908799/xbd/envvar.html
|
// http://pubs.opengroup.org/onlinepubs/7908799/xbd/envvar.html
|
||||||
@ -676,44 +682,44 @@ void tst_QLocale::systemLocale_data()
|
|||||||
// setDefault(Persian) has interfered with the system locale setup.
|
// setDefault(Persian) has interfered with the system locale setup.
|
||||||
|
|
||||||
// Vanilla:
|
// Vanilla:
|
||||||
ADD_CTOR_TEST("C", "C Ordibehesht");
|
ADD_CTOR_TEST("C", "C", "Ordibehesht");
|
||||||
|
|
||||||
// Standard forms:
|
// Standard forms:
|
||||||
ADD_CTOR_TEST("en", "en_US Ordibehesht");
|
ADD_CTOR_TEST("en", "en_US", "Ordibehesht");
|
||||||
ADD_CTOR_TEST("en_GB", "en_GB Ordibehesht");
|
ADD_CTOR_TEST("en_GB", "en_GB", "Ordibehesht");
|
||||||
ADD_CTOR_TEST("de", "de_DE Ordibehescht");
|
ADD_CTOR_TEST("de", "de_DE", "Ordibehescht");
|
||||||
// Norsk has some quirks:
|
// Norsk has some quirks:
|
||||||
ADD_CTOR_TEST("no", "nb_NO ordibehesht");
|
ADD_CTOR_TEST("no", "nb_NO", "ordibehesht");
|
||||||
ADD_CTOR_TEST("nb", "nb_NO ordibehesht");
|
ADD_CTOR_TEST("nb", "nb_NO", "ordibehesht");
|
||||||
ADD_CTOR_TEST("nn", "nn_NO ordibehesht");
|
ADD_CTOR_TEST("nn", "nn_NO", "ordibehesht");
|
||||||
ADD_CTOR_TEST("no_NO", "nb_NO ordibehesht");
|
ADD_CTOR_TEST("no_NO", "nb_NO", "ordibehesht");
|
||||||
ADD_CTOR_TEST("nb_NO", "nb_NO ordibehesht");
|
ADD_CTOR_TEST("nb_NO", "nb_NO", "ordibehesht");
|
||||||
ADD_CTOR_TEST("nn_NO", "nn_NO ordibehesht");
|
ADD_CTOR_TEST("nn_NO", "nn_NO", "ordibehesht");
|
||||||
|
|
||||||
// Not too fussy about case:
|
// Not too fussy about case:
|
||||||
ADD_CTOR_TEST("DE", "de_DE Ordibehescht");
|
ADD_CTOR_TEST("DE", "de_DE", "Ordibehescht");
|
||||||
ADD_CTOR_TEST("EN", "en_US Ordibehesht");
|
ADD_CTOR_TEST("EN", "en_US", "Ordibehesht");
|
||||||
|
|
||||||
// Invalid fields
|
// Invalid fields
|
||||||
ADD_CTOR_TEST("bla", "C Ordibehesht");
|
ADD_CTOR_TEST("bla", "C", "Ordibehesht");
|
||||||
ADD_CTOR_TEST("zz", "C Ordibehesht");
|
ADD_CTOR_TEST("zz", "C", "Ordibehesht");
|
||||||
ADD_CTOR_TEST("zz_zz", "C Ordibehesht");
|
ADD_CTOR_TEST("zz_zz", "C", "Ordibehesht");
|
||||||
ADD_CTOR_TEST("zz...", "C Ordibehesht");
|
ADD_CTOR_TEST("zz...", "C", "Ordibehesht");
|
||||||
ADD_CTOR_TEST("en.bla", "en_US Ordibehesht");
|
ADD_CTOR_TEST("en.bla", "en_US", "Ordibehesht");
|
||||||
ADD_CTOR_TEST("en@bla", "en_US Ordibehesht");
|
ADD_CTOR_TEST("en@bla", "en_US", "Ordibehesht");
|
||||||
ADD_CTOR_TEST("en_blaaa", "en_US Ordibehesht");
|
ADD_CTOR_TEST("en_blaaa", "en_US", "Ordibehesht");
|
||||||
ADD_CTOR_TEST("en_zz", "en_US Ordibehesht");
|
ADD_CTOR_TEST("en_zz", "en_US", "Ordibehesht");
|
||||||
ADD_CTOR_TEST("en_GB.bla", "en_GB Ordibehesht");
|
ADD_CTOR_TEST("en_GB.bla", "en_GB", "Ordibehesht");
|
||||||
ADD_CTOR_TEST("en_GB@.bla", "en_GB Ordibehesht");
|
ADD_CTOR_TEST("en_GB@.bla", "en_GB", "Ordibehesht");
|
||||||
ADD_CTOR_TEST("en_GB@bla", "en_GB Ordibehesht");
|
ADD_CTOR_TEST("en_GB@bla", "en_GB", "Ordibehesht");
|
||||||
|
|
||||||
// Empty optional fields, but with punctuators supplied
|
// Empty optional fields, but with punctuators supplied
|
||||||
ADD_CTOR_TEST("en.", "en_US Ordibehesht");
|
ADD_CTOR_TEST("en.", "en_US", "Ordibehesht");
|
||||||
ADD_CTOR_TEST("en@", "en_US Ordibehesht");
|
ADD_CTOR_TEST("en@", "en_US", "Ordibehesht");
|
||||||
ADD_CTOR_TEST("en.@", "en_US Ordibehesht");
|
ADD_CTOR_TEST("en.@", "en_US", "Ordibehesht");
|
||||||
ADD_CTOR_TEST("en_", "en_US Ordibehesht");
|
ADD_CTOR_TEST("en_", "en_US", "Ordibehesht");
|
||||||
ADD_CTOR_TEST("en_.", "en_US Ordibehesht");
|
ADD_CTOR_TEST("en_.", "en_US", "Ordibehesht");
|
||||||
ADD_CTOR_TEST("en_.@", "en_US Ordibehesht");
|
ADD_CTOR_TEST("en_.@", "en_US", "Ordibehesht");
|
||||||
#undef ADD_CTOR_TEST
|
#undef ADD_CTOR_TEST
|
||||||
|
|
||||||
#if QT_CONFIG(process) // for runSysApp
|
#if QT_CONFIG(process) // for runSysApp
|
||||||
@ -722,7 +728,11 @@ void tst_QLocale::systemLocale_data()
|
|||||||
QString errorMessage;
|
QString errorMessage;
|
||||||
if (runSysApp(m_sysapp, QStringList(), cleanEnv, &defaultLoc, &errorMessage)) {
|
if (runSysApp(m_sysapp, QStringList(), cleanEnv, &defaultLoc, &errorMessage)) {
|
||||||
#if defined(Q_OS_MACOS)
|
#if defined(Q_OS_MACOS)
|
||||||
|
#if QT_CONFIG(jalalicalendar)
|
||||||
QString localeForInvalidLocale = "C Ordibehesht";
|
QString localeForInvalidLocale = "C Ordibehesht";
|
||||||
|
#else
|
||||||
|
QString localeForInvalidLocale = "C";
|
||||||
|
#endif // QT_CONFIG(jalalicalendar)
|
||||||
#else
|
#else
|
||||||
QString localeForInvalidLocale = defaultLoc;
|
QString localeForInvalidLocale = defaultLoc;
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user