Skip to content

Commit fdcfbd9

Browse files
authored
Use test-drive directly instead of vendoring it
1 parent 0c85f24 commit fdcfbd9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+270
-2009
lines changed

ci/fpm-deployment.sh

+1-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ include=(
2424
prune=(
2525
"$destdir/test/test_always_fail.f90"
2626
"$destdir/test/test_always_skip.f90"
27-
"$destdir/test/test_mean_f03.f90"
2827
"$destdir/src/common.f90"
2928
"$destdir/src/f18estop.f90"
3029
)
@@ -44,7 +43,7 @@ find src/tests -name "*.dat" -exec cp {} "$destdir/" \;
4443
cp "${include[@]}" "$destdir/"
4544

4645
# Source file workarounds for fpm; ignore missing files
47-
rm -f "${prune[@]}"
46+
rm "${prune[@]}"
4847

4948
# List stdlib-fpm package contents
5049
ls -R "$destdir"

ci/fpm.toml

+3
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@ license = "MIT"
44
author = "stdlib contributors"
55
maintainer = "@fortran-lang/stdlib"
66
copyright = "2019-2021 stdlib contributors"
7+
8+
[dev-dependencies]
9+
test-drive.git = "https://github.com/fortran-lang/test-drive"

config/CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ if(NOT DEFINED CMAKE_INSTALL_MODULEDIR)
1010
)
1111
endif()
1212

13+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
14+
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" PARENT_SCOPE)
15+
1316
# Export a pkg-config file
1417
configure_file(
1518
"${CMAKE_CURRENT_SOURCE_DIR}/template.pc"

config/cmake/Findtest-drive.cmake

+178
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
# SPDX-Identifier: MIT
2+
3+
#[[.rst:
4+
Find test-drive
5+
---------------
6+
7+
Makes the test-drive project available.
8+
9+
Imported Targets
10+
^^^^^^^^^^^^^^^^
11+
12+
This module provides the following imported target, if found:
13+
14+
``test-drive::test-drive``
15+
The test-drive library
16+
17+
18+
Result Variables
19+
^^^^^^^^^^^^^^^^
20+
21+
This module will define the following variables:
22+
23+
``TEST_DRIVE_FOUND``
24+
True if the test-drive library is available
25+
26+
``TEST_DRIVE_SOURCE_DIR``
27+
Path to the source directory of the test-drive project,
28+
only set if the project is included as source.
29+
30+
``TEST_DRIVE_BINARY_DIR``
31+
Path to the binary directory of the test-drive project,
32+
only set if the project is included as source.
33+
34+
Cache variables
35+
^^^^^^^^^^^^^^^
36+
37+
The following cache variables may be set to influence the library detection:
38+
39+
``TEST_DRIVE_FIND_METHOD``
40+
Methods to find or make the project available. Available methods are
41+
- ``cmake``: Try to find via CMake config file
42+
- ``pkgconf``: Try to find via pkg-config file
43+
- ``subproject``: Use source in subprojects directory
44+
- ``fetch``: Fetch the source from upstream
45+
46+
``TEST_DRIVE_DIR``
47+
Used for searching the CMake config file
48+
49+
``TEST_DRIVE_SUBPROJECT``
50+
Directory to find the test-drive subproject, relative to the project root
51+
52+
#]]
53+
54+
set(_lib "test-drive")
55+
set(_pkg "TEST_DRIVE")
56+
set(_url "https://github.com/fortran-lang/test-drive")
57+
58+
if(NOT DEFINED "${_pkg}_FIND_METHOD")
59+
if(DEFINED "${PROJECT_NAME}-dependency-method")
60+
set("${_pkg}_FIND_METHOD" "${${PROJECT_NAME}-dependency-method}")
61+
else()
62+
set("${_pkg}_FIND_METHOD" "cmake" "pkgconf" "subproject" "fetch")
63+
endif()
64+
set("_${_pkg}_FIND_METHOD")
65+
endif()
66+
67+
foreach(method ${${_pkg}_FIND_METHOD})
68+
if(TARGET "${_lib}::${_lib}")
69+
break()
70+
endif()
71+
72+
if("${method}" STREQUAL "cmake")
73+
message(STATUS "${_lib}: Find installed package")
74+
if(DEFINED "${_pkg}_DIR")
75+
set("_${_pkg}_DIR")
76+
set("${_lib}_DIR" "${_pkg}_DIR")
77+
endif()
78+
find_package("${_lib}" CONFIG QUIET)
79+
if("${_lib}_FOUND")
80+
message(STATUS "${_lib}: Found installed package")
81+
break()
82+
endif()
83+
endif()
84+
85+
if("${method}" STREQUAL "pkgconf")
86+
find_package(PkgConfig QUIET)
87+
pkg_check_modules("${_pkg}" QUIET "${_lib}")
88+
if("${_pkg}_FOUND")
89+
message(STATUS "Found ${_lib} via pkg-config")
90+
91+
add_library("${_lib}::${_lib}" INTERFACE IMPORTED)
92+
target_link_libraries(
93+
"${_lib}::${_lib}"
94+
INTERFACE
95+
"${${_pkg}_LINK_LIBRARIES}"
96+
)
97+
target_include_directories(
98+
"${_lib}::${_lib}"
99+
INTERFACE
100+
"${${_pkg}_INCLUDE_DIRS}"
101+
)
102+
103+
break()
104+
endif()
105+
endif()
106+
107+
if("${method}" STREQUAL "subproject")
108+
if(NOT DEFINED "${_pkg}_SUBPROJECT")
109+
set("_${_pkg}_SUBPROJECT")
110+
set("${_pkg}_SUBPROJECT" "subprojects/${_lib}")
111+
endif()
112+
set("${_pkg}_SOURCE_DIR" "${PROJECT_SOURCE_DIR}/${${_pkg}_SUBPROJECT}")
113+
set("${_pkg}_BINARY_DIR" "${PROJECT_BINARY_DIR}/${${_pkg}_SUBPROJECT}")
114+
if(EXISTS "${${_pkg}_SOURCE_DIR}/CMakeLists.txt")
115+
message(STATUS "Include ${_lib} from ${${_pkg}_SUBPROJECT}")
116+
add_subdirectory(
117+
"${${_pkg}_SOURCE_DIR}"
118+
"${${_pkg}_BINARY_DIR}"
119+
)
120+
121+
add_library("${_lib}::${_lib}" INTERFACE IMPORTED)
122+
target_link_libraries("${_lib}::${_lib}" INTERFACE "${_lib}")
123+
124+
# We need the module directory in the subproject before we finish the configure stage
125+
if(NOT EXISTS "${${_pkg}_BINARY_DIR}/include")
126+
make_directory("${${_pkg}_BINARY_DIR}/include")
127+
endif()
128+
129+
break()
130+
endif()
131+
endif()
132+
133+
if("${method}" STREQUAL "fetch")
134+
message(STATUS "Retrieving ${_lib} from ${_url}")
135+
include(FetchContent)
136+
FetchContent_Declare(
137+
"${_lib}"
138+
GIT_REPOSITORY "${_url}"
139+
GIT_TAG "HEAD"
140+
)
141+
FetchContent_MakeAvailable("${_lib}")
142+
143+
add_library("${_lib}::${_lib}" INTERFACE IMPORTED)
144+
target_link_libraries("${_lib}::${_lib}" INTERFACE "${_lib}")
145+
146+
# We need the module directory in the subproject before we finish the configure stage
147+
FetchContent_GetProperties("${_lib}" SOURCE_DIR "${_pkg}_SOURCE_DIR")
148+
FetchContent_GetProperties("${_lib}" BINARY_DIR "${_pkg}_BINARY_DIR")
149+
if(NOT EXISTS "${${_pkg}_BINARY_DIR}/include")
150+
make_directory("${${_pkg}_BINARY_DIR}/include")
151+
endif()
152+
153+
break()
154+
endif()
155+
156+
endforeach()
157+
158+
if(TARGET "${_lib}::${_lib}")
159+
set("${_pkg}_FOUND" TRUE)
160+
else()
161+
set("${_pkg}_FOUND" FALSE)
162+
endif()
163+
164+
if(DEFINED "_${_pkg}_SUBPROJECT")
165+
unset("${_pkg}_SUBPROJECT")
166+
unset("_${_pkg}_SUBPROJECT")
167+
endif()
168+
if(DEFINED "_${_pkg}_DIR")
169+
unset("${_lib}_DIR")
170+
unset("_${_pkg}_DIR")
171+
endif()
172+
if(DEFINED "_${_pkg}_FIND_METHOD")
173+
unset("${_pkg}_FIND_METHOD")
174+
unset("_${_pkg}_FIND_METHOD")
175+
endif()
176+
unset(_lib)
177+
unset(_pkg)
178+
unset(_url)

src/tests/CMakeLists.txt

+4-13
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,10 @@
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-
)
1+
if (NOT TARGET "test-drive::test-drive")
2+
find_package("test-drive" REQUIRED)
3+
endif()
124

135
macro(ADDTEST name)
146
add_executable(test_${name} test_${name}.f90)
15-
target_link_libraries(test_${name} "${PROJECT_NAME}-testing")
7+
target_link_libraries(test_${name} "${PROJECT_NAME}" "test-drive::test-drive")
168
add_test(NAME ${name}
179
COMMAND $<TARGET_FILE:test_${name}> ${CMAKE_CURRENT_BINARY_DIR}
1810
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
@@ -28,7 +20,6 @@ add_subdirectory(sorting)
2820
add_subdirectory(stats)
2921
add_subdirectory(string)
3022
add_subdirectory(system)
31-
add_subdirectory(test)
3223
add_subdirectory(quadrature)
3324
add_subdirectory(math)
3425
add_subdirectory(stringlist)

src/tests/Makefile.manual

+7-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
.PHONY: all clean test
22

33
LIB = libstdlib-testing.a
4-
SRCFYPP = stdlib_test.fypp
5-
SRCGEN = $(SRCFYPP:.fypp=.f90)
6-
SRC = $(SRCGEN)
7-
OBJS = $(SRC:.f90=.o)
4+
SRC = testdrive.F90
5+
OBJS = $(SRC:.F90=.o)
86
MODS = $(OBJS:.o=.mod)
7+
FETCH = curl -L
98

109
all test:: $(LIB)
1110

11+
testdrive.F90:
12+
$(FETCH) https://github.com/fortran-lang/test-drive/raw/main/src/testdrive.F90 > $@
13+
1214
all test clean::
1315
$(MAKE) -f Makefile.manual --directory=ascii $@
1416
$(MAKE) -f Makefile.manual --directory=bitsets $@
@@ -19,7 +21,6 @@ all test clean::
1921
$(MAKE) -f Makefile.manual --directory=quadrature $@
2022
$(MAKE) -f Makefile.manual --directory=stats $@
2123
$(MAKE) -f Makefile.manual --directory=string $@
22-
$(MAKE) -f Makefile.manual --directory=test $@
2324
$(MAKE) -f Makefile.manual --directory=math $@
2425
$(MAKE) -f Makefile.manual --directory=stringlist $@
2526
$(MAKE) -f Makefile.manual --directory=linalg $@
@@ -30,8 +31,5 @@ $(LIB): $(OBJS)
3031
clean::
3132
$(RM) $(LIB) $(OBJS) $(MODS) $(SRCGEN)
3233

33-
%.o: %.f90
34+
%.o: %.F90
3435
$(FC) $(FFLAGS) -I.. -c $<
35-
36-
$(SRCGEN): %.f90: %.fypp ../common.fypp
37-
fypp $(FYPPFLAGS) -I.. $< $@

src/tests/ascii/test_ascii.f90

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module test_ascii
2-
use stdlib_test, only : new_unittest, unittest_type, error_type, check
2+
use testdrive, only : new_unittest, unittest_type, error_type, check
33
use stdlib_ascii, only: lowercase, uppercase, digits, &
44
octal_digits, fullhex_digits, hex_digits, lowerhex_digits, &
55
whitespace, letters, is_alphanum, is_alpha, is_lower, is_upper, &
@@ -932,7 +932,7 @@ end module test_ascii
932932

933933
program tester
934934
use, intrinsic :: iso_fortran_env, only : error_unit
935-
use stdlib_test, only : run_testsuite, new_testsuite, testsuite_type
935+
use testdrive, only : run_testsuite, new_testsuite, testsuite_type
936936
use test_ascii, only : collect_ascii
937937
implicit none
938938
integer :: stat, is

src/tests/bitsets/test_stdlib_bitset_64.f90

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module test_stdlib_bitset_64
2-
use stdlib_test, only : new_unittest, unittest_type, error_type, check
2+
use testdrive, only : new_unittest, unittest_type, error_type, check
33
use :: stdlib_kinds, only : int8, int16, int32, int64
44
use stdlib_bitsets
55
implicit none
@@ -588,7 +588,7 @@ end module test_stdlib_bitset_64
588588

589589
program tester
590590
use, intrinsic :: iso_fortran_env, only : error_unit
591-
use stdlib_test, only : run_testsuite, new_testsuite, testsuite_type
591+
use testdrive, only : run_testsuite, new_testsuite, testsuite_type
592592
use test_stdlib_bitset_64, only : collect_stdlib_bitset_64
593593
implicit none
594594
integer :: stat, is

src/tests/bitsets/test_stdlib_bitset_large.f90

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module test_stdlib_bitset_large
2-
use stdlib_test, only : new_unittest, unittest_type, error_type, check
2+
use testdrive, only : new_unittest, unittest_type, error_type, check
33
use :: stdlib_kinds, only : int8, int16, int32, int64
44
use stdlib_bitsets
55
implicit none
@@ -1102,7 +1102,7 @@ end module test_stdlib_bitset_large
11021102

11031103
program tester
11041104
use, intrinsic :: iso_fortran_env, only : error_unit
1105-
use stdlib_test, only : run_testsuite, new_testsuite, testsuite_type
1105+
use testdrive, only : run_testsuite, new_testsuite, testsuite_type
11061106
use test_stdlib_bitset_large, only : collect_stdlib_bitset_large
11071107
implicit none
11081108
integer :: stat, is

src/tests/io/test_loadtxt.f90

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module test_loadtxt
22
use stdlib_kinds, only: int32, sp, dp
33
use stdlib_io, only: loadtxt, savetxt
4-
use stdlib_test, only: new_unittest, unittest_type, error_type, check
4+
use testdrive, only: new_unittest, unittest_type, error_type, check
55
implicit none
66

77
private
@@ -205,7 +205,7 @@ end module test_loadtxt
205205

206206
program tester
207207
use, intrinsic :: iso_fortran_env, only : error_unit
208-
use stdlib_test, only : run_testsuite, new_testsuite, testsuite_type
208+
use testdrive, only : run_testsuite, new_testsuite, testsuite_type
209209
use test_loadtxt, only : collect_loadtxt
210210
implicit none
211211
integer :: stat, is

src/tests/io/test_loadtxt_qp.f90

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module test_loadtxt_qp
22
use stdlib_kinds, only: qp
33
use stdlib_io, only: loadtxt, savetxt
4-
use stdlib_test, only: new_unittest, unittest_type, error_type, check
4+
use testdrive, only: new_unittest, unittest_type, error_type, check
55
implicit none
66

77
private
@@ -89,7 +89,7 @@ end module test_loadtxt_qp
8989

9090
program tester
9191
use, intrinsic :: iso_fortran_env, only : error_unit
92-
use stdlib_test, only : run_testsuite, new_testsuite, testsuite_type
92+
use testdrive, only : run_testsuite, new_testsuite, testsuite_type
9393
use test_loadtxt_qp, only : collect_loadtxt_qp
9494
implicit none
9595
integer :: stat, is

src/tests/io/test_open.f90

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module test_open
22
use stdlib_io, only: open
3-
use stdlib_test, only: new_unittest, unittest_type, error_type, check
3+
use testdrive, only: new_unittest, unittest_type, error_type, check
44
implicit none
55

66
private
@@ -147,7 +147,7 @@ end module test_open
147147

148148
program tester
149149
use, intrinsic :: iso_fortran_env, only : error_unit
150-
use stdlib_test, only : run_testsuite, new_testsuite, testsuite_type
150+
use testdrive, only : run_testsuite, new_testsuite, testsuite_type
151151
use test_open, only : collect_open
152152
implicit none
153153
integer :: stat, is

0 commit comments

Comments
 (0)