Skip to content

Commit

Permalink
Add extra CMake install path check
Browse files Browse the repository at this point in the history
  • Loading branch information
jngrad committed Oct 17, 2019
1 parent f0642c8 commit c43d057
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
22 changes: 21 additions & 1 deletion testsuite/cmake/BashUnitTests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,27 @@ function assert_file_exists() {
fi
}

## @brief Check if two variables are identical
## @brief Check if two strings are identical
## @param $1 Obtained result
## @param $2 Expected result
## @param $3 Message on failure (optional)
function assert_string_equal() {
local -r result=$1
local -r expected=$2
local message=$3
if [ -z "${message}" ]
then
message="${result} != ${expected}"
fi
if [ "${result}" = "${expected}" ]
then
log_success
else
log_failure "${message}"
fi
}

## @brief Check if two integers are identical
## @param $1 Obtained result
## @param $2 Expected result
## @param $3 Message on failure (optional)
Expand Down
10 changes: 8 additions & 2 deletions testsuite/cmake/test_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,23 @@ source BashUnitTests.sh

# test installation and Python bindings
function test_install() {
local -r site_package_espressomd="@CMAKE_INSTALL_PREFIX@/@Python_SITEARCH@/espressomd"
local -r site_package_espressomd="$(realpath '@CMAKE_INSTALL_PREFIX@/@Python_SITEARCH@/espressomd')"

# check Python files were installed in espressomd
local -r filepaths=("@CMAKE_INSTALL_FULL_BINDIR@/pypresso" \
"${site_package_espressomd}/EspressoCore.so" \
"${site_package_espressomd}/_init.so" \
"${site_package_espressomd}/__init__.py"
)

for filepath in ${filepaths[@]}; do
assert_file_exists "${filepath}"
done

# check no Python file was installed outside espressomd
paths=$(find "@CMAKE_INSTALL_PREFIX@" -path "${site_package_espressomd}" -prune -o \( -name '*.py' -o -name '*.so' \) -print)
count=$(echo "${paths}" | wc -l)
assert_string_equal "${paths}" "" "${count} files were installed in the wrong directories:"$'\n'"${paths}"

# check the espressomd module can be imported from pypresso
assert_return_code "@CMAKE_INSTALL_FULL_BINDIR@/pypresso" -c "import espressomd"
}
Expand Down

0 comments on commit c43d057

Please sign in to comment.