Changeset View
Changeset View
Standalone View
Standalone View
autotests/kconfigtest.cpp
Show All 32 Lines | |||||
33 | #include <ksharedconfig.h> | 33 | #include <ksharedconfig.h> | ||
34 | #include <kconfiggroup.h> | 34 | #include <kconfiggroup.h> | ||
35 | #include <kconfigwatcher.h> | 35 | #include <kconfigwatcher.h> | ||
36 | 36 | | |||
37 | #ifdef Q_OS_UNIX | 37 | #ifdef Q_OS_UNIX | ||
38 | #include <utime.h> | 38 | #include <utime.h> | ||
39 | #endif | 39 | #endif | ||
40 | #ifndef Q_OS_WIN | 40 | #ifndef Q_OS_WIN | ||
41 | #include <unistd.h> // gethostname | 41 | #include <unistd.h> // getuid | ||
42 | #endif | 42 | #endif | ||
43 | 43 | | |||
44 | KCONFIGGROUP_DECLARE_ENUM_QOBJECT(KConfigTest, Testing) | 44 | KCONFIGGROUP_DECLARE_ENUM_QOBJECT(KConfigTest, Testing) | ||
45 | KCONFIGGROUP_DECLARE_FLAGS_QOBJECT(KConfigTest, Flags) | 45 | KCONFIGGROUP_DECLARE_FLAGS_QOBJECT(KConfigTest, Flags) | ||
46 | 46 | | |||
47 | QTEST_MAIN(KConfigTest) | 47 | QTEST_MAIN(KConfigTest) | ||
48 | 48 | | |||
49 | Q_DECLARE_METATYPE(KConfigGroup) | 49 | Q_DECLARE_METATYPE(KConfigGroup) | ||
▲ Show 20 Lines • Show All 472 Lines • ▼ Show 20 Line(s) | 518 | { | |||
522 | out.setCodec("UTF-8"); | 522 | out.setCodec("UTF-8"); | ||
523 | out << "[Test Group]" << endl | 523 | out << "[Test Group]" << endl | ||
524 | << "homePath=$HOME/foo" << endl | 524 | << "homePath=$HOME/foo" << endl | ||
525 | << "homePath2=file://$HOME/foo" << endl | 525 | << "homePath2=file://$HOME/foo" << endl | ||
526 | << "withSlash=$WITHSLASH/foo" << endl | 526 | << "withSlash=$WITHSLASH/foo" << endl | ||
527 | << "withSlash2=$WITHSLASH" << endl | 527 | << "withSlash2=$WITHSLASH" << endl | ||
528 | << "withBraces[$e]=file://${HOME}/foo" << endl | 528 | << "withBraces[$e]=file://${HOME}/foo" << endl | ||
529 | << "URL[$e]=file://${HOME}/foo" << endl | 529 | << "URL[$e]=file://${HOME}/foo" << endl | ||
530 | << "hostname[$e]=$(hostname)" << endl | | |||
mdawson: Instead of removing this test, can it instead be switched to verify the command execution does… | |||||
Hehe, that's what I did initially, and the value being read was (hostname) without the $ because of the way [$e] works. A bit surprising, but in line with the fact that $/ $? $@ etc would also remove the $ (because the code just sees an empty env var name), and if someone wanted to keep the $ they would have to write $$. So I concluded invalid testcase, nobody would write this anymore. But OK, it's a test about old files that might have this. I'll re-add the test. dfaure: Hehe, that's what I did initially, and the value being read was (hostname) without the $… | |||||
531 | << "escapes=aaa,bb/b,ccc\\,ccc" << endl | 530 | << "escapes=aaa,bb/b,ccc\\,ccc" << endl | ||
532 | << "noeol=foo" // no EOL | 531 | << "noeol=foo" // no EOL | ||
533 | ; | 532 | ; | ||
534 | } | 533 | } | ||
535 | KConfig cf2(TEST_SUBDIR "pathtest"); | 534 | KConfig cf2(TEST_SUBDIR "pathtest"); | ||
536 | KConfigGroup group = cf2.group("Test Group"); | 535 | KConfigGroup group = cf2.group("Test Group"); | ||
537 | QVERIFY(group.hasKey("homePath")); | 536 | QVERIFY(group.hasKey("homePath")); | ||
538 | QCOMPARE(group.readPathEntry("homePath", QString()), HOMEPATH); | 537 | QCOMPARE(group.readPathEntry("homePath", QString()), HOMEPATH); | ||
539 | QVERIFY(group.hasKey("homePath2")); | 538 | QVERIFY(group.hasKey("homePath2")); | ||
540 | QCOMPARE(group.readPathEntry("homePath2", QString()), QString("file://" + HOMEPATH)); | 539 | QCOMPARE(group.readPathEntry("homePath2", QString()), QString("file://" + HOMEPATH)); | ||
541 | QVERIFY(group.hasKey("withSlash")); | 540 | QVERIFY(group.hasKey("withSlash")); | ||
542 | QCOMPARE(group.readPathEntry("withSlash", QString()), QStringLiteral("/a//foo")); | 541 | QCOMPARE(group.readPathEntry("withSlash", QString()), QStringLiteral("/a//foo")); | ||
543 | QVERIFY(group.hasKey("withSlash2")); | 542 | QVERIFY(group.hasKey("withSlash2")); | ||
544 | QCOMPARE(group.readPathEntry("withSlash2", QString()), QStringLiteral("/a/")); | 543 | QCOMPARE(group.readPathEntry("withSlash2", QString()), QStringLiteral("/a/")); | ||
545 | QVERIFY(group.hasKey("withBraces")); | 544 | QVERIFY(group.hasKey("withBraces")); | ||
546 | QCOMPARE(group.readPathEntry("withBraces", QString()), QString("file://" + HOMEPATH)); | 545 | QCOMPARE(group.readPathEntry("withBraces", QString()), QString("file://" + HOMEPATH)); | ||
547 | QVERIFY(group.hasKey("URL")); | 546 | QVERIFY(group.hasKey("URL")); | ||
548 | QCOMPARE(group.readEntry("URL", QString()), QString("file://" + HOMEPATH)); | 547 | QCOMPARE(group.readEntry("URL", QString()), QString("file://" + HOMEPATH)); | ||
549 | #if !defined(Q_OS_WIN32) && !defined(Q_OS_MAC) | | |||
550 | // I don't know if this will work on windows | | |||
551 | // This test hangs on OS X | | |||
552 | QVERIFY(group.hasKey("hostname")); | | |||
553 | char hostname[256]; | | |||
554 | QVERIFY(::gethostname(hostname, sizeof(hostname)) == 0); | | |||
555 | QCOMPARE(group.readEntry("hostname", QString()), QString::fromLatin1(hostname)); | | |||
556 | #endif | | |||
557 | QVERIFY(group.hasKey("noeol")); | 548 | QVERIFY(group.hasKey("noeol")); | ||
558 | QCOMPARE(group.readEntry("noeol", QString()), QString("foo")); | 549 | QCOMPARE(group.readEntry("noeol", QString()), QString("foo")); | ||
559 | 550 | | |||
560 | const auto val = QStringList { QStringLiteral("aaa"), QStringLiteral("bb/b"), QStringLiteral("ccc,ccc")}; | 551 | const auto val = QStringList { QStringLiteral("aaa"), QStringLiteral("bb/b"), QStringLiteral("ccc,ccc")}; | ||
561 | QCOMPARE(group.readPathEntry("escapes", QStringList()), val); | 552 | QCOMPARE(group.readPathEntry("escapes", QStringList()), val); | ||
562 | } | 553 | } | ||
563 | 554 | | |||
564 | void KConfigTest::testPersistenceOfExpandFlagForPath() | 555 | void KConfigTest::testPersistenceOfExpandFlagForPath() | ||
▲ Show 20 Lines • Show All 1396 Lines • Show Last 20 Lines |
Instead of removing this test, can it instead be switched to verify the command execution does not occur?