Skip to content

Commit

Permalink
use create_teste_sourcelist
Browse files Browse the repository at this point in the history
  • Loading branch information
djmitche committed Aug 8, 2024
1 parent 82758a7 commit 7743791
Show file tree
Hide file tree
Showing 33 changed files with 67 additions and 125 deletions.
80 changes: 36 additions & 44 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,63 +11,55 @@ 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)
target_link_libraries (test_runner "-framework CoreFoundation -framework Security -framework SystemConfiguration")
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}
Expand Down
2 changes: 1 addition & 1 deletion test/col.test.cpp → test/col_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include <test.h>

////////////////////////////////////////////////////////////////////////////////
int TEST_NAME() {
int TEST_NAME(int, char**) {
UnitTest test(12);

// Ensure environment has no influence.
Expand Down
2 changes: 1 addition & 1 deletion test/dom.test.cpp → test/dom_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion test/eval.test.cpp → test/eval_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion test/lexer.test.cpp → test/lexer_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#include <vector>

////////////////////////////////////////////////////////////////////////////////
int TEST_NAME() {
int TEST_NAME(int, char**) {
#ifdef PRODUCT_TASKWARRIOR
UnitTest t(1255);
#else
Expand Down
2 changes: 1 addition & 1 deletion test/t.test.cpp → test/t_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include <test.h>

////////////////////////////////////////////////////////////////////////////////
int TEST_NAME() {
int TEST_NAME(int, char**) {
UnitTest test(48);
Context context;
Context::setContext(&context);
Expand Down
2 changes: 1 addition & 1 deletion test/tc.test.cpp → test/tc_cpp_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/tdb2.test.cpp → test/tdb2_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void cleardb() {
} // namespace

////////////////////////////////////////////////////////////////////////////////
int TEST_NAME() {
int TEST_NAME(int, char**) {
UnitTest t(12);
Context context;
Context::setContext(&context);
Expand Down
50 changes: 0 additions & 50 deletions test/test_main_generator.sh

This file was deleted.

2 changes: 1 addition & 1 deletion test/tw-2689.test.cpp → test/tw_2689_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include <test.h>

////////////////////////////////////////////////////////////////////////////////
int TEST_NAME() {
int TEST_NAME(int, char**) {
UnitTest test(12);

// Ensure environment has no influence.
Expand Down
2 changes: 1 addition & 1 deletion test/util.test.cpp → test/util_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include <iostream>

////////////////////////////////////////////////////////////////////////////////
int TEST_NAME() {
int TEST_NAME(int, char**) {
UnitTest t(19);
Context context;
Context::setContext(&context);
Expand Down
2 changes: 1 addition & 1 deletion test/variant_add.test.cpp → test/variant_add_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#define EPSILON 0.001

////////////////////////////////////////////////////////////////////////////////
int TEST_NAME() {
int TEST_NAME(int, char**) {
UnitTest t(80);

Variant v0(true);
Expand Down
2 changes: 1 addition & 1 deletion test/variant_and.test.cpp → test/variant_and_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include <iostream>

////////////////////////////////////////////////////////////////////////////////
int TEST_NAME() {
int TEST_NAME(int, char**) {
UnitTest t(76);

Variant v0(true);
Expand Down
2 changes: 1 addition & 1 deletion test/variant_cast.test.cpp → test/variant_cast_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#define EPSILON 0.001

////////////////////////////////////////////////////////////////////////////////
int TEST_NAME() {
int TEST_NAME(int, char**) {
UnitTest t(81);

time_t now = time(nullptr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#define EPSILON 0.0001

////////////////////////////////////////////////////////////////////////////////
int TEST_NAME() {
int TEST_NAME(int, char**) {
UnitTest t(44);

Variant v0(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include <iostream>

////////////////////////////////////////////////////////////////////////////////
int TEST_NAME() {
int TEST_NAME(int, char**) {
UnitTest t(72);

Variant v0(true);
Expand Down
2 changes: 1 addition & 1 deletion test/variant_exp.test.cpp → test/variant_exp_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include <iostream>

////////////////////////////////////////////////////////////////////////////////
int TEST_NAME() {
int TEST_NAME(int, char**) {
UnitTest t(38);

Variant v0(true);
Expand Down
2 changes: 1 addition & 1 deletion test/variant_gt.test.cpp → test/variant_gt_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include <iostream>

////////////////////////////////////////////////////////////////////////////////
int TEST_NAME() {
int TEST_NAME(int, char**) {
UnitTest t(72);

Variant v0(true);
Expand Down
2 changes: 1 addition & 1 deletion test/variant_gte.test.cpp → test/variant_gte_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include <iostream>

////////////////////////////////////////////////////////////////////////////////
int TEST_NAME() {
int TEST_NAME(int, char**) {
UnitTest t(72);

Variant v0(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include <iostream>

////////////////////////////////////////////////////////////////////////////////
int TEST_NAME() {
int TEST_NAME(int, char**) {
UnitTest t(72);

Variant v0(true);
Expand Down
2 changes: 1 addition & 1 deletion test/variant_lt.test.cpp → test/variant_lt_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include <iostream>

////////////////////////////////////////////////////////////////////////////////
int TEST_NAME() {
int TEST_NAME(int, char**) {
UnitTest t(72);

Variant v0(true);
Expand Down
2 changes: 1 addition & 1 deletion test/variant_lte.test.cpp → test/variant_lte_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include <iostream>

////////////////////////////////////////////////////////////////////////////////
int TEST_NAME() {
int TEST_NAME(int, char**) {
UnitTest t(72);

Variant v0(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include <iostream>

////////////////////////////////////////////////////////////////////////////////
int TEST_NAME() {
int TEST_NAME(int, char**) {
UnitTest t(120);

Task task;
Expand Down
2 changes: 1 addition & 1 deletion test/variant_math.test.cpp → test/variant_math_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#define EPSILON 0.001

////////////////////////////////////////////////////////////////////////////////
int TEST_NAME() {
int TEST_NAME(int, char**) {
UnitTest t(1);

Variant v0(10.0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#define EPSILON 0.0001

////////////////////////////////////////////////////////////////////////////////
int TEST_NAME() {
int TEST_NAME(int, char**) {
UnitTest t(40);

Variant v0(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#define EPSILON 0.0001

////////////////////////////////////////////////////////////////////////////////
int TEST_NAME() {
int TEST_NAME(int, char**) {
UnitTest t(54);

Variant v0(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include <iostream>

////////////////////////////////////////////////////////////////////////////////
int TEST_NAME() {
int TEST_NAME(int, char**) {
UnitTest t(120);

Task task;
Expand Down
2 changes: 1 addition & 1 deletion test/variant_not.test.cpp → test/variant_not_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include <iostream>

////////////////////////////////////////////////////////////////////////////////
int TEST_NAME() {
int TEST_NAME(int, char**) {
UnitTest t(14);

Variant v0(true);
Expand Down
2 changes: 1 addition & 1 deletion test/variant_or.test.cpp → test/variant_or_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include <iostream>

////////////////////////////////////////////////////////////////////////////////
int TEST_NAME() {
int TEST_NAME(int, char**) {
UnitTest t(76);

Variant v0(true);
Expand Down
Loading

0 comments on commit 7743791

Please sign in to comment.