Simplify tests directory structure

This commit is contained in:
Simon Brunel 2020-02-08 10:02:13 +01:00
parent 1ad99391a3
commit d5a82518f9
61 changed files with 86 additions and 183 deletions

View File

@ -17,6 +17,7 @@ function(qtpromise_add_test NAME)
endif() endif()
target_link_libraries(${_TARGET} target_link_libraries(${_TARGET}
Qt5::Concurrent
Qt5::Test Qt5::Test
qtpromise qtpromise
qtpromise.tests.utils qtpromise.tests.utils
@ -28,3 +29,16 @@ function(qtpromise_add_test NAME)
WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
) )
endfunction() endfunction()
function(qtpromise_add_tests GROUP)
cmake_parse_arguments(_ARG "" "" "SOURCES" ${ARGN})
foreach(_FILE ${_ARG_SOURCES})
get_filename_component(_FILE_NAME ${_FILE} NAME)
if (_FILE_NAME MATCHES "^tst_(.+)\.cpp$")
string(REGEX REPLACE "^tst_(.+)\.cpp$" "\\1" _TEST_NAME ${_FILE_NAME})
qtpromise_add_test(${GROUP}.${_TEST_NAME} SOURCES ${_FILE} ${_ARG_UNPARSED_ARGUMENTS})
endif()
endforeach()
endfunction()

View File

@ -5,5 +5,9 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
add_compile_options(/wd4996) add_compile_options(/wd4996)
endif() endif()
add_subdirectory(helpers) qtpromise_add_tests(deprecation
add_subdirectory(qpromise) SOURCES
tst_helpers_qpromise.cpp
tst_helpers_qpromiseall.cpp
tst_qpromise_all.cpp
)

View File

@ -1,2 +0,0 @@
add_subdirectory(qpromise)
add_subdirectory(qpromiseall)

View File

@ -1,6 +0,0 @@
qtpromise_add_test(deprecations.helpers.qpromise
SOURCES
tst_qpromise.cpp
LIBRARIES
Qt5::Concurrent
)

View File

@ -1,4 +0,0 @@
qtpromise_add_test(deprecations.helpers.qpromiseall
SOURCES
tst_qpromiseall.cpp
)

View File

@ -1 +0,0 @@
add_subdirectory(all)

View File

@ -1,4 +0,0 @@
qtpromise_add_test(deprecations.qpromise.all
SOURCES
tst_all.cpp
)

View File

@ -5,8 +5,8 @@
* the LICENSE file in the root directory of this source tree. * the LICENSE file in the root directory of this source tree.
*/ */
#include "../../../shared/data.h" #include "../shared/data.h"
#include "../../../shared/utils.h" #include "../shared/utils.h"
// QtPromise // QtPromise
#include <QtPromise> #include <QtPromise>
@ -38,7 +38,7 @@ private Q_SLOTS:
}; };
QTEST_MAIN(tst_deprecations_helpers_qpromise) QTEST_MAIN(tst_deprecations_helpers_qpromise)
#include "tst_qpromise.moc" #include "tst_helpers_qpromise.moc"
void tst_deprecations_helpers_qpromise::value() void tst_deprecations_helpers_qpromise::value()
{ {

View File

@ -5,7 +5,7 @@
* the LICENSE file in the root directory of this source tree. * the LICENSE file in the root directory of this source tree.
*/ */
#include "../../../shared/utils.h" #include "../shared/utils.h"
// QtPromise // QtPromise
#include <QtPromise> #include <QtPromise>
@ -32,7 +32,7 @@ private Q_SLOTS:
}; };
QTEST_MAIN(tst_deprecations_helpers_qpromiseall) QTEST_MAIN(tst_deprecations_helpers_qpromiseall)
#include "tst_qpromiseall.moc" #include "tst_helpers_qpromiseall.moc"
namespace { namespace {

View File

@ -5,7 +5,7 @@
* the LICENSE file in the root directory of this source tree. * the LICENSE file in the root directory of this source tree.
*/ */
#include "../../../shared/utils.h" #include "../shared/utils.h"
// QtPromise // QtPromise
#include <QtPromise> #include <QtPromise>
@ -32,7 +32,7 @@ private Q_SLOTS:
}; };
QTEST_MAIN(tst_deprecations_qpromise_all) QTEST_MAIN(tst_deprecations_qpromise_all)
#include "tst_all.moc" #include "tst_qpromise_all.moc"
namespace { namespace {

View File

@ -1,6 +1,4 @@
qtpromise_add_test(exceptions qtpromise_add_test(exceptions
SOURCES SOURCES
tst_exceptions.cpp tst_exceptions.cpp
LIBRARIES
Qt5::Concurrent
) )

View File

@ -1,6 +1,4 @@
qtpromise_add_test(future qtpromise_add_test(future
SOURCES SOURCES
tst_future.cpp tst_future.cpp
LIBRARIES
Qt5::Concurrent
) )

View File

@ -1,9 +1,12 @@
add_subdirectory(all) qtpromise_add_tests(helpers
add_subdirectory(attempt) SOURCES
add_subdirectory(connect) tst_all.cpp
add_subdirectory(each) tst_attempt.cpp
add_subdirectory(filter) tst_connect.cpp
add_subdirectory(map) tst_each.cpp
add_subdirectory(reduce) tst_filter.cpp
add_subdirectory(reject) tst_map.cpp
add_subdirectory(resolve) tst_reduce.cpp
tst_reject.cpp
tst_resolve.cpp
)

View File

@ -1,4 +0,0 @@
qtpromise_add_test(helpers.all
SOURCES
tst_all.cpp
)

View File

@ -1,6 +0,0 @@
qtpromise_add_test(helpers.attempt
SOURCES
tst_attempt.cpp
LIBRARIES
Qt5::Concurrent
)

View File

@ -1,4 +0,0 @@
qtpromise_add_test(helpers.connect
SOURCES
tst_connect.cpp
)

View File

@ -1,4 +0,0 @@
qtpromise_add_test(helpers.each
SOURCES
tst_each.cpp
)

View File

@ -1,4 +0,0 @@
qtpromise_add_test(helpers.filter
SOURCES
tst_filter.cpp
)

View File

@ -1,4 +0,0 @@
qtpromise_add_test(helpers.map
SOURCES
tst_map.cpp
)

View File

@ -1,4 +0,0 @@
qtpromise_add_test(helpers.reduce
SOURCES
tst_reduce.cpp
)

View File

@ -1,4 +0,0 @@
qtpromise_add_test(helpers.reject
SOURCES
tst_reject.cpp
)

View File

@ -1,6 +0,0 @@
qtpromise_add_test(helpers.resolve
SOURCES
tst_resolve.cpp
LIBRARIES
Qt5::Concurrent
)

View File

@ -5,7 +5,7 @@
* the LICENSE file in the root directory of this source tree. * the LICENSE file in the root directory of this source tree.
*/ */
#include "../../shared/utils.h" #include "../shared/utils.h"
// QtPromise // QtPromise
#include <QtPromise> #include <QtPromise>

View File

@ -5,7 +5,7 @@
* the LICENSE file in the root directory of this source tree. * the LICENSE file in the root directory of this source tree.
*/ */
#include "../../shared/utils.h" #include "../shared/utils.h"
// QtPromise // QtPromise
#include <QtPromise> #include <QtPromise>

View File

@ -5,8 +5,8 @@
* the LICENSE file in the root directory of this source tree. * the LICENSE file in the root directory of this source tree.
*/ */
#include "../../shared/object.h" #include "../shared/object.h"
#include "../../shared/utils.h" #include "../shared/utils.h"
// QtPromise // QtPromise
#include <QtPromise> #include <QtPromise>

View File

@ -5,7 +5,7 @@
* the LICENSE file in the root directory of this source tree. * the LICENSE file in the root directory of this source tree.
*/ */
#include "../../shared/utils.h" #include "../shared/utils.h"
// QtPromise // QtPromise
#include <QtPromise> #include <QtPromise>

View File

@ -5,12 +5,13 @@
* the LICENSE file in the root directory of this source tree. * the LICENSE file in the root directory of this source tree.
*/ */
#include "../../shared/utils.h" #include "../shared/utils.h"
// QtPromise // QtPromise
#include <QtPromise> #include <QtPromise>
// Qt // Qt
#include <QtConcurrent>
#include <QtTest> #include <QtTest>
using namespace QtPromise; using namespace QtPromise;
@ -52,8 +53,6 @@ struct SequenceTester
} // anonymous namespace } // anonymous namespace
#include <QtConcurrent/QtConcurrent>
void tst_helpers_filter::emptySequence() void tst_helpers_filter::emptySequence()
{ {
auto p = QtPromise::filter(QVector<int>{}, [](int v, ...) { auto p = QtPromise::filter(QVector<int>{}, [](int v, ...) {

View File

@ -5,7 +5,7 @@
* the LICENSE file in the root directory of this source tree. * the LICENSE file in the root directory of this source tree.
*/ */
#include "../../shared/utils.h" #include "../shared/utils.h"
// QtPromise // QtPromise
#include <QtPromise> #include <QtPromise>

View File

@ -5,8 +5,8 @@
* the LICENSE file in the root directory of this source tree. * the LICENSE file in the root directory of this source tree.
*/ */
#include "../../shared/data.h" #include "../shared/data.h"
#include "../../shared/utils.h" #include "../shared/utils.h"
// QtPromise // QtPromise
#include <QtPromise> #include <QtPromise>

View File

@ -5,7 +5,7 @@
* the LICENSE file in the root directory of this source tree. * the LICENSE file in the root directory of this source tree.
*/ */
#include "../../shared/utils.h" #include "../shared/utils.h"
// QtPromise // QtPromise
#include <QtPromise> #include <QtPromise>

View File

@ -5,8 +5,8 @@
* the LICENSE file in the root directory of this source tree. * the LICENSE file in the root directory of this source tree.
*/ */
#include "../../shared/data.h" #include "../shared/data.h"
#include "../../shared/utils.h" #include "../shared/utils.h"
// QtPromise // QtPromise
#include <QtPromise> #include <QtPromise>

View File

@ -1,14 +1,17 @@
add_subdirectory(construct) qtpromise_add_tests(qpromise
add_subdirectory(delay) SOURCES
add_subdirectory(each) tst_construct.cpp
add_subdirectory(fail) tst_delay.cpp
add_subdirectory(filter) tst_each.cpp
add_subdirectory(finally) tst_fail.cpp
add_subdirectory(map) tst_filter.cpp
add_subdirectory(operators) tst_finally.cpp
add_subdirectory(reduce) tst_map.cpp
add_subdirectory(resolve) tst_operators.cpp
add_subdirectory(tap) tst_reduce.cpp
add_subdirectory(tapfail) tst_resolve.cpp
add_subdirectory(then) tst_tap.cpp
add_subdirectory(timeout) tst_tapfail.cpp
tst_then.cpp
tst_timeout.cpp
)

View File

@ -1,4 +0,0 @@
qtpromise_add_test(qpromise.construct
SOURCES
tst_construct.cpp
)

View File

@ -1,4 +0,0 @@
qtpromise_add_test(qpromise.delay
SOURCES
tst_delay.cpp
)

View File

@ -1,4 +0,0 @@
qtpromise_add_test(qpromise.each
SOURCES
tst_each.cpp
)

View File

@ -1,4 +0,0 @@
qtpromise_add_test(qpromise.fail
SOURCES
tst_fail.cpp
)

View File

@ -1,4 +0,0 @@
qtpromise_add_test(qpromise.filter
SOURCES
tst_filter.cpp
)

View File

@ -1,4 +0,0 @@
qtpromise_add_test(qpromise.finally
SOURCES
tst_finally.cpp
)

View File

@ -1,4 +0,0 @@
qtpromise_add_test(qpromise.map
SOURCES
tst_map.cpp
)

View File

@ -1,4 +0,0 @@
qtpromise_add_test(qpromise.operators
SOURCES
tst_operators.cpp
)

View File

@ -1,4 +0,0 @@
qtpromise_add_test(qpromise.reduce
SOURCES
tst_reduce.cpp
)

View File

@ -1,4 +0,0 @@
qtpromise_add_test(qpromise.resolve
SOURCES
tst_resolve.cpp
)

View File

@ -1,4 +0,0 @@
qtpromise_add_test(qpromise.tap
SOURCES
tst_tap.cpp
)

View File

@ -1,4 +0,0 @@
qtpromise_add_test(qpromise.tapfail
SOURCES
tst_tapfail.cpp
)

View File

@ -1,4 +0,0 @@
qtpromise_add_test(qpromise.then
SOURCES
tst_then.cpp
)

View File

@ -1,4 +0,0 @@
qtpromise_add_test(qpromise.timeout
SOURCES
tst_timeout.cpp
)

View File

@ -5,7 +5,7 @@
* the LICENSE file in the root directory of this source tree. * the LICENSE file in the root directory of this source tree.
*/ */
#include "../../shared/utils.h" #include "../shared/utils.h"
// QtPromise // QtPromise
#include <QtPromise> #include <QtPromise>

View File

@ -5,7 +5,7 @@
* the LICENSE file in the root directory of this source tree. * the LICENSE file in the root directory of this source tree.
*/ */
#include "../../shared/utils.h" #include "../shared/utils.h"
// QtPromise // QtPromise
#include <QtPromise> #include <QtPromise>

View File

@ -5,7 +5,7 @@
* the LICENSE file in the root directory of this source tree. * the LICENSE file in the root directory of this source tree.
*/ */
#include "../../shared/utils.h" #include "../shared/utils.h"
// QtPromise // QtPromise
#include <QtPromise> #include <QtPromise>

View File

@ -5,7 +5,7 @@
* the LICENSE file in the root directory of this source tree. * the LICENSE file in the root directory of this source tree.
*/ */
#include "../../shared/utils.h" #include "../shared/utils.h"
// QtPromise // QtPromise
#include <QtPromise> #include <QtPromise>

View File

@ -5,12 +5,13 @@
* the LICENSE file in the root directory of this source tree. * the LICENSE file in the root directory of this source tree.
*/ */
#include "../../shared/utils.h" #include "../shared/utils.h"
// QtPromise // QtPromise
#include <QtPromise> #include <QtPromise>
// Qt // Qt
#include <QtConcurrent>
#include <QtTest> #include <QtTest>
using namespace QtPromise; using namespace QtPromise;
@ -57,8 +58,6 @@ struct SequenceTester
} // anonymous namespace } // anonymous namespace
#include <QtConcurrent/QtConcurrent>
void tst_qpromise_filter::emptySequence() void tst_qpromise_filter::emptySequence()
{ {
auto p = QPromise<QVector<int>>::resolve({}).filter([](int v, ...) { auto p = QPromise<QVector<int>>::resolve({}).filter([](int v, ...) {

View File

@ -5,7 +5,7 @@
* the LICENSE file in the root directory of this source tree. * the LICENSE file in the root directory of this source tree.
*/ */
#include "../../shared/utils.h" #include "../shared/utils.h"
// QtPromise // QtPromise
#include <QtPromise> #include <QtPromise>

View File

@ -5,7 +5,7 @@
* the LICENSE file in the root directory of this source tree. * the LICENSE file in the root directory of this source tree.
*/ */
#include "../../shared/utils.h" #include "../shared/utils.h"
// QtPromise // QtPromise
#include <QtPromise> #include <QtPromise>

View File

@ -5,7 +5,7 @@
* the LICENSE file in the root directory of this source tree. * the LICENSE file in the root directory of this source tree.
*/ */
#include "../../shared/utils.h" #include "../shared/utils.h"
// QtPromise // QtPromise
#include <QtPromise> #include <QtPromise>

View File

@ -5,8 +5,8 @@
* the LICENSE file in the root directory of this source tree. * the LICENSE file in the root directory of this source tree.
*/ */
#include "../../shared/data.h" #include "../shared/data.h"
#include "../../shared/utils.h" #include "../shared/utils.h"
// QtPromise // QtPromise
#include <QtPromise> #include <QtPromise>

View File

@ -5,8 +5,8 @@
* the LICENSE file in the root directory of this source tree. * the LICENSE file in the root directory of this source tree.
*/ */
#include "../../shared/data.h" #include "../shared/data.h"
#include "../../shared/utils.h" #include "../shared/utils.h"
// QtPromise // QtPromise
#include <QtPromise> #include <QtPromise>

View File

@ -5,7 +5,7 @@
* the LICENSE file in the root directory of this source tree. * the LICENSE file in the root directory of this source tree.
*/ */
#include "../../shared/utils.h" #include "../shared/utils.h"
// QtPromise // QtPromise
#include <QtPromise> #include <QtPromise>

View File

@ -5,7 +5,7 @@
* the LICENSE file in the root directory of this source tree. * the LICENSE file in the root directory of this source tree.
*/ */
#include "../../shared/utils.h" #include "../shared/utils.h"
// QtPromise // QtPromise
#include <QtPromise> #include <QtPromise>

View File

@ -5,7 +5,7 @@
* the LICENSE file in the root directory of this source tree. * the LICENSE file in the root directory of this source tree.
*/ */
#include "../../shared/utils.h" #include "../shared/utils.h"
#include <functional> #include <functional>

View File

@ -5,7 +5,7 @@
* the LICENSE file in the root directory of this source tree. * the LICENSE file in the root directory of this source tree.
*/ */
#include "../../shared/utils.h" #include "../shared/utils.h"
// QtPromise // QtPromise
#include <QtPromise> #include <QtPromise>

View File

@ -1,6 +1,4 @@
qtpromise_add_test(thread qtpromise_add_test(thread
SOURCES SOURCES
tst_thread.cpp tst_thread.cpp
LIBRARIES
Qt5::Concurrent
) )