Commit 1afe91fa authored by David Keitel's avatar David Keitel
Browse files

Merge branch 'cw-python-test-scripts' into 'master'

Allow test scripts for CW codes in LALApps to be written in Python

See merge request lscsoft/lalsuite!1363
parents 047c7b71 a277127d
......@@ -4,12 +4,13 @@ echo "--- Test compiler is $0 ---"
echo
# Parse command line
skip_tests="$1"
test="$2"
script_extn="$1"
skip_tests="$2"
test="$3"
echo "skip_tests='${skip_tests}'"
echo "test='${test}'"
echo
if [ "X#2" = X ]; then
if [ "X$3" = X ]; then
echo "Invalid command line"
exit 1
fi
......@@ -25,12 +26,12 @@ if [ "X${LAL_TEST_BUILDDIR}" = X ]; then
fi
# Test script name and location
scriptname=$(expr "X${test}" : "X.*/\(test[^/]*\)\.sh$")
if [ "X${scriptname}" = X ]; then
script_name=$(expr "X${test}" : "X.*/\(test[^/]*\)\.${script_extn}$")
if [ "X${script_name}" = X ]; then
echo "Could not parse name of test script from '${test}'"
exit 1
fi
script="${LAL_TEST_SRCDIR}/${scriptname}.sh"
script="${LAL_TEST_SRCDIR}/${script_name}.${script_extn}"
if [ ! -f "${script}" ]; then
echo "Test script '${script}' does not exist"
exit 1
......@@ -42,14 +43,14 @@ fi
# Skip test if requested
case " ${skip_tests} " in
*" ${scriptname}.sh "*)
*" ${script_name}.${script_extn} "*)
echo "Skipping test ${test}"
exit 77
;;
esac
# Create directory for test
testdir="${LAL_TEST_BUILDDIR}/${scriptname}.testdir"
testdir="${LAL_TEST_BUILDDIR}/${script_name}.testdir"
rm -rf "${testdir}"
if [ -d "${testdir}" ]; then
echo "Could not remove test directory '${testdir}'"
......@@ -58,7 +59,7 @@ fi
mkdir -p "${testdir}"
# Extract any reference results, and check validity
reftarball="${LAL_TEST_SRCDIR}/${scriptname}.tar.gz"
reftarball="${LAL_TEST_SRCDIR}/${script_name}.tar.gz"
if [ -f ${reftarball} ]; then
echo "Extracting reference tarball ${reftarball}"
cd "${testdir}"
......@@ -109,14 +110,27 @@ echo
echo "--- Running test ${test} ---"
echo
cd "${testdir}"
export TIMEFORMAT=$'\n\n\nreal %R\nuser %R\nsys %R'
time bash -c "\
set -e; \
export LAL_TEST_SRCDIR=/dev/null/; \
export LAL_TEST_BUILDDIR=/dev/null/; \
export srcdir=/dev/null/; \
export builddir=/dev/null/; \
source '${script}'" && status=$? || status=$?
set +e
(
export LAL_TEST_SRCDIR=/dev/null/
export LAL_TEST_BUILDDIR=/dev/null/
export srcdir=/dev/null/
export builddir=/dev/null/
case "${script_extn}" in
sh)
time bash "${script}"
;;
py)
time ${PYTHON} "${script}"
;;
*)
echo "Test script '${script}' does not have a recognised extension"
exit 1
;;
esac
)
status=$?
set -e
cd "${LAL_TEST_BUILDDIR}"
echo
case $status in
......
......@@ -24,4 +24,5 @@ TESTS_ENVIRONMENT = \
export LAL_TEST_SRCDIR; LAL_TEST_SRCDIR="$(abs_srcdir)"; \
export LAL_TEST_BUILDDIR; LAL_TEST_BUILDDIR="$(abs_builddir)"; \
export LAL_DATA_PATH; LAL_DATA_PATH="$(LAL_DATA_PATH)"; \
export PYTHON; PYTHON="$(PYTHON)"; \
$(END_OF_LIST)
......@@ -12,14 +12,15 @@ test_script_compiler = $(top_srcdir)/gnuscripts/lalapps-pulsar-test-compiler.sh
EXTRA_DIST += $(test_script_compiler)
skip_tests =
TEST_EXTENSIONS = .sh
SH_LOG_COMPILER = /bin/bash $(test_script_compiler) "$(skip_tests)"
TEST_EXTENSIONS = .sh .py
SH_LOG_COMPILER = /bin/bash $(test_script_compiler) sh "$(skip_tests)"
PY_LOG_COMPILER = /bin/bash $(test_script_compiler) py "$(skip_tests)"
clean-local: clean-local-test-dirs
clean-local-test-dirs:
@for file in $(test_scripts); do \
case $${file} in \
*.sh) \
*.sh|*.py) \
scriptname=`expr "X$${file}" : "X\([^/]*\)\.sh$$"`; \
echo " rm -rf $${scriptname}.testdir/"; \
rm -rf $${scriptname}.testdir/ || exit 1; \
......@@ -30,7 +31,7 @@ clean-local-test-dirs:
dist-hook: test-ref-tarball-dist-hook
@for file in $(test_scripts); do \
case $${file} in \
*.sh) \
*.sh|*.py) \
scriptname=`expr "X$${file}" : "X\([^/]*\)\.sh$$"`; \
if test -r "$(srcdir)/$${scriptname}.tar.gz"; then \
cp "$(srcdir)/$${scriptname}.tar.gz" "$(distdir)/$${scriptname}.tar.gz"; \
......
BUILT_SOURCES =
EXTRA_DIST =
MOSTLYCLEANFILES =
include $(top_srcdir)/gnuscripts/lalapps.am
include $(top_srcdir)/gnuscripts/lalapps_pulsar_test.am
include $(top_srcdir)/gnuscripts/lalsuite_help2man.am
# Makefile for fscan
......
BUILT_SOURCES =
EXTRA_DIST =
MOSTLYCLEANFILES =
include $(top_srcdir)/gnuscripts/lalapps.am
include $(top_srcdir)/gnuscripts/lalapps_pulsar_test.am
include $(top_srcdir)/gnuscripts/lalsuite_help2man.am
AM_CPPFLAGS += -I$(top_srcdir)/src/pulsar/Fstatistic
......
BUILT_SOURCES =
EXTRA_DIST =
MOSTLYCLEANFILES =
include $(top_srcdir)/gnuscripts/lalapps.am
include $(top_srcdir)/gnuscripts/lalapps_pulsar_test.am
include $(top_srcdir)/gnuscripts/lalsuite_help2man.am
AM_CPPFLAGS += -I$(top_srcdir)/src/pulsar/Fstatistic
......
BUILT_SOURCES =
EXTRA_DIST =
MOSTLYCLEANFILES =
include $(top_srcdir)/gnuscripts/lalapps.am
include $(top_srcdir)/gnuscripts/lalapps_pulsar_test.am
include $(top_srcdir)/gnuscripts/lalsuite_help2man.am
bin_PROGRAMS = lalapps_CombSearch
......
BUILT_SOURCES =
EXTRA_DIST =
MOSTLYCLEANFILES =
include $(top_srcdir)/gnuscripts/lalapps.am
include $(top_srcdir)/gnuscripts/lalapps_pulsar_test.am
include $(top_srcdir)/gnuscripts/lalsuite_help2man.am
bin_PROGRAMS = lalapps_TwoSpect \
......@@ -62,3 +64,6 @@ testVectorMath_SOURCES = helperprograms/testVectorMath.c \
computeSignalDetector_SOURCES = helperprograms/computeSignalDetector.c \
TwoSpectSpecFunc.c \
TwoSpectSpecFunc.h
# Add shell test scripts to this variable
test_scripts += testTwoSpect.py
import os, sys
# test that local TwoSpect executable can be called
os.system("lalapps_TwoSpect --version")
# return test status 'SKIP', since this test doesn't really do anything yet
sys.exit(77)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment