Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CMake not adding some tests #104

Merged
merged 7 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 30 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,26 +59,45 @@ foreach(TEST_PATH ${TEST_PATHS})
add_test(${TEST_NAME} ${TEST_NAME})
endforeach()

# List of directories containing test scripts
set(PYTHON_TEST_DIRS
${CMAKE_SOURCE_DIR}/src/pytorch/
${CMAKE_SOURCE_DIR}/src/pytorch/neighbors
RaulPPelaez marked this conversation as resolved.
Show resolved Hide resolved
${CMAKE_SOURCE_DIR}/src/pytorch/pme
)

# Move test scripts to a test folder in the build directory, create test folder if necessary
add_custom_target(copy_test ALL
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/test
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_SOURCE_DIR}/src/pytorch/Test*.py
${CMAKE_SOURCE_DIR}/src/pytorch/neighbors/Test*.py
${CMAKE_SOURCE_DIR}/src/pytorch/neighbors/getNeighborPairs.py
${CMAKE_SOURCE_DIR}/src/pytorch/pme/Test*.py
${CMAKE_BINARY_DIR}/test
)

# Add the data directory as well
add_custom_command(
TARGET copy_test POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/src/pytorch/molecules
${CMAKE_BINARY_DIR}/test/molecules
)

# Add tests for all scripts in the test directory
file(GLOB_RECURSE PYTHON_TEST_PATHS ${CMAKE_BINARY_DIR}/test/Test*.py)
foreach(TEST_PATH ${PYTHON_TEST_PATHS})
cmake_path(GET TEST_PATH STEM TEST_NAME)
add_test(${TEST_NAME} pytest -v ${CMAKE_BINARY_DIR}/test/${TEST_NAME}.py)
# Copy each test to the binary dir and add it
foreach(TEST_DIR ${PYTHON_TEST_DIRS})
file(GLOB TEST_SCRIPTS ${TEST_DIR}/Test*.py)
foreach(TEST_SCRIPT ${TEST_SCRIPTS})
get_filename_component(TEST_NAME ${TEST_SCRIPT} NAME_WE)
file(RELATIVE_PATH RELATIVE_TEST_PATH ${CMAKE_SOURCE_DIR}/src/pytorch ${TEST_SCRIPT})
add_custom_command(
TARGET copy_test POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${TEST_SCRIPT} ${CMAKE_BINARY_DIR}/test/${RELATIVE_TEST_PATH}
)
add_test(NAME ${TEST_NAME} COMMAND pytest -v ${CMAKE_BINARY_DIR}/test/${RELATIVE_TEST_PATH})
endforeach()
endforeach()

add_custom_command(
TARGET copy_test POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/src/pytorch/neighbors/getNeighborPairs.py ${CMAKE_BINARY_DIR}/test/getNeighborPairs.py
)

add_test(TestGetNeighborPairs pytest -v --doctest-modules ${CMAKE_BINARY_DIR}/test/getNeighborPairs.py)

# Installation
Expand Down
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ dependencies:
- python 3.10.*
- pytorch-gpu 2.0.*
- sysroot_linux-64 2.17

16 changes: 8 additions & 8 deletions src/pytorch/molecules/1hvj_ligand.mol2
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ USER_CHARGES

@<TRIPOS>ATOM
1 C1 3.4440 3.3887 10.7035 zw 1 A78 0.766100
2 O2 3.2004 4.2657 11.5137 z‚ 1 A78 -0.669100
3 N3 4.0410 3.6349 9.4679 z€ 1 A78 -0.445800
2 O2 3.2004 4.2657 11.5137 z 1 A78 -0.669100
3 N3 4.0410 3.6349 9.4679 z 1 A78 -0.445800
4 C4 4.2905 2.5750 8.4667 c3 1 A78 0.072300
5 C5 4.5571 4.9758 9.1200 za 1 A78 0.046700
6 C6 6.0491 5.1114 9.4017 zo 1 A78 0.372600
Expand All @@ -20,7 +20,7 @@ USER_CHARGES
12 N22 3.1777 2.0550 10.9450 z| 1 A78 -0.557900
13 C23 2.6353 1.5314 12.2140 zb 1 A78 0.044700
14 C24 3.6764 0.5489 12.7936 zx 1 A78 0.653100
15 O25 3.4215 -0.6062 13.0869 z‚ 1 A78 -0.634100
15 O25 3.4215 -0.6062 13.0869 z 1 A78 -0.634100
16 C26 1.1960 0.9387 12.0510 zh 1 A78 -0.074700
17 C27 0.5342 0.6636 13.4290 zi 1 A78 -0.094600
18 C28 0.2755 1.8727 11.2187 zi 1 A78 -0.094600
Expand All @@ -34,7 +34,7 @@ USER_CHARGES
26 C45 6.5634 -0.7826 9.1129 ca 1 A78 -0.133000
27 C46 6.6724 -0.6210 10.5037 zr 1 A78 -0.123000
28 C47 6.3818 0.6114 14.8979 zj 1 A78 -0.123400
29 O48 5.4918 0.6100 17.1615 zƒ 1 A78 -0.608800
29 O48 5.4918 0.6100 17.1615 z 1 A78 -0.608800
30 C49 5.2282 0.1487 15.8325 zk 1 A78 0.125100
31 N50 6.1967 -2.0921 16.4025 z~ 1 A78 -0.538900
32 C51 5.0294 -1.3972 15.8311 zm 1 A78 0.103700
Expand All @@ -45,16 +45,16 @@ USER_CHARGES
37 C56 3.1116 -6.1003 16.4218 ca 1 A78 -0.136000
38 C57 2.8290 -5.3098 15.2970 ca 1 A78 -0.132500
39 C58 3.0128 -3.9187 15.3507 zt 1 A78 -0.123500
40 N81 7.1331 -5.5620 16.8647 z 1 A78 -0.539900
40 N81 7.1331 -5.5620 16.8647 z 1 A78 -0.539900
41 C82 7.4436 -4.1278 17.0194 zc 1 A78 0.034700
42 C83 6.6091 -3.3476 15.9854 zy 1 A78 0.658100
43 O84 6.2884 -3.8198 14.9065 z‚ 1 A78 -0.633100
43 O84 6.2884 -3.8198 14.9065 z 1 A78 -0.633100
44 C85 8.9768 -3.8384 16.8891 ze 1 A78 -0.086700
45 C86 9.3055 -2.3257 16.9980 zf 1 A78 -0.095100
46 C87 9.8090 -4.6280 17.9340 zf 1 A78 -0.095100
47 C97 6.9688 -6.4414 17.9188 zz 1 A78 0.754100
48 O98 7.1154 -6.1080 19.0818 z‚ 1 A78 -0.657100
49 N99 6.6109 -7.7343 17.5371 z 1 A78 -0.445800
48 O98 7.1154 -6.1080 19.0818 z 1 A78 -0.657100
49 N99 6.6109 -7.7343 17.5371 z 1 A78 -0.445800
50 C2 6.4191 -8.1324 16.1243 c3 1 A78 0.059300
51 C3 6.3450 -8.7797 18.5509 zd 1 A78 0.038700
52 C8 4.9082 -8.7509 19.0589 zu 1 A78 0.359600
Expand Down