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

Refactor rm -rf from testsuite script #2664

Merged
merged 7 commits into from
Jun 2, 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
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ add_custom_target( installcheck
COMMAND ${CMAKE_COMMAND} -E env
${CMAKE_INSTALL_FULL_DATADIR}/testsuite/do_tests.sh
--prefix=${CMAKE_INSTALL_PREFIX}
--report-dir="${PROJECT_BINARY_DIR}/reports"
${TEST_OPTS}
WORKING_DIRECTORY "${PROJECT_BINARY_DIR}"
COMMENT "Executing NEST's testsuite..."
Expand Down
44 changes: 22 additions & 22 deletions testsuite/do_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,10 @@ usage ()
fi

cat <<EOF
Usage: $0 --prefix=<path> --report-dir=<path> [options]
Usage: $0 --prefix=<path> [options]

Required arguments:
--prefix=<path> The base installation path of NEST
--report-dir=<path> The directory to store the output to

Options:
--with-python=<exe> The Python executable to use
Expand All @@ -66,7 +65,6 @@ EOF
}

PREFIX=""
REPORTDIR=""
PYTHON=""
MUSIC=""
while test $# -gt 0 ; do
Expand All @@ -77,9 +75,6 @@ while test $# -gt 0 ; do
--prefix=*)
PREFIX="$( echo "$1" | sed 's/^--prefix=//' )"
;;
--report-dir=*)
REPORTDIR="$( echo "$1" | sed 's/^--report-dir=//' )"
;;
--with-python=*)
PYTHON="$( echo "$1" | sed 's/^--with-python=//' )"
;;
Expand All @@ -97,10 +92,6 @@ if test ! "${PREFIX:-}"; then
usage 2 "--prefix";
fi

if test ! "${REPORTDIR:-}"; then
usage 2 "--report-dir";
fi

if test "${PYTHON}"; then
TIME_LIMIT=120 # seconds, for each of the Python tests
PYTEST_VERSION="$(${PYTHON} -m pytest --version --timeout ${TIME_LIMIT} --numprocesses=1 2>&1)" || {
Expand All @@ -121,12 +112,23 @@ fi
. "$(dirname $0)/junit_xml.sh"
. "$(dirname $0)/run_test.sh"

if test -d "${REPORTDIR}"; then
rm -rf "${REPORTDIR}"
TEST_BASEDIR="${PREFIX}/share/nest/testsuite"

# create the report directory in TEST_BASEDIR. Save and restore the old value
# of TMPDIR.

if [[ "${TMPDIR-}" ]]; then
OLD_TMPDIR=$TMPDIR
fi

TMPDIR=$TEST_BASEDIR
REPORTDIR="$(mktemp -d test_report_XXX)"

if [[ "${OLD_TMPDIR-}" ]]; then
TMPDIR=OLD_TMPDIR
unset OLD_TMPDIR
fi
mkdir "${REPORTDIR}"

TEST_BASEDIR="${PREFIX}/share/nest/testsuite"
TEST_LOGFILE="${REPORTDIR}/installcheck.log"
TEST_OUTFILE="${REPORTDIR}/output.log"
TEST_RETFILE="${REPORTDIR}/output.ret"
Expand Down Expand Up @@ -392,7 +394,7 @@ if test "${MUSIC}"; then

# Create a temporary directory with a unique name.
BASEDIR="$PWD"
tmpdir="$(mktemp -d)"
TMPDIR_MUSIC="$(mktemp -d)"

TESTDIR="${TEST_BASEDIR}/musictests/"

Expand Down Expand Up @@ -421,16 +423,16 @@ if test "${MUSIC}"; then
echo "Running test '${test_name}' with $np $proc_txt... " >> "${TEST_LOGFILE}"
printf '%s' " Running test '${test_name}' with $np $proc_txt... "

# Copy everything to 'tmpdir'.
# Copy everything to TMPDIR_MUSIC.
# Variables might also be empty. To prevent 'cp' from terminating in such a case,
# the exit code is suppressed.
cp ${music_file} ${sh_file} ${input_file} ${sli_files} ${tmpdir} 2>/dev/null || true
cp ${music_file} ${sh_file} ${input_file} ${sli_files} ${TMPDIR_MUSIC} 2>/dev/null || true

# Create the runner script in 'tmpdir'.
cd "${tmpdir}"
# Create the runner script in TMPDIR_MUSIC.
cd "${TMPDIR_MUSIC}"
echo "#!/bin/sh" > runner.sh
echo "set +e" >> runner.sh
echo "NEST_DATA_PATH=\"${tmpdir}\"" >> runner.sh
echo "NEST_DATA_PATH=\"${TMPDIR_MUSIC}\"" >> runner.sh
echo "${test_command} > ${TEST_OUTFILE} 2>&1" >> runner.sh
if test -n "${sh_file}"; then
chmod 755 "$(basename "${sh_file}")"
Expand Down Expand Up @@ -481,8 +483,6 @@ if test "${MUSIC}"; then
cd "${BASEDIR}"
done

rm -rf "$tmpdir"

junit_close
else
echo " Not running MUSIC tests because NEST was compiled without support"
Expand Down
Loading