diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index ba16d3927..3b9db7e4a 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -11,54 +11,47 @@ 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 ) -# Build a `test_main.cpp` based on `test_SRCS` -add_custom_command( - OUTPUT test_main.cpp - COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/test_main_generator.sh - ${test_SRCS} - > ${CMAKE_CURRENT_BINARY_DIR}/test_main.cpp - DEPENDS test_main_generator.sh -) - # 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 - test_main.cpp - ${test_SRCS} + ${cpp_test_SRCS} ) target_link_libraries (test_runner task tc commands columns libshared task tc commands columns libshared task commands columns libshared ${TASK_LIBRARIES}) if (DARWIN) @@ -66,8 +59,7 @@ if (DARWIN) endif (DARWIN) foreach (test_FILE ${test_SRCS}) - # Test_NAME is the name of the test with `.` replaced by `_`. - string(REGEX REPLACE "[^a-zA-Z0-9]" _ test_NAME ${test_FILE}) + 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} diff --git a/test/col.test.cpp b/test/col_test.cpp similarity index 99% rename from test/col.test.cpp rename to test/col_test.cpp index e5f673a13..d2ffd378c 100644 --- a/test/col.test.cpp +++ b/test/col_test.cpp @@ -33,7 +33,7 @@ #include //////////////////////////////////////////////////////////////////////////////// -int TEST_NAME() { +int TEST_NAME(int, char**) { UnitTest test(12); // Ensure environment has no influence. diff --git a/test/dom.test.cpp b/test/dom_test.cpp similarity index 99% rename from test/dom.test.cpp rename to test/dom_test.cpp index 39f6857fd..f542b3e30 100644 --- a/test/dom.test.cpp +++ b/test/dom_test.cpp @@ -55,7 +55,7 @@ bool providerString(const std::string& path, Variant& var) { } // namespace //////////////////////////////////////////////////////////////////////////////// -int TEST_NAME() { +int TEST_NAME(int, char**) { UnitTest t(12); DOM dom; diff --git a/test/eval.test.cpp b/test/eval_test.cpp similarity index 99% rename from test/eval.test.cpp rename to test/eval_test.cpp index a3b880ea6..e55d612a2 100644 --- a/test/eval.test.cpp +++ b/test/eval_test.cpp @@ -47,7 +47,7 @@ bool get(const std::string& name, Variant& value) { } // namespace //////////////////////////////////////////////////////////////////////////////// -int TEST_NAME() { +int TEST_NAME(int, char**) { UnitTest t(52); Context context; Context::setContext(&context); diff --git a/test/lexer.test.cpp b/test/lexer_test.cpp similarity index 99% rename from test/lexer.test.cpp rename to test/lexer_test.cpp index 2969a5bff..715c46081 100644 --- a/test/lexer.test.cpp +++ b/test/lexer_test.cpp @@ -37,7 +37,7 @@ #include //////////////////////////////////////////////////////////////////////////////// -int TEST_NAME() { +int TEST_NAME(int, char**) { #ifdef PRODUCT_TASKWARRIOR UnitTest t(1255); #else diff --git a/test/t.test.cpp b/test/t_test.cpp similarity index 99% rename from test/t.test.cpp rename to test/t_test.cpp index 82f11e285..a7063b19f 100644 --- a/test/t.test.cpp +++ b/test/t_test.cpp @@ -32,7 +32,7 @@ #include //////////////////////////////////////////////////////////////////////////////// -int TEST_NAME() { +int TEST_NAME(int, char**) { UnitTest test(48); Context context; Context::setContext(&context); diff --git a/test/tc.test.cpp b/test/tc_cpp_test.cpp similarity index 99% rename from test/tc.test.cpp rename to test/tc_cpp_test.cpp index 647c55719..c9fc090b9 100644 --- a/test/tc.test.cpp +++ b/test/tc_cpp_test.cpp @@ -39,7 +39,7 @@ #include "test.h" //////////////////////////////////////////////////////////////////////////////// -int TEST_NAME() { +int TEST_NAME(int, char**) { UnitTest t(23); // This function contains unit tests for the various bits of the wrappers for diff --git a/test/tdb2.test.cpp b/test/tdb2_test.cpp similarity index 99% rename from test/tdb2.test.cpp rename to test/tdb2_test.cpp index b3679a9df..22134d250 100644 --- a/test/tdb2.test.cpp +++ b/test/tdb2_test.cpp @@ -45,7 +45,7 @@ void cleardb() { } // namespace //////////////////////////////////////////////////////////////////////////////// -int TEST_NAME() { +int TEST_NAME(int, char**) { UnitTest t(12); Context context; Context::setContext(&context); diff --git a/test/test_main_generator.sh b/test/test_main_generator.sh deleted file mode 100755 index 463c944ec..000000000 --- a/test/test_main_generator.sh +++ /dev/null @@ -1,50 +0,0 @@ -#! /bin/bash -#/////////////////////////////////////////////////////////////////////////////// -#/ -#/ Copyright 2024 - 2024, Göteborg Bit Factory. -#/ -#/ Permission is hereby granted, free of charge, to any person obtaining a copy -#/ of this software and associated documentation files (the "Software"), to deal -#/ in the Software without restriction, including without limitation the rights -#/ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -#/ copies of the Software, and to permit persons to whom the Software is -#/ furnished to do so, subject to the following conditions: -#/ -#/ The above copyright notice and this permission notice shall be included -#/ in all copies or substantial portions of the Software. -#/ -#/ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -#/ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -#/ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -#/ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -#/ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -#/ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -#/ SOFTWARE. -#/ -#/ https://www.opensource.org/licenses/mit-license.php -#/ -#/////////////////////////////////////////////////////////////////////////////// - -cat <<'EOF' -#include -#include -int main(int argc, char** argv) { - // Expect to be called as `test_runner `. - assert(argc == 2); - std::string test_name = argv[1]; -EOF -for test_file in "${@}"; do - # same substitution as made in CMakeLists.txt - test_name=${test_file//[^a-zA-Z0-9]/_} - cat < //////////////////////////////////////////////////////////////////////////////// -int TEST_NAME() { +int TEST_NAME(int, char**) { UnitTest test(12); // Ensure environment has no influence. diff --git a/test/util.test.cpp b/test/util_test.cpp similarity index 99% rename from test/util.test.cpp rename to test/util_test.cpp index 90725927e..c4cf4e0bd 100644 --- a/test/util.test.cpp +++ b/test/util_test.cpp @@ -35,7 +35,7 @@ #include //////////////////////////////////////////////////////////////////////////////// -int TEST_NAME() { +int TEST_NAME(int, char**) { UnitTest t(19); Context context; Context::setContext(&context); diff --git a/test/variant_add.test.cpp b/test/variant_add_test.cpp similarity index 99% rename from test/variant_add.test.cpp rename to test/variant_add_test.cpp index 1712223a1..b17a3812c 100644 --- a/test/variant_add.test.cpp +++ b/test/variant_add_test.cpp @@ -35,7 +35,7 @@ #define EPSILON 0.001 //////////////////////////////////////////////////////////////////////////////// -int TEST_NAME() { +int TEST_NAME(int, char**) { UnitTest t(80); Variant v0(true); diff --git a/test/variant_and.test.cpp b/test/variant_and_test.cpp similarity index 99% rename from test/variant_and.test.cpp rename to test/variant_and_test.cpp index df5684c8a..97196ea78 100644 --- a/test/variant_and.test.cpp +++ b/test/variant_and_test.cpp @@ -33,7 +33,7 @@ #include //////////////////////////////////////////////////////////////////////////////// -int TEST_NAME() { +int TEST_NAME(int, char**) { UnitTest t(76); Variant v0(true); diff --git a/test/variant_cast.test.cpp b/test/variant_cast_test.cpp similarity index 99% rename from test/variant_cast.test.cpp rename to test/variant_cast_test.cpp index 7f6fde8ee..327881dc0 100644 --- a/test/variant_cast.test.cpp +++ b/test/variant_cast_test.cpp @@ -35,7 +35,7 @@ #define EPSILON 0.001 //////////////////////////////////////////////////////////////////////////////// -int TEST_NAME() { +int TEST_NAME(int, char**) { UnitTest t(81); time_t now = time(nullptr); diff --git a/test/variant_divide.test.cpp b/test/variant_divide_test.cpp similarity index 99% rename from test/variant_divide.test.cpp rename to test/variant_divide_test.cpp index 949b1e94e..c1df0c158 100644 --- a/test/variant_divide.test.cpp +++ b/test/variant_divide_test.cpp @@ -35,7 +35,7 @@ #define EPSILON 0.0001 //////////////////////////////////////////////////////////////////////////////// -int TEST_NAME() { +int TEST_NAME(int, char**) { UnitTest t(44); Variant v0(true); diff --git a/test/variant_equal.test.cpp b/test/variant_equal_test.cpp similarity index 99% rename from test/variant_equal.test.cpp rename to test/variant_equal_test.cpp index 4e79c2b82..2383c6e96 100644 --- a/test/variant_equal.test.cpp +++ b/test/variant_equal_test.cpp @@ -33,7 +33,7 @@ #include //////////////////////////////////////////////////////////////////////////////// -int TEST_NAME() { +int TEST_NAME(int, char**) { UnitTest t(72); Variant v0(true); diff --git a/test/variant_exp.test.cpp b/test/variant_exp_test.cpp similarity index 99% rename from test/variant_exp.test.cpp rename to test/variant_exp_test.cpp index cc41aedd2..00fd48121 100644 --- a/test/variant_exp.test.cpp +++ b/test/variant_exp_test.cpp @@ -33,7 +33,7 @@ #include //////////////////////////////////////////////////////////////////////////////// -int TEST_NAME() { +int TEST_NAME(int, char**) { UnitTest t(38); Variant v0(true); diff --git a/test/variant_gt.test.cpp b/test/variant_gt_test.cpp similarity index 99% rename from test/variant_gt.test.cpp rename to test/variant_gt_test.cpp index 7ec655ff7..2abab3add 100644 --- a/test/variant_gt.test.cpp +++ b/test/variant_gt_test.cpp @@ -33,7 +33,7 @@ #include //////////////////////////////////////////////////////////////////////////////// -int TEST_NAME() { +int TEST_NAME(int, char**) { UnitTest t(72); Variant v0(true); diff --git a/test/variant_gte.test.cpp b/test/variant_gte_test.cpp similarity index 99% rename from test/variant_gte.test.cpp rename to test/variant_gte_test.cpp index e4bb00d7d..4dbfa8f8e 100644 --- a/test/variant_gte.test.cpp +++ b/test/variant_gte_test.cpp @@ -33,7 +33,7 @@ #include //////////////////////////////////////////////////////////////////////////////// -int TEST_NAME() { +int TEST_NAME(int, char**) { UnitTest t(72); Variant v0(true); diff --git a/test/variant_inequal.test.cpp b/test/variant_inequal_test.cpp similarity index 99% rename from test/variant_inequal.test.cpp rename to test/variant_inequal_test.cpp index 0353a1c62..29222899b 100644 --- a/test/variant_inequal.test.cpp +++ b/test/variant_inequal_test.cpp @@ -33,7 +33,7 @@ #include //////////////////////////////////////////////////////////////////////////////// -int TEST_NAME() { +int TEST_NAME(int, char**) { UnitTest t(72); Variant v0(true); diff --git a/test/variant_lt.test.cpp b/test/variant_lt_test.cpp similarity index 99% rename from test/variant_lt.test.cpp rename to test/variant_lt_test.cpp index 8860ffce8..80967edd5 100644 --- a/test/variant_lt.test.cpp +++ b/test/variant_lt_test.cpp @@ -33,7 +33,7 @@ #include //////////////////////////////////////////////////////////////////////////////// -int TEST_NAME() { +int TEST_NAME(int, char**) { UnitTest t(72); Variant v0(true); diff --git a/test/variant_lte.test.cpp b/test/variant_lte_test.cpp similarity index 99% rename from test/variant_lte.test.cpp rename to test/variant_lte_test.cpp index be0f2a5b4..f68d4bf8a 100644 --- a/test/variant_lte.test.cpp +++ b/test/variant_lte_test.cpp @@ -33,7 +33,7 @@ #include //////////////////////////////////////////////////////////////////////////////// -int TEST_NAME() { +int TEST_NAME(int, char**) { UnitTest t(72); Variant v0(true); diff --git a/test/variant_match.test.cpp b/test/variant_match_test.cpp similarity index 99% rename from test/variant_match.test.cpp rename to test/variant_match_test.cpp index bf059d0b4..879adc8d3 100644 --- a/test/variant_match.test.cpp +++ b/test/variant_match_test.cpp @@ -34,7 +34,7 @@ #include //////////////////////////////////////////////////////////////////////////////// -int TEST_NAME() { +int TEST_NAME(int, char**) { UnitTest t(120); Task task; diff --git a/test/variant_math.test.cpp b/test/variant_math_test.cpp similarity index 98% rename from test/variant_math.test.cpp rename to test/variant_math_test.cpp index 23fe51bb1..46b4dc10f 100644 --- a/test/variant_math.test.cpp +++ b/test/variant_math_test.cpp @@ -35,7 +35,7 @@ #define EPSILON 0.001 //////////////////////////////////////////////////////////////////////////////// -int TEST_NAME() { +int TEST_NAME(int, char**) { UnitTest t(1); Variant v0(10.0); diff --git a/test/variant_modulo.test.cpp b/test/variant_modulo_test.cpp similarity index 99% rename from test/variant_modulo.test.cpp rename to test/variant_modulo_test.cpp index e3b92e601..39ef6a2b6 100644 --- a/test/variant_modulo.test.cpp +++ b/test/variant_modulo_test.cpp @@ -35,7 +35,7 @@ #define EPSILON 0.0001 //////////////////////////////////////////////////////////////////////////////// -int TEST_NAME() { +int TEST_NAME(int, char**) { UnitTest t(40); Variant v0(true); diff --git a/test/variant_multiply.test.cpp b/test/variant_multiply_test.cpp similarity index 99% rename from test/variant_multiply.test.cpp rename to test/variant_multiply_test.cpp index 547166ab9..159fbb8cb 100644 --- a/test/variant_multiply.test.cpp +++ b/test/variant_multiply_test.cpp @@ -35,7 +35,7 @@ #define EPSILON 0.0001 //////////////////////////////////////////////////////////////////////////////// -int TEST_NAME() { +int TEST_NAME(int, char**) { UnitTest t(54); Variant v0(true); diff --git a/test/variant_nomatch.test.cpp b/test/variant_nomatch_test.cpp similarity index 99% rename from test/variant_nomatch.test.cpp rename to test/variant_nomatch_test.cpp index 5a14b096d..31820f8ac 100644 --- a/test/variant_nomatch.test.cpp +++ b/test/variant_nomatch_test.cpp @@ -34,7 +34,7 @@ #include //////////////////////////////////////////////////////////////////////////////// -int TEST_NAME() { +int TEST_NAME(int, char**) { UnitTest t(120); Task task; diff --git a/test/variant_not.test.cpp b/test/variant_not_test.cpp similarity index 98% rename from test/variant_not.test.cpp rename to test/variant_not_test.cpp index dce655802..15b6ad476 100644 --- a/test/variant_not.test.cpp +++ b/test/variant_not_test.cpp @@ -33,7 +33,7 @@ #include //////////////////////////////////////////////////////////////////////////////// -int TEST_NAME() { +int TEST_NAME(int, char**) { UnitTest t(14); Variant v0(true); diff --git a/test/variant_or.test.cpp b/test/variant_or_test.cpp similarity index 99% rename from test/variant_or.test.cpp rename to test/variant_or_test.cpp index 780220b46..9c91e2151 100644 --- a/test/variant_or.test.cpp +++ b/test/variant_or_test.cpp @@ -33,7 +33,7 @@ #include //////////////////////////////////////////////////////////////////////////////// -int TEST_NAME() { +int TEST_NAME(int, char**) { UnitTest t(76); Variant v0(true); diff --git a/test/variant_partial.test.cpp b/test/variant_partial_test.cpp similarity index 99% rename from test/variant_partial.test.cpp rename to test/variant_partial_test.cpp index 0e08fb7af..40eef0c48 100644 --- a/test/variant_partial.test.cpp +++ b/test/variant_partial_test.cpp @@ -33,7 +33,7 @@ #include //////////////////////////////////////////////////////////////////////////////// -int TEST_NAME() { +int TEST_NAME(int, char**) { UnitTest t(72); Variant v0(true); diff --git a/test/variant_subtract.test.cpp b/test/variant_subtract_test.cpp similarity index 99% rename from test/variant_subtract.test.cpp rename to test/variant_subtract_test.cpp index c683bd7c7..967589123 100644 --- a/test/variant_subtract.test.cpp +++ b/test/variant_subtract_test.cpp @@ -35,7 +35,7 @@ #define EPSILON 0.001 //////////////////////////////////////////////////////////////////////////////// -int TEST_NAME() { +int TEST_NAME(int, char**) { UnitTest t(55); Variant v0(true); diff --git a/test/variant_xor.test.cpp b/test/variant_xor_test.cpp similarity index 99% rename from test/variant_xor.test.cpp rename to test/variant_xor_test.cpp index 8680da763..0917d35a3 100644 --- a/test/variant_xor.test.cpp +++ b/test/variant_xor_test.cpp @@ -33,7 +33,7 @@ #include //////////////////////////////////////////////////////////////////////////////// -int TEST_NAME() { +int TEST_NAME(int, char**) { UnitTest t(76); Variant v0(true); diff --git a/test/view.test.cpp b/test/view_test.cpp similarity index 99% rename from test/view.test.cpp rename to test/view_test.cpp index 7e6f788ca..76a27541a 100644 --- a/test/view.test.cpp +++ b/test/view_test.cpp @@ -43,7 +43,7 @@ Context context; extern std::string configurationDefaults; //////////////////////////////////////////////////////////////////////////////// -int TEST_NAME() { +int TEST_NAME(int, char**) { UnitTest t(1); Context context; Context::setContext(&context);