diff --git a/tests/auto/corelib/thread/qpromise/tst_qpromise.cpp b/tests/auto/corelib/thread/qpromise/tst_qpromise.cpp index 2c12e41c934..c88e2a0a211 100644 --- a/tests/auto/corelib/thread/qpromise/tst_qpromise.cpp +++ b/tests/auto/corelib/thread/qpromise/tst_qpromise.cpp @@ -86,7 +86,6 @@ do { \ QFAIL("Test case " #test "(" #__VA_ARGS__ ") failed"); \ } while (false) -#if QT_CONFIG(cxx11_future) // std::thread-like wrapper that ensures that the thread is joined at the end of // a scope to prevent potential std::terminate struct ThreadWrapper @@ -103,7 +102,6 @@ struct ThreadWrapper t->wait(); } }; -#endif void tst_QPromise::promise() { @@ -344,7 +342,9 @@ void tst_QPromise::progress() void tst_QPromise::addInThread() { -#if QT_CONFIG(cxx11_future) +#if !QT_CONFIG(cxx11_future) + QSKIP("This test requires C++11 std threading enabled (and working) in the standard library."); +#endif const auto testAddResult = [] (auto promise, const auto &result) { promise.start(); auto f = promise.future(); @@ -360,12 +360,13 @@ void tst_QPromise::addInThread() RUN_TEST_FUNC(testAddResult, QPromise(), 42); RUN_TEST_FUNC(testAddResult, QPromise(), u8"42"); RUN_TEST_FUNC(testAddResult, QPromise(), CopyOnlyType{99}); -#endif } void tst_QPromise::addInThreadMoveOnlyObject() { -#if QT_CONFIG(cxx11_future) +#if !QT_CONFIG(cxx11_future) + QSKIP("This test requires C++11 std threading enabled (and working) in the standard library."); +#endif QPromise promise; promise.start(); auto f = promise.future(); @@ -377,12 +378,13 @@ void tst_QPromise::addInThreadMoveOnlyObject() // Iterators wait for result first for (auto& result : f) QCOMPARE(result, MoveOnlyType{-11}); -#endif } void tst_QPromise::reportFromMultipleThreads() { -#if QT_CONFIG(cxx11_future) +#if !QT_CONFIG(cxx11_future) + QSKIP("This test requires C++11 std threading enabled (and working) in the standard library."); +#endif QPromise promise; auto f = promise.future(); promise.start(); @@ -401,12 +403,13 @@ void tst_QPromise::reportFromMultipleThreads() QVERIFY(std::find(expected.begin(), expected.end(), actual) != expected.end()); expected.removeOne(actual); } -#endif } void tst_QPromise::reportFromMultipleThreadsByMovedPromise() { -#if QT_CONFIG(cxx11_future) +#if !QT_CONFIG(cxx11_future) + QSKIP("This test requires C++11 std threading enabled (and working) in the standard library."); +#endif QPromise initialPromise; auto f = initialPromise.future(); { @@ -433,12 +436,13 @@ void tst_QPromise::reportFromMultipleThreadsByMovedPromise() QVERIFY(std::find(expected.begin(), expected.end(), actual) != expected.end()); expected.removeOne(actual); } -#endif } void tst_QPromise::doNotCancelWhenFinished() { -#if QT_CONFIG(cxx11_future) +#if !QT_CONFIG(cxx11_future) + QSKIP("This test requires C++11 std threading enabled (and working) in the standard library."); +#endif const auto testFinishedPromise = [] (auto promise) { auto f = promise.future(); promise.start(); @@ -457,13 +461,14 @@ void tst_QPromise::doNotCancelWhenFinished() RUN_TEST_FUNC(testFinishedPromise, QPromise()); RUN_TEST_FUNC(testFinishedPromise, QPromise()); RUN_TEST_FUNC(testFinishedPromise, QPromise()); -#endif } #ifndef QT_NO_EXCEPTIONS void tst_QPromise::cancelWhenDestroyed() { -#if QT_CONFIG(cxx11_future) +#if !QT_CONFIG(cxx11_future) + QSKIP("This test requires C++11 std threading enabled (and working) in the standard library."); +#endif QPromise initialPromise; auto f = initialPromise.future(); @@ -491,13 +496,14 @@ void tst_QPromise::cancelWhenDestroyed() QVERIFY(std::find(expected.begin(), expected.end(), actual) != expected.end()); expected.removeOne(actual); } -#endif } #endif void tst_QPromise::cancelWhenReassigned() { -#if QT_CONFIG(cxx11_future) +#if !QT_CONFIG(cxx11_future) + QSKIP("This test requires C++11 std threading enabled (and working) in the standard library."); +#endif QPromise promise; auto f = promise.future(); promise.start(); @@ -511,7 +517,6 @@ void tst_QPromise::cancelWhenReassigned() QCOMPARE(f.isFinished(), true); QCOMPARE(f.isCanceled(), true); -#endif } template @@ -630,7 +635,9 @@ void tst_QPromise::continuationsRunWhenFinished() void tst_QPromise::finishWhenSwapped() { -#if QT_CONFIG(cxx11_future) +#if !QT_CONFIG(cxx11_future) + QSKIP("This test requires C++11 std threading enabled (and working) in the standard library."); +#endif QPromise promise1; auto f1 = promise1.future(); promise1.start(); @@ -665,13 +672,14 @@ void tst_QPromise::finishWhenSwapped() QCOMPARE(f2.resultAt(0), 1); QCOMPARE(f2.resultAt(1), 2); -#endif } template void testCancelWhenMoved() { -#if QT_CONFIG(cxx11_future) +#if !QT_CONFIG(cxx11_future) + QSKIP("This test requires C++11 std threading enabled (and working) in the standard library."); +#endif QPromise promise1; auto f1 = promise1.future(); promise1.start(); @@ -697,7 +705,6 @@ void testCancelWhenMoved() // Future #2 is explicitly finished inside thread QCOMPARE(f2.isFinished(), true); QCOMPARE(f2.isCanceled(), false); -#endif } void tst_QPromise::cancelWhenMoved() @@ -739,7 +746,9 @@ void tst_QPromise::waitUntilResumed() void tst_QPromise::waitUntilCanceled() { -#if QT_CONFIG(cxx11_future) +#if !QT_CONFIG(cxx11_future) + QSKIP("This test requires C++11 std threading enabled (and working) in the standard library."); +#endif QPromise promise; promise.start(); auto f = promise.future(); @@ -760,7 +769,6 @@ void tst_QPromise::waitUntilCanceled() f.waitForFinished(); QCOMPARE(f.resultCount(), 0); -#endif } // Below is a quick and dirty hack to make snippets a part of a test suite