Skip to content

Commit

Permalink
Move examples to inside ctest
Browse files Browse the repository at this point in the history
Signed-off-by: Cristian Le <cristian.le@mpsd.mpg.de>
  • Loading branch information
LecrisUT committed Jan 19, 2024
1 parent f5f013c commit 2924ef6
Show file tree
Hide file tree
Showing 24 changed files with 47 additions and 65 deletions.
8 changes: 0 additions & 8 deletions .distro/plans/examples.fmf

This file was deleted.

1 change: 0 additions & 1 deletion example/.fmf/version

This file was deleted.

1 change: 1 addition & 0 deletions example/c_api
5 changes: 0 additions & 5 deletions example/c_api/main.fmf

This file was deleted.

1 change: 1 addition & 0 deletions example/fortran_api
5 changes: 0 additions & 5 deletions example/fortran_api/main.fmf

This file was deleted.

8 changes: 0 additions & 8 deletions example/main.fmf

This file was deleted.

1 change: 1 addition & 0 deletions example/python_api
10 changes: 0 additions & 10 deletions example/python_api/main.fmf

This file was deleted.

26 changes: 0 additions & 26 deletions example/test.sh

This file was deleted.

16 changes: 14 additions & 2 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,9 @@ function(Spglib_add_test test)
```cmake
Spglib_add_test(<name>
[TEST_NAME <test_name>]
[LABELS <label1> <label2>])
[LABELS <label1> <label2>]
[TEST_COMMAND <arg1> <arg2>]
)
```

## Options
Expand All @@ -188,6 +190,9 @@ function(Spglib_add_test test)
`LABELS`
Additional labels to be added

`TEST_COMMAND`
Test command to use instead of ctest

]===]

list(APPEND CMAKE_MESSAGE_CONTEXT "Spglib_add_test")
Expand All @@ -198,6 +203,7 @@ function(Spglib_add_test test)
)
set(ARGS_MultiValue
LABELS
TEST_COMMAND
)
cmake_parse_arguments(PARSE_ARGV 1 ARGS "${ARGS_Options}" "${ARGS_OneValue}" "${ARGS_MultiValue}")
# Check required/optional arguments
Expand All @@ -207,6 +213,12 @@ function(Spglib_add_test test)
if (NOT DEFINED ARGS_TEST_NAME)
set(ARGS_TEST_NAME ${test})
endif ()
if (NOT DEFINED ARGS_TEST_COMMAND)
set(ARGS_TEST_COMMAND
${CMAKE_CTEST_COMMAND} --test-dir ${CMAKE_CURRENT_BINARY_DIR}/${test} --output-on-failure
)
endif ()

set(extra_args)
if (Spglib_IS_TOP_LEVEL)
list(APPEND extra_args
Expand All @@ -233,7 +245,7 @@ function(Spglib_add_test test)
--build-generator "${CMAKE_GENERATOR}"
--build-options
${compiler_args} ${extra_args}
--test-command ${CMAKE_CTEST_COMMAND} --test-dir ${CMAKE_CURRENT_BINARY_DIR}/${test} --output-on-failure
--test-command ${ARGS_TEST_COMMAND}
)
set_tests_properties(${ARGS_TEST_NAME} PROPERTIES
LABELS "${ARGS_LABELS}"
Expand Down
30 changes: 30 additions & 0 deletions test/example/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
set_property(DIRECTORY APPEND
PROPERTY LABELS example
)

set(test_list
c_api
)
if (SPGLIB_WITH_Fortran)
list(APPEND test_list
fortran_api
)
endif ()

foreach (test IN LISTS test_list)
Spglib_add_test(${test}
TEST_NAME example-${test}
TEST_COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${test}/example && ${CMAKE_CURRENT_BINARY_DIR}/${test}/example_full
)
endforeach ()

if (SPGLIB_WITH_Python)
add_test (NAME example-python
COMMAND ${Python_EXECUTABLE} -m pytest
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/python_api/example.py
)
add_test (NAME example-python-full
COMMAND ${Python_EXECUTABLE} -m pytest
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/python_api/example_full.py
)
endif ()
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 2924ef6

Please sign in to comment.