1+ set_directory_properties (PROPERTIES LABELS h5fortran)
2+
3+ # --- fundamental HDF5 library check
4+
15add_executable (test_minimal test_minimal.f90)
26# even though we're not using h5fortran, we're testing that HDF5 was linked
37# as part of h5fortran
48target_link_libraries (test_minimal PRIVATE h5fortran::h5fortran)
59set_target_properties (test_minimal PROPERTIES LABELS unit)
6- add_test (NAME h5fortran: minimal COMMAND test_minimal)
7- set_tests_properties (h5fortran: minimal PROPERTIES
10+ add_test (NAME minimal COMMAND test_minimal)
11+ set_tests_properties (minimal PROPERTIES
812FIXTURES_SETUP h5lib
913TIMEOUT 5
1014LABELS core
1115)
1216
17+ # --- h5fortran unit tests
1318
1419function (setup_test names )
1520
@@ -22,24 +27,23 @@ target_link_libraries(test_${name} PRIVATE h5fortran::h5fortran)
2227target_compile_options (test_${name} PRIVATE "$<$<Fortran_COMPILER_ID:GNU>:-Wno-compare-reals;-Wno-conversion>" )
2328set_target_properties (test_${name} PROPERTIES LABELS unit)
2429
25- add_test (NAME h5fortran: ${name}
30+ add_test (NAME ${name}
2631COMMAND test_${name}
2732WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
2833)
29- set_tests_properties (h5fortran: ${name} PROPERTIES
34+ set_tests_properties (${name} PROPERTIES
3035FIXTURES_REQUIRED h5lib
3136TIMEOUT 10
3237)
3338
34-
3539if (${name} MATCHES ".*fail.*" )
36- set_tests_properties (h5fortran: ${name} PROPERTIES
40+ set_tests_properties (${name} PROPERTIES
3741 WILL_FAIL true
3842 LABELS shaky
3943 DISABLED $<OR :$<BOOL :${CI} >,$<NOT :$<BOOL :test_shaky>>>
4044 )
4145else ()
42- set_tests_properties (h5fortran: ${name} PROPERTIES
46+ set_tests_properties (${name} PROPERTIES
4347 LABELS unit
4448 )
4549endif ()
@@ -48,18 +52,25 @@ endforeach()
4852
4953endfunction (setup_test)
5054
51- # --- all other tests
55+ # --- setup unit tests
5256set (testnames array attributes deflate destructor error exist module layout lt scalar shape string
5357fail_read_size_mismatch fail_read_rank_mismatch fail_nonexist_variable)
5458
5559setup_test("${testnames} " )
5660
57- set_tests_properties (h5fortran: shape PROPERTIES
61+ set_tests_properties (shape PROPERTIES
5862FIXTURES_SETUP h5shape
5963)
6064
6165set (shape_file ${CMAKE_CURRENT_BINARY_DIR} /test_shape.h5)
6266
67+ if (ENABLE_COVERAGE)
68+ setup_target_for_coverage_gcovr_html(
69+ NAME coverage
70+ EXECUTABLE ${CMAKE_CTEST_COMMAND}
71+ )
72+ endif ()
73+
6374# --- Windows shared DLLs
6475if (WIN32 AND BUILD_SHARED_LIBS AND CMAKE_VERSION VERSION_GREATER_EQUAL 3.21)
6576 add_custom_command (TARGET test_shape POST_BUILD
@@ -83,11 +94,11 @@ if(NOT DEFINED h5py_ok)
8394 endif ()
8495endif ()
8596
86- add_test (NAME h5fortran: PythonShape
97+ add_test (NAME PythonShape
8798COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR} /test_shape.py ${shape_file}
8899)
89100
90- set_tests_properties (h5fortran: PythonShape PROPERTIES
101+ set_tests_properties (PythonShape PROPERTIES
91102REQUIRED_FILES ${shape_file}
92103FIXTURES_REQUIRED "h5lib;h5shape"
93104TIMEOUT 15
@@ -101,12 +112,12 @@ find_package(Matlab COMPONENTS MAIN_PROGRAM)
101112if (Matlab_FOUND)
102113 set (matlab_cmd "i=h5info('${shape_file} ', '/d7').Dataspace.Size; assert(all(i == [2, 1, 3, 4, 7, 6, 5]))" )
103114
104- add_test (NAME h5fortran: MatlabShape COMMAND ${Matlab_MAIN_PROGRAM} -batch ${matlab_cmd} )
115+ add_test (NAME MatlabShape COMMAND ${Matlab_MAIN_PROGRAM} -batch ${matlab_cmd} )
105116
106- set_tests_properties (h5fortran: MatlabShape PROPERTIES
117+ set_tests_properties (MatlabShape PROPERTIES
107118 TIMEOUT 90
108119 LABELS shaky
109- DEPENDS h5fortran: shape
120+ DEPENDS shape
110121 REQUIRED_FILES ${shape_file}
111122 FIXTURES_REQUIRED h5lib
112123 )
@@ -117,13 +128,13 @@ endif(matlab)
117128# --- h5ls
118129
119130find_program (h5ls NAMES h5ls)
120- add_test (NAME h5fortran: h5ls COMMAND ${h5ls} ${shape_file} /d7)
131+ add_test (NAME h5ls COMMAND ${h5ls} ${shape_file} /d7)
121132
122- set_tests_properties (h5fortran: h5ls PROPERTIES
133+ set_tests_properties (h5ls PROPERTIES
123134TIMEOUT 10
124135REQUIRED_FILES ${shape_file}
125136FIXTURES_REQUIRED h5lib
126- DEPENDS h5fortran: shape
137+ DEPENDS shape
127138PASS_REGULAR_EXPRESSION "{5, 6, 7, 4, 3, 1, 2}"
128139DISABLED $<NOT :$<BOOL :${h5ls} >>
129140)
0 commit comments