Skip to content

Commit 42e731a

Browse files
committed
CMake: Don't rely on diff for testing
1 parent 7693a30 commit 42e731a

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

CMakeLists.txt

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,6 @@ if ( ENABLE_TESTS )
273273
add_dependencies(build_tests ${LIB_NAME} ${LIB_NAME}-static)
274274

275275
find_program ( JSONLINT jsonlint )
276-
find_program ( DIFF diff )
277276

278277
set ( DATA_DIR "${CMAKE_SOURCE_DIR}/files" )
279278

@@ -370,22 +369,22 @@ if ( ENABLE_TESTS )
370369
endif ()
371370

372371
# Check output for differences
373-
if ( DIFF )
374-
foreach ( JSON_FILE ${EXPECTED_OUTPUTS} )
375-
get_filename_component (OUTPUT ${JSON_FILE} NAME )
376-
add_test ( NAME regression-${OUTPUT}
377-
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/files"
378-
COMMAND ${DIFF} -q ${OUTPUT} expected-outputs/${OUTPUT} )
379-
set_property ( TEST regression-${OUTPUT}
380-
APPEND
381-
PROPERTY
382-
DEPENDS ${UNIT_TESTS}
383-
REQUIRED_FILES ${EXPECTED_OUTPUTS} )
384-
endforeach ( JSON_FILE )
385-
else ()
386-
message ( WARNING
387-
"For full test coverage diff, or a similar tool must be present on your system" )
388-
endif ()
372+
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.14)
373+
set( JSON_FORTRAN_COMPARE_FLAG "--ignore-eol")
374+
endif()
375+
376+
foreach ( JSON_FILE ${EXPECTED_OUTPUTS} )
377+
get_filename_component (OUTPUT ${JSON_FILE} NAME )
378+
add_test ( NAME regression-${OUTPUT}
379+
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/files"
380+
COMMAND ${CMAKE_COMMAND} -E compare_files ${JSON_FORTRAN_COMPARE_FLAG} ${OUTPUT} expected-outputs/${OUTPUT} )
381+
set_property ( TEST regression-${OUTPUT}
382+
APPEND
383+
PROPERTY
384+
DEPENDS ${UNIT_TESTS}
385+
REQUIRED_FILES ${EXPECTED_OUTPUTS} )
386+
endforeach ( JSON_FILE )
387+
389388

390389
endif ()
391390

0 commit comments

Comments
 (0)