From e586d8994d5d60ad21d78316a83430d057080abb Mon Sep 17 00:00:00 2001 From: Ralph Lange Date: Wed, 13 Nov 2019 14:05:32 +0100 Subject: [PATCH] travis: add tests for utils functions and defaults --- .travis.yml | 7 +++-- defaults.set | 4 ++- test00.set | 3 ++ travis-test.sh | 73 +++++++++++++++++++++++++++++++++++++++++++++-- travis/prepare.sh | 2 +- 5 files changed, 82 insertions(+), 7 deletions(-) create mode 100644 test00.set diff --git a/.travis.yml b/.travis.yml index 0fa36bd..c00d818 100644 --- a/.travis.yml +++ b/.travis.yml @@ -48,8 +48,9 @@ script: matrix: include: -# Different configurations of default gcc and clang +# Run on Linux and Mac - - env: BASE=3.15 + - env: SET=test00 - - env: SET=test01 + - env: SET=test00 + os: osx diff --git a/defaults.set b/defaults.set index 9deaf3d..c73c4ed 100644 --- a/defaults.set +++ b/defaults.set @@ -25,9 +25,11 @@ SNCSEQ_DIRNAME=seq STREAM_REPONAME=StreamDevice STREAM_REPOOWNER=paulscherrerinstitute -# Default settings work (and are tested) for: +# The default settings also work (and are tested) for: # asyn # std # calc # autosave # busy +# sscan +# iocStats diff --git a/test00.set b/test00.set new file mode 100644 index 0000000..ff1581f --- /dev/null +++ b/test00.set @@ -0,0 +1,3 @@ +MODULES="" + +BASE=R3.15.7 diff --git a/travis-test.sh b/travis-test.sh index b1d502c..65e7e79 100755 --- a/travis-test.sh +++ b/travis-test.sh @@ -1,4 +1,73 @@ #!/bin/sh -set -e -x +set -x -echo Testing the dependency setup +UTILS_UNITTEST=1 + +# Perl version of "readlink -f" (which MacOS does not provide) +readlinkf() { perl -MCwd -e 'print Cwd::abs_path shift' "$1"; } + +# test utilities +die() { + echo $1 + exit 1 +} + +fn_exists() { + LC_ALL=C type -t $1 | grep -q function +} + +repo_exists() { + DEP=$1 + dep_lc=$(echo $DEP | tr 'A-Z' 'a-z') + eval dirname=\${${DEP}_DIRNAME:=${dep_lc}} + eval reponame=\${${DEP}_REPONAME:=${dep_lc}} + eval repourl=\${${DEP}_REPOURL:="https://github.com/\${${DEP}_REPOOWNER:=${REPOOWNER:-epics-modules}}/${reponame}.git"} + + git ls-remote --quiet --heads --exit-code $repourl > /dev/null 2>&1 +} + +SETUP_DIRS=$(echo $SETUP_PATH | tr ":" "\n") + +SCRIPTDIR=$(dirname $(readlinkf $0))/travis +CURDIR="$PWD" +CACHEDIR="$HOME/.cache" +SOURCEDIR="$HOME/.source" + +echo "Testing contents of utils.sh" + +[ -d "$SCRIPTDIR" ] || die "SCRIPTDIR does not exist" +[ -e "$SCRIPTDIR/utils.sh" ] || die "SCRIPTDIR/utils.sh does not exist" + +# source functions +. $SCRIPTDIR/utils.sh + +# check for functions +fn_exists fold_start || die "function fold_start missing from SCRIPTDIR/utils.sh" +fn_exists fold_end || die "function fold_end missing from SCRIPTDIR/utils.sh" +fn_exists source_set || die "function source_set missing from SCRIPTDIR/utils.sh" +fn_exists update_release_local || die "function update_release_local missing from SCRIPTDIR/utils.sh" +fn_exists add_dependency || die "function add_dependency missing from SCRIPTDIR/utils.sh" + +# test source_set () + +source_set xxdoesnotexistxx | grep -q "does not exist" || die "missing setup file not detected" +source_set test01 | grep -q "Loading setup file" || die "test01 setup file not found" + +echo "Testing default settings for completeness and valid git repo settings" + +[ -e ./defaults.set ] || die "defaults.set does not exist" +source_set defaults + +repo_exists BASE || die "Defaults for BASE do not point to a valid git repository at $repourl" +repo_exists PVDATA || die "Defaults for PVDATA do not point to a valid git repository at $repourl" +repo_exists PVACCESS || die "Defaults for PVACCESS do not point to a valid git repository at $repourl" +repo_exists NTYPES || die "Defaults for NTYPES do not point to a valid git repository at $repourl" +repo_exists SNCSEQ || die "Defaults for SNCSEQ do not point to a valid git repository at $repourl" +repo_exists STREAM || die "Defaults for STREAM do not point to a valid git repository at $repourl" +repo_exists ASYN || die "Defaults for STREAM do not point to a valid git repository at $repourl" +repo_exists STD || die "Defaults for STD do not point to a valid git repository at $repourl" +repo_exists CALC || die "Defaults for CALC do not point to a valid git repository at $repourl" +repo_exists AUTOSAVE || die "Defaults for AUTOSAVE do not point to a valid git repository at $repourl" +repo_exists BUSY || die "Defaults for BUSY do not point to a valid git repository at $repourl" +repo_exists SSCAN || die "Defaults for SSCAN do not point to a valid git repository at $repourl" +repo_exists IOCSTATS || die "Defaults for IOCSTATS do not point to a valid git repository at $repourl" diff --git a/travis/prepare.sh b/travis/prepare.sh index 83b488b..3ec978f 100755 --- a/travis/prepare.sh +++ b/travis/prepare.sh @@ -30,7 +30,7 @@ fold_end load.settings # Check out dependencies # ---------------------- -fold_start check.out.dependencies "Checking out dependencies" +fold_start check.out.dependencies "Checking/cloning dependencies" mkdir -p $SOURCEDIR