File: ShellTests.cmake

package info (click to toggle)
mujoco 2.2.2-3.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 39,800 kB
  • sloc: ansic: 28,947; cpp: 28,897; cs: 14,241; python: 10,465; xml: 5,104; sh: 93; makefile: 34
file content (52 lines) | stat: -rw-r--r-- 2,164 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# Copyright 2021 DeepMind Technologies Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

function(add_mujoco_shell_test TEST_NAME TARGET_BINARY)
  find_program(BASH_PROGRAM bash)
  if(BASH_PROGRAM)
    # Set up the test directory
    set(TEST_TMPDIR "${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME}")
    add_test(NAME ${TEST_NAME}_setup
             COMMAND ${BASH_PROGRAM} "${PROJECT_SOURCE_DIR}/cmake/setup_test_dir.sh" ${TEST_TMPDIR}
    )
    set_tests_properties(${TEST_NAME}_setup PROPERTIES FIXTURES_SETUP ${TEST_NAME}_fixture)
    add_test(NAME ${TEST_NAME}_cleanup
             COMMAND ${BASH_PROGRAM} "${PROJECT_SOURCE_DIR}/cmake/cleanup_test_dir.sh"
                     ${TEST_TMPDIR}
    )
    set_tests_properties(${TEST_NAME}_cleanup PROPERTIES FIXTURES_CLEANUP ${TEST_NAME}_fixture)
    add_test(
      NAME ${TEST_NAME}
      COMMAND ${BASH_PROGRAM} "${CMAKE_CURRENT_SOURCE_DIR}/${TEST_NAME}.sh"
      WORKING_DIRECTORY $<TARGET_FILE_DIR:${TARGET_BINARY}>
    )
    set_tests_properties(${TEST_NAME} PROPERTIES FIXTURES_REQUIRED ${TEST_NAME}_fixture)
    set_property(
      TEST "${TEST_NAME}"
      PROPERTY ENVIRONMENT
               "CMAKE_SOURCE_DIR=${CMAKE_SOURCE_DIR}"
               "TARGET_BINARY=$<TARGET_FILE:${TARGET_BINARY}>"
               "TEST_TMPDIR=${TEST_TMPDIR}"
    )
    if(WIN32)
      # Define the directory containing the mujoco DLL library so that it can be added to the PATH.
      # We modify the PATH in the script as it is more reliable.
      set_property(
        TEST "${TEST_NAME}"
        APPEND
        PROPERTY ENVIRONMENT "MUJOCO_DLL_DIR=$<TARGET_FILE_DIR:mujoco>"
      )
    endif()
  endif()
endfunction()