Skip to content

Commit

Permalink
Add functional tests to script (only config checks so far)
Browse files Browse the repository at this point in the history
  • Loading branch information
giacomofiorin committed Apr 1, 2022
1 parent 941c482 commit a4112e8
Show file tree
Hide file tree
Showing 83 changed files with 2,532 additions and 9 deletions.
42 changes: 33 additions & 9 deletions cmake/buildColvarsTests.cmake
Original file line number Diff line number Diff line change
@@ -1,25 +1,49 @@
if(BUILD_TESTS)

# Build functional tests' executables
add_subdirectory(${COLVARS_SOURCE_DIR}/tests/functional tests/functional)

if(DEFINED CMAKE_SYSTEM_NAME)
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
message(STATUS "Copying input files for tests")
# TODO make this portable outside Linux
add_custom_command(TARGET colvars POST_BUILD
COMMAND bash build_tests.sh
${CMAKE_BINARY_DIR}/tests/functional
WORKING_DIRECTORY ${COLVARS_SOURCE_DIR}/tests)

if(CMAKE_SYSTEM_NAME STREQUAL "Linux")

# TODO automate this step and make it OS-portable
# add_custom_command(TARGET colvars POST_BUILD
# COMMAND bash build_tests.sh
# ${CMAKE_BINARY_DIR}/tests/functional
# WORKING_DIRECTORY ${COLVARS_SOURCE_DIR}/tests)

# Copy the Colvars configuration files
file(GLOB TEST_CONFIG_FILES ${COLVARS_SOURCE_DIR}/tests/input_files/*/test.in)
foreach(TEST_CONFIG_FILE ${TEST_CONFIG_FILES})
get_filename_component(TEST_NAME ${TEST_CONFIG_FILE} DIRECTORY)
get_filename_component(TEST_NAME ${TEST_NAME} NAME)
add_custom_command(TARGET colvars POST_BUILD
COMMAND ${CMAKE_COMMAND}
-E copy ${TEST_CONFIG_FILE}
${CMAKE_BINARY_DIR}/tests/functional/${TEST_NAME}/test.in)
add_test(NAME ${TEST_NAME}
COMMAND run_colvars_test ${TEST_NAME}/test.in
WORKING_DIRECTORY
${CMAKE_CURRENT_BINARY_DIR}/tests/functional)
endforeach()

# Copy other input files (coordinates, index files, etc)
file(GLOB TEST_INPUT_FILES ${COLVARS_SOURCE_DIR}/tests/input_files/*)
message("${TEST_INPUT_FILES}")
foreach(TEST_INPUT_FILE ${TEST_INPUT_FILES})
add_custom_command(TARGET colvars POST_BUILD
COMMAND ${CMAKE_COMMAND}
-E copy ${TEST_INPUT_FILE} ${CMAKE_BINARY_DIR}/tests/functional)
-E copy ${TEST_INPUT_FILE}
${CMAKE_BINARY_DIR}/tests/functional)
endforeach(TEST_INPUT_FILE)

endif()
endif()
enable_testing()
endif()

option(BUILD_UNITTESTS "Build unit tests" ${BUILD_TESTS})
if(BUILD_UNITTESTS)
# Build unit tests executables
add_subdirectory(${COLVARS_SOURCE_DIR}/tests/unittests tests/unittests)
endif()
11 changes: 11 additions & 0 deletions devel-tools/build_test_library.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,14 @@ execute_process(
if(NOT result EQUAL 0)
message(FATAL_ERROR "Error building library.")
endif()


execute_process(
COMMAND ${CMAKE_CTEST_COMMAND}
--test-dir ${BUILD_DIR}
RESULT_VARIABLE result
)

if(NOT result EQUAL 0)
message(FATAL_ERROR "Error running tests.")
endif()
30 changes: 30 additions & 0 deletions tests/input_files/angle_harmonic-fixed/test.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
colvarsTrajFrequency 1
colvarsRestartFrequency 10
indexFile index.ndx

colvar {

name one

outputAppliedForce on

width 0.5

angle {
group1 {
indexGroup group1
}
group2 {
indexGroup group2
}
group3 {
indexGroup group3
}
}
}

harmonic {
colvars one
centers 0.1
forceConstant 0.001
}
29 changes: 29 additions & 0 deletions tests/input_files/coordnum-aniso-pairlist_harmonic-fixed/test.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
colvarsTrajFrequency 1
colvarsRestartFrequency 10
indexFile index.ndx

colvar {

name one
outputAppliedForce on

width 0.5

coordNum {
cutoff3 (0.3, 0.6, 0.4)
group1 {
indexGroup group1
}
group2 {
indexGroup group2
}
tolerance 0.01
pairListFrequency 2
}
}

harmonic {
colvars one
centers 0.1
forceConstant 0.001
}
28 changes: 28 additions & 0 deletions tests/input_files/coordnum-aniso_harmonic-fixed/test.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
colvarsTrajFrequency 1
colvarsRestartFrequency 10
indexFile index.ndx

colvar {

name one

outputAppliedForce on

width 0.5

coordNum {
cutoff3 (0.3, 0.6, 0.4)
group1 {
indexGroup group1
}
group2 {
indexGroup group2
}
}
}

harmonic {
colvars one
centers 0.1
forceConstant 0.001
}
28 changes: 28 additions & 0 deletions tests/input_files/coordnum-group2centeronly_harmonic-fixed/test.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
colvarsTrajFrequency 1
colvarsRestartFrequency 10
indexFile index.ndx

colvar {

name one

outputAppliedForce on

width 0.5

coordNum {
group1 {
indexGroup group1
}
group2 {
indexGroup group2
}
group2CenterOnly yes
}
}

harmonic {
colvars one
centers 0.1
forceConstant 0.001
}
29 changes: 29 additions & 0 deletions tests/input_files/coordnum-pairlist_harmonic-fixed/test.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
colvarsTrajFrequency 1
colvarsRestartFrequency 10
indexFile index.ndx

colvar {

name one

outputAppliedForce on

width 0.5

coordNum {
group1 {
indexGroup group1
}
group2 {
indexGroup group2
}
tolerance 0.01
pairListFrequency 2
}
}

harmonic {
colvars one
centers 0.1
forceConstant 0.001
}
27 changes: 27 additions & 0 deletions tests/input_files/coordnum_harmonic-fixed/test.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
colvarsTrajFrequency 1
colvarsRestartFrequency 10
indexFile index.ndx

colvar {

name one

outputAppliedForce on

width 0.5

coordNum {
group1 {
indexGroup group1
}
group2 {
indexGroup group2
}
}
}

harmonic {
colvars one
centers 0.1
forceConstant 0.001
}
4 changes: 4 additions & 0 deletions tests/input_files/customfunction_harmonic-fixed/test.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
colvarsTrajFrequency 1
colvarsRestartFrequency 10
indexFile index.ndx

33 changes: 33 additions & 0 deletions tests/input_files/dihedral_harmonic-fixed/test.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
colvarsTrajFrequency 1
colvarsRestartFrequency 10
indexFile index.ndx

colvar {

name one

outputAppliedForce on

width 0.5

dihedral {
group1 {
indexGroup group1
}
group2 {
indexGroup group2
}
group3 {
indexGroup group3
}
group4 {
indexGroup group4
}
}
}

harmonic {
colvars one
centers 0.1
forceConstant 0.001
}
36 changes: 36 additions & 0 deletions tests/input_files/dihedral_histogram-customgrid-periodic/test.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
colvarsTrajFrequency 1
colvarsRestartFrequency 10
indexFile index.ndx

colvar {

name one

outputAppliedForce on

width 0.5

dihedral {
group1 {
indexGroup group1
}
group2 {
indexGroup group2
}
group3 {
indexGroup group3
}
group4 {
indexGroup group4
}
}
}

histogram {
colvars one
histogramGrid {
widths 5
lowerBoundaries -60
upperBoundaries 300
}
}
34 changes: 34 additions & 0 deletions tests/input_files/dihedralwalls/test.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
colvarsTrajFrequency 1
colvarsRestartFrequency 10
indexFile index.ndx

colvar {

name one

outputAppliedForce on

width 0.5

dihedral {
group1 {
indexGroup group1
}
group2 {
indexGroup group2
}
group3 {
indexGroup group3
}
group4 {
indexGroup group4
}
}
}

harmonicWalls {
colvars one
lowerWalls -10.0
upperWalls +10.0
forceConstant 0.001
}
30 changes: 30 additions & 0 deletions tests/input_files/dipoleangle_harmonic-fixed/test.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
colvarsTrajFrequency 1
colvarsRestartFrequency 10
indexFile index.ndx

colvar {

name one

outputAppliedForce on

width 0.5

dipoleAngle {
group1 {
indexGroup group1
}
group2 {
indexGroup group2
}
group3 {
indexGroup group3
}
}
}

harmonic {
colvars one
centers 0.1
forceConstant 0.001
}
Loading

0 comments on commit a4112e8

Please sign in to comment.