Skip to content

Commit ace7812

Browse files
committed
Add testing module to allow better structuring of test suites
1 parent 590adbe commit ace7812

9 files changed

+2142
-324
lines changed

src/tests/CMakeLists.txt

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
1+
fypp_f90("${fyppFlags};-I${CMAKE_CURRENT_SOURCE_DIR}/.." "stdlib_test.fypp" outFiles)
2+
add_library("${PROJECT_NAME}-testing" "${outFiles}")
3+
target_link_libraries("${PROJECT_NAME}-testing" PUBLIC "${PROJECT_NAME}")
4+
set_target_properties(
5+
"${PROJECT_NAME}-testing" PROPERTIES
6+
Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
7+
)
8+
target_include_directories(
9+
"${PROJECT_NAME}-testing" PUBLIC
10+
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
11+
)
12+
113
macro(ADDTEST name)
214
add_executable(test_${name} test_${name}.f90)
3-
target_link_libraries(test_${name} ${PROJECT_NAME})
15+
target_link_libraries(test_${name} "${PROJECT_NAME}-testing")
416
add_test(NAME ${name}
517
COMMAND $<TARGET_FILE:test_${name}> ${CMAKE_CURRENT_BINARY_DIR}
618
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
@@ -16,6 +28,7 @@ add_subdirectory(sorting)
1628
add_subdirectory(stats)
1729
add_subdirectory(string)
1830
add_subdirectory(system)
31+
add_subdirectory(test)
1932
add_subdirectory(quadrature)
2033
add_subdirectory(math)
2134

src/tests/Makefile.manual

+23-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
.PHONY: all clean test
22

3-
all test clean:
3+
LIB = libstdlib-testing.a
4+
SRCFYPP = stdlib_test.fypp
5+
SRCGEN = $(SRCFYPP:.fypp=.f90)
6+
SRC = $(SRCGEN)
7+
OBJS = $(SRC:.f90=.o)
8+
MODS = $(OBJS:.o=.mod)
9+
10+
all test:: $(LIB)
11+
12+
all test clean::
413
$(MAKE) -f Makefile.manual --directory=ascii $@
514
$(MAKE) -f Makefile.manual --directory=bitsets $@
615
$(MAKE) -f Makefile.manual --directory=io $@
@@ -10,4 +19,17 @@ all test clean:
1019
$(MAKE) -f Makefile.manual --directory=quadrature $@
1120
$(MAKE) -f Makefile.manual --directory=stats $@
1221
$(MAKE) -f Makefile.manual --directory=string $@
22+
$(MAKE) -f Makefile.manual --directory=test $@
1323
$(MAKE) -f Makefile.manual --directory=math $@
24+
25+
$(LIB): $(OBJS)
26+
ar rcs $@ $^
27+
28+
clean::
29+
$(RM) $(LIB) $(OBJS) $(MODS) $(SRCGEN)
30+
31+
%.o: %.f90
32+
$(FC) $(FFLAGS) -I.. -c $<
33+
34+
$(SRCGEN): %.f90: %.fypp ../common.fypp
35+
fypp $(FYPPFLAGS) -I.. $< $@

src/tests/Makefile.manual.test.mk

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Common Makefile rules that are included from each test subdirectory's
22
# Makefile
33

4-
CPPFLAGS += -I../..
5-
LDFLAGS += -L../.. -lstdlib
4+
CPPFLAGS += -I../.. -I..
5+
LDFLAGS += -L../.. -L.. -lstdlib-testing -lstdlib
66

77
OBJS = $(PROGS_SRC:.f90=.o)
88
PROGS = $(OBJS:.o=)

0 commit comments

Comments
 (0)