mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Run all C++ tests from a single executable (#3582)
This commit is contained in:
parent
4ff63a7960
commit
c719cce4f1
44 changed files with 138 additions and 94 deletions
2
.github/workflows/tests.yaml
vendored
2
.github/workflows/tests.yaml
vendored
|
@ -17,7 +17,7 @@ jobs:
|
|||
run: cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS=--coverage
|
||||
|
||||
- name: Build project
|
||||
run: cmake --build build --target build_tests
|
||||
run: cmake --build build --target test_runner --target task_executable
|
||||
|
||||
- name: Test project
|
||||
run: ctest --test-dir build -j 8 --output-on-failure
|
||||
|
|
24
Cargo.lock
generated
24
Cargo.lock
generated
|
@ -1141,6 +1141,21 @@ dependencies = [
|
|||
"sct",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustls"
|
||||
version = "0.23.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c58f8c84392efc0a126acce10fa59ff7b3d2ac06ab451a33f2741989b806b044"
|
||||
dependencies = [
|
||||
"log",
|
||||
"once_cell",
|
||||
"ring",
|
||||
"rustls-pki-types",
|
||||
"rustls-webpki 0.102.6",
|
||||
"subtle",
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustls-pemfile"
|
||||
version = "1.0.4"
|
||||
|
@ -1807,6 +1822,15 @@ dependencies = [
|
|||
"rustls-pki-types",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-util"
|
||||
version = "0.1.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
|
||||
dependencies = [
|
||||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-core"
|
||||
version = "0.52.0"
|
||||
|
|
|
@ -52,9 +52,9 @@ cmake --build build-clang
|
|||
## Run the Test Suite:
|
||||
For running the test suite [ctest](https://cmake.org/cmake/help/latest/manual/ctest.1.html) is used.
|
||||
Before one can run the test suite the `task_executable` must be built.
|
||||
After that also the `build_tests` target must be build, which can be done over:
|
||||
After that also the `test_runner` target must be build, which can be done over:
|
||||
```sh
|
||||
cmake --build build --target build_tests
|
||||
cmake --build build --target test_runner
|
||||
```
|
||||
Again you may also use the `-j <number-of-jobs>` option for parallel builds.
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
cmake_minimum_required (VERSION 3.22)
|
||||
|
||||
# -- C++ tests
|
||||
|
||||
include_directories (${CMAKE_SOURCE_DIR}
|
||||
${CMAKE_SOURCE_DIR}/src
|
||||
${CMAKE_SOURCE_DIR}/src/commands
|
||||
|
@ -8,56 +10,64 @@ include_directories (${CMAKE_SOURCE_DIR}
|
|||
${CMAKE_SOURCE_DIR}/test
|
||||
${TASK_INCLUDE_DIRS})
|
||||
|
||||
# All C++ test files. Note that the portion before `.cpp` must be a valid,
|
||||
# unique C++ identifier.
|
||||
set(test_SRCS
|
||||
col.test.cpp
|
||||
dom.test.cpp
|
||||
eval.test.cpp
|
||||
lexer.test.cpp
|
||||
t.test.cpp
|
||||
tw-2689.test.cpp
|
||||
tdb2.test.cpp
|
||||
tc.test.cpp
|
||||
util.test.cpp
|
||||
variant_add.test.cpp
|
||||
variant_and.test.cpp
|
||||
variant_cast.test.cpp
|
||||
variant_divide.test.cpp
|
||||
variant_equal.test.cpp
|
||||
variant_exp.test.cpp
|
||||
variant_gt.test.cpp
|
||||
variant_gte.test.cpp
|
||||
variant_inequal.test.cpp
|
||||
variant_lt.test.cpp
|
||||
variant_lte.test.cpp
|
||||
variant_match.test.cpp
|
||||
variant_math.test.cpp
|
||||
variant_modulo.test.cpp
|
||||
variant_multiply.test.cpp
|
||||
variant_nomatch.test.cpp
|
||||
variant_not.test.cpp
|
||||
variant_or.test.cpp
|
||||
variant_partial.test.cpp
|
||||
variant_subtract.test.cpp
|
||||
variant_xor.test.cpp
|
||||
view.test.cpp
|
||||
col_test.cpp
|
||||
dom_test.cpp
|
||||
eval_test.cpp
|
||||
lexer_test.cpp
|
||||
t_test.cpp
|
||||
tw_2689_test.cpp
|
||||
tdb2_test.cpp
|
||||
tc_cpp_test.cpp
|
||||
util_test.cpp
|
||||
variant_add_test.cpp
|
||||
variant_and_test.cpp
|
||||
variant_cast_test.cpp
|
||||
variant_divide_test.cpp
|
||||
variant_equal_test.cpp
|
||||
variant_exp_test.cpp
|
||||
variant_gt_test.cpp
|
||||
variant_gte_test.cpp
|
||||
variant_inequal_test.cpp
|
||||
variant_lt_test.cpp
|
||||
variant_lte_test.cpp
|
||||
variant_match_test.cpp
|
||||
variant_math_test.cpp
|
||||
variant_modulo_test.cpp
|
||||
variant_multiply_test.cpp
|
||||
variant_nomatch_test.cpp
|
||||
variant_not_test.cpp
|
||||
variant_or_test.cpp
|
||||
variant_partial_test.cpp
|
||||
variant_subtract_test.cpp
|
||||
variant_xor_test.cpp
|
||||
view_test.cpp
|
||||
)
|
||||
|
||||
add_custom_target (build_tests DEPENDS ${test_SRCS}
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/test)
|
||||
|
||||
foreach (src_FILE ${test_SRCS})
|
||||
add_executable (${src_FILE} ${src_FILE} test.cpp)
|
||||
target_link_libraries (${src_FILE} task commands columns libshared task commands columns libshared task commands columns libshared ${TASK_LIBRARIES})
|
||||
add_dependencies (${src_FILE} task_executable)
|
||||
# Build `test_runner` containing all CPP tests, linked once.
|
||||
create_test_sourcelist (cpp_test_SRCS cpp_tests.cpp ${test_SRCS})
|
||||
add_executable(test_runner
|
||||
test.cpp
|
||||
${cpp_test_SRCS}
|
||||
)
|
||||
target_link_libraries (test_runner task commands columns libshared task commands columns libshared task commands columns libshared ${TASK_LIBRARIES})
|
||||
if (DARWIN)
|
||||
target_link_libraries (${src_FILE} "-framework CoreFoundation -framework Security -framework SystemConfiguration")
|
||||
target_link_libraries (test_runner "-framework CoreFoundation -framework Security -framework SystemConfiguration")
|
||||
endif (DARWIN)
|
||||
|
||||
add_test(NAME ${src_FILE}
|
||||
COMMAND ${src_FILE}
|
||||
foreach (test_FILE ${test_SRCS})
|
||||
get_filename_component (test_NAME ${test_FILE} NAME_WE)
|
||||
# Tell the source file what its own name is
|
||||
set_source_files_properties(${test_FILE} PROPERTIES COMPILE_FLAGS -DTEST_NAME=${test_NAME})
|
||||
add_test(NAME ${test_FILE}
|
||||
COMMAND test_runner ${test_NAME}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
endforeach (src_FILE)
|
||||
endforeach (test_FILE)
|
||||
|
||||
# -- Python tests
|
||||
|
||||
add_subdirectory(basetest)
|
||||
add_subdirectory(simpletap)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
## Running Tests
|
||||
Do this to run all tests:
|
||||
```shell
|
||||
cmake --build build --target build_tests
|
||||
cmake --build build --target test_runner --target task_executable
|
||||
ctest --test-dir build
|
||||
```
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#include <test.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main(int, char**) {
|
||||
int TEST_NAME(int, char**) {
|
||||
UnitTest test(12);
|
||||
|
||||
// Ensure environment has no influence.
|
|
@ -26,5 +26,5 @@ RUN cmake --install build
|
|||
RUN task --version
|
||||
|
||||
# Setup tests
|
||||
RUN cmake --build build --target build_tests -j 8
|
||||
RUN cmake --build build --target test_runner -j 8
|
||||
CMD ctest --test-dir build -j 8 --output-on-failure --rerun-failed
|
||||
|
|
|
@ -27,5 +27,5 @@ RUN cmake --install build
|
|||
RUN task --version
|
||||
|
||||
# Setup tests
|
||||
RUN cmake --build build --target build_tests -j 8
|
||||
RUN cmake --build build --target test_runner -j 8
|
||||
CMD ctest --test-dir build -j 8 --output-on-failure --rerun-failed
|
||||
|
|
|
@ -27,5 +27,5 @@ RUN cmake --install build
|
|||
RUN task --version
|
||||
|
||||
# Setup tests
|
||||
RUN cmake --build build --target build_tests -j 8
|
||||
RUN cmake --build build --target test_runner -j 8
|
||||
CMD ctest --test-dir build -j 8 --output-on-failure --rerun-failed
|
||||
|
|
|
@ -26,5 +26,5 @@ RUN cmake --install build
|
|||
RUN task --version
|
||||
|
||||
# Setup tests
|
||||
RUN cmake --build build --target build_tests -j 8
|
||||
RUN cmake --build build --target test_runner -j 8
|
||||
CMD ctest --test-dir build -j 8 --output-on-failure --rerun-failed
|
||||
|
|
|
@ -26,5 +26,5 @@ RUN cmake --install build
|
|||
RUN task --version
|
||||
|
||||
# Setup tests
|
||||
RUN cmake --build build --target build_tests -j 8
|
||||
RUN cmake --build build --target test_runner -j 8
|
||||
CMD ctest --test-dir build -j 8 --output-on-failure --rerun-failed
|
||||
|
|
|
@ -25,5 +25,5 @@ RUN cmake --install build
|
|||
RUN task --version
|
||||
|
||||
# Setup tests
|
||||
RUN cmake --build build --target build_tests -j 8
|
||||
RUN cmake --build build --target test_runner -j 8
|
||||
CMD ctest --test-dir build -j 8 --output-on-failure --rerun-failed
|
||||
|
|
|
@ -34,5 +34,5 @@ RUN cmake --install build
|
|||
RUN task --version
|
||||
|
||||
# Setup tests
|
||||
RUN cmake --build build --target build_tests -j 8
|
||||
RUN cmake --build build --target test_runner -j 8
|
||||
CMD ctest --test-dir build -j 8 --output-on-failure --rerun-failed
|
||||
|
|
|
@ -27,5 +27,5 @@ RUN cmake --install build
|
|||
RUN task --version
|
||||
|
||||
# Setup tests
|
||||
RUN cmake --build build --target build_tests -j 8
|
||||
RUN cmake --build build --target test_runner -j 8
|
||||
CMD ctest --test-dir build -j 8 --output-on-failure --rerun-failed
|
||||
|
|
|
@ -31,6 +31,8 @@
|
|||
#include <Variant.h>
|
||||
#include <test.h>
|
||||
|
||||
namespace {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool providerString(const std::string& path, Variant& var) {
|
||||
if (path == "name") {
|
||||
|
@ -50,8 +52,10 @@ bool providerString(const std::string& path, Variant& var) {
|
|||
return false;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main(int, char**) {
|
||||
int TEST_NAME(int, char**) {
|
||||
UnitTest t(12);
|
||||
|
||||
DOM dom;
|
|
@ -31,6 +31,8 @@
|
|||
#include <Eval.h>
|
||||
#include <test.h>
|
||||
|
||||
namespace {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// A few hard-coded symbols.
|
||||
bool get(const std::string& name, Variant& value) {
|
||||
|
@ -42,8 +44,10 @@ bool get(const std::string& name, Variant& value) {
|
|||
return true;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main(int, char**) {
|
||||
int TEST_NAME(int, char**) {
|
||||
UnitTest t(52);
|
||||
Context context;
|
||||
Context::setContext(&context);
|
|
@ -37,7 +37,7 @@
|
|||
#include <vector>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main(int, char**) {
|
||||
int TEST_NAME(int, char**) {
|
||||
#ifdef PRODUCT_TASKWARRIOR
|
||||
UnitTest t(1255);
|
||||
#else
|
|
@ -32,7 +32,7 @@
|
|||
#include <test.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main(int, char**) {
|
||||
int TEST_NAME(int, char**) {
|
||||
UnitTest test(48);
|
||||
Context context;
|
||||
Context::setContext(&context);
|
|
@ -41,7 +41,7 @@ std::string uuid2str(tc::Uuid uuid) { return static_cast<std::string>(uuid.to_st
|
|||
// Tests for the basic cxxbridge functionality. This focuses on the methods with
|
||||
// complex cxxbridge implementations, rather than those with complex Rust
|
||||
// implementations but simple APIs, like sync.
|
||||
int main(int, char **) {
|
||||
int TEST_NAME(int, char **) {
|
||||
UnitTest t;
|
||||
std::string str;
|
||||
|
|
@ -34,7 +34,7 @@
|
|||
|
||||
#include <iostream>
|
||||
|
||||
Context context;
|
||||
namespace {
|
||||
|
||||
void cleardb() {
|
||||
// Remove any residual test files.
|
||||
|
@ -42,8 +42,10 @@ void cleardb() {
|
|||
unlink("./taskchampion.sqlite3");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main(int, char**) {
|
||||
int TEST_NAME(int, char**) {
|
||||
UnitTest t(12);
|
||||
Context context;
|
||||
Context::setContext(&context);
|
|
@ -34,7 +34,7 @@
|
|||
#include <test.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main(int, char**) {
|
||||
int TEST_NAME(int, char**) {
|
||||
UnitTest test(12);
|
||||
|
||||
// Ensure environment has no influence.
|
|
@ -35,7 +35,7 @@
|
|||
#include <iostream>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main(int, char**) {
|
||||
int TEST_NAME(int, char**) {
|
||||
UnitTest t(19);
|
||||
Context context;
|
||||
Context::setContext(&context);
|
|
@ -35,7 +35,7 @@
|
|||
#define EPSILON 0.001
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main(int, char**) {
|
||||
int TEST_NAME(int, char**) {
|
||||
UnitTest t(80);
|
||||
|
||||
Variant v0(true);
|
|
@ -33,7 +33,7 @@
|
|||
#include <iostream>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main(int, char**) {
|
||||
int TEST_NAME(int, char**) {
|
||||
UnitTest t(76);
|
||||
|
||||
Variant v0(true);
|
|
@ -35,7 +35,7 @@
|
|||
#define EPSILON 0.001
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main(int, char**) {
|
||||
int TEST_NAME(int, char**) {
|
||||
UnitTest t(81);
|
||||
|
||||
time_t now = time(nullptr);
|
|
@ -35,7 +35,7 @@
|
|||
#define EPSILON 0.0001
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main(int, char**) {
|
||||
int TEST_NAME(int, char**) {
|
||||
UnitTest t(44);
|
||||
|
||||
Variant v0(true);
|
|
@ -33,7 +33,7 @@
|
|||
#include <iostream>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main(int, char**) {
|
||||
int TEST_NAME(int, char**) {
|
||||
UnitTest t(72);
|
||||
|
||||
Variant v0(true);
|
|
@ -33,7 +33,7 @@
|
|||
#include <iostream>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main(int, char**) {
|
||||
int TEST_NAME(int, char**) {
|
||||
UnitTest t(38);
|
||||
|
||||
Variant v0(true);
|
|
@ -33,7 +33,7 @@
|
|||
#include <iostream>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main(int, char**) {
|
||||
int TEST_NAME(int, char**) {
|
||||
UnitTest t(72);
|
||||
|
||||
Variant v0(true);
|
|
@ -33,7 +33,7 @@
|
|||
#include <iostream>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main(int, char**) {
|
||||
int TEST_NAME(int, char**) {
|
||||
UnitTest t(72);
|
||||
|
||||
Variant v0(true);
|
|
@ -33,7 +33,7 @@
|
|||
#include <iostream>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main(int, char**) {
|
||||
int TEST_NAME(int, char**) {
|
||||
UnitTest t(72);
|
||||
|
||||
Variant v0(true);
|
|
@ -33,7 +33,7 @@
|
|||
#include <iostream>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main(int, char**) {
|
||||
int TEST_NAME(int, char**) {
|
||||
UnitTest t(72);
|
||||
|
||||
Variant v0(true);
|
|
@ -33,7 +33,7 @@
|
|||
#include <iostream>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main(int, char**) {
|
||||
int TEST_NAME(int, char**) {
|
||||
UnitTest t(72);
|
||||
|
||||
Variant v0(true);
|
|
@ -33,12 +33,12 @@
|
|||
|
||||
#include <iostream>
|
||||
|
||||
Task task;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main(int, char**) {
|
||||
int TEST_NAME(int, char**) {
|
||||
UnitTest t(120);
|
||||
|
||||
Task task;
|
||||
|
||||
Variant vs0("untrue"); // ~ true
|
||||
Variant vs1(8421); // ~ 42
|
||||
Variant vs2(3.14159); // ~ 3.14
|
|
@ -35,7 +35,7 @@
|
|||
#define EPSILON 0.001
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main(int, char**) {
|
||||
int TEST_NAME(int, char**) {
|
||||
UnitTest t(1);
|
||||
|
||||
Variant v0(10.0);
|
|
@ -35,7 +35,7 @@
|
|||
#define EPSILON 0.0001
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main(int, char**) {
|
||||
int TEST_NAME(int, char**) {
|
||||
UnitTest t(40);
|
||||
|
||||
Variant v0(true);
|
|
@ -35,7 +35,7 @@
|
|||
#define EPSILON 0.0001
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main(int, char**) {
|
||||
int TEST_NAME(int, char**) {
|
||||
UnitTest t(54);
|
||||
|
||||
Variant v0(true);
|
|
@ -33,12 +33,12 @@
|
|||
|
||||
#include <iostream>
|
||||
|
||||
Task task;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main(int, char**) {
|
||||
int TEST_NAME(int, char**) {
|
||||
UnitTest t(120);
|
||||
|
||||
Task task;
|
||||
|
||||
Variant vs0("untrue"); // !~ true
|
||||
Variant vs1(8421); // !~ 42
|
||||
Variant vs2(3.14159); // !~ 3.14
|
|
@ -33,7 +33,7 @@
|
|||
#include <iostream>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main(int, char**) {
|
||||
int TEST_NAME(int, char**) {
|
||||
UnitTest t(14);
|
||||
|
||||
Variant v0(true);
|
|
@ -33,7 +33,7 @@
|
|||
#include <iostream>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main(int, char**) {
|
||||
int TEST_NAME(int, char**) {
|
||||
UnitTest t(76);
|
||||
|
||||
Variant v0(true);
|
|
@ -33,7 +33,7 @@
|
|||
#include <iostream>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main(int, char**) {
|
||||
int TEST_NAME(int, char**) {
|
||||
UnitTest t(72);
|
||||
|
||||
Variant v0(true);
|
|
@ -35,7 +35,7 @@
|
|||
#define EPSILON 0.001
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main(int, char**) {
|
||||
int TEST_NAME(int, char**) {
|
||||
UnitTest t(55);
|
||||
|
||||
Variant v0(true);
|
|
@ -33,7 +33,7 @@
|
|||
#include <iostream>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main(int, char**) {
|
||||
int TEST_NAME(int, char**) {
|
||||
UnitTest t(76);
|
||||
|
||||
Variant v0(true);
|
|
@ -43,7 +43,7 @@ Context context;
|
|||
extern std::string configurationDefaults;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main(int, char**) {
|
||||
int TEST_NAME(int, char**) {
|
||||
UnitTest t(1);
|
||||
Context context;
|
||||
Context::setContext(&context);
|
Loading…
Add table
Add a link
Reference in a new issue