Skip to content

Commit e244112

Browse files
authored
Fix travis (spacetelescope#471)
* Fix travis configuration * Add runtime smoke tests * Add check_exec script (CI) * Use check_exec
1 parent 11b1be9 commit e244112

File tree

2 files changed

+115
-6
lines changed

2 files changed

+115
-6
lines changed

.ci/bin/check_exec

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
#!/bin/bash
2+
argc=$#
3+
argv=("$@")
4+
5+
6+
# Does argv contain '--'?
7+
#
8+
# returns:
9+
# 0 = no
10+
# 1 = yes
11+
function has_double_dash() {
12+
local have_double_dash=0
13+
for arg in "${argv[@]}"; do
14+
if [[ "$arg" == "--" ]]; then
15+
have_double_dash=1
16+
fi
17+
done
18+
echo $have_double_dash
19+
}
20+
21+
# Copy arguments and programs to appropriate global arrays
22+
#
23+
# params:
24+
# array = arguments passed to the program (i.e. "${argv[@]}")
25+
#
26+
# returns:
27+
# nothing
28+
function init_check_exec() {
29+
while [[ $1 != "--" ]] && [[ $# != 0 ]]; do
30+
args+=("$1")
31+
shift
32+
done
33+
shift
34+
35+
while [[ $# != 0 ]]; do
36+
programs+=("$1")
37+
shift
38+
done
39+
}
40+
41+
42+
# main
43+
44+
logfile=
45+
errors=0
46+
args=()
47+
programs=()
48+
49+
if [[ ${argc} < 2 ]]; then
50+
echo "usage: $0 {argument ...} -- {program ...}"
51+
echo
52+
echo "argument - Argument(s) to pass to {program ...}"
53+
echo "-- - Delimiter to separate arguments from programs (required)"
54+
echo "program - Program(s) to execute"
55+
echo
56+
exit 1
57+
fi
58+
59+
if [[ $(has_double_dash) == 0 ]]; then
60+
echo "'--' not found in argument list." >&2
61+
exit 1
62+
fi
63+
64+
init_check_exec "${argv[@]}"
65+
66+
logfile=$(mktemp)
67+
if [[ ! -f ${logfile} ]] || [[ -z ${logfile} ]]; then
68+
echo "Failed to create temporary file." >&2
69+
exit 1
70+
fi
71+
72+
for program in "${programs[@]}"; do
73+
/bin/echo -n "Checking '$(basename $program) ${args[@]}'... "
74+
75+
# Execute program with arguments
76+
${program} ${args[@]} &>${logfile}
77+
code=$?
78+
79+
# Check exit code
80+
if (( $code != 0 )); then
81+
echo "FAILED (code: $code)";
82+
echo
83+
/bin/echo -n "OUTPUT: "
84+
if (( $(du $logfile | awk '{ print $1 }') > 0 )); then
85+
echo
86+
cat "${logfile}"
87+
else
88+
echo "[No output]"
89+
fi
90+
91+
echo
92+
(( errors++ ))
93+
else
94+
echo "OK"
95+
fi
96+
done
97+
98+
# nuke log file
99+
[[ -f "${logfile}" ]] && rm -f "${logfile}"
100+
101+
(( $errors != 0 )) && exit 1
102+
exit 0

.travis.yml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,37 @@
1+
#bump
12
language: c
2-
sudo: false
33

44
env:
55
global:
66
# Set defaults to avoid repeating in most cases
77
- ASTROCONDA=http://ssb.stsci.edu/astroconda
8-
- CONDA_DEPS="cfitsio curl gcc pkg-config"
8+
- CONDA_DEPS="cfitsio curl pkg-config"
99
- EXE_PREFIX="/tmp/miniconda3"
1010
- PYTHON_VERSION=3.6
1111
- WAF_ARGS_CONFIGURE="-v"
1212
- WAF_ARGS_BUILD="-v"
1313
- WAF_ARGS_INSTALL="-v"
1414

15-
matrix:
15+
jobs:
1616
fast_finish: true
1717

1818
include:
19+
- os: linux
20+
compiler: gcc
21+
dist: xenial
22+
1923
- os: osx
2024
compiler: clang
2125
env:
2226
- CC="clang"
23-
27+
- FC="/usr/local/bin/gfortran"
28+
- WAF_ARGS_CONFIGURE="-v --with-cfitsio=$EXE_PREFIX/envs/test"
2429
before_install:
2530
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then export CONDA_INSTALLER=https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh; fi
31+
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get -y update && sudo apt-get -y install gfortran; fi
2632
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export CONDA_INSTALLER=https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh; fi
33+
# "|| true" is bad, but tar failing to set permissions is too. oh well.
34+
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then curl -L https://downloads.sourceforge.net/project/hpc/hpc/g95/gfortran-8.3-bin.tar.gz | sudo tar xfvz - -C / || true; fi
2735
- wget $CONDA_INSTALLER
2836
- bash Miniconda3-latest-*.sh -b -p $EXE_PREFIX
2937
- export PATH=$EXE_PREFIX/bin:$PATH
@@ -37,5 +45,4 @@ install:
3745
- ./waf install $WAF_ARGS_INSTALL
3846

3947
script:
40-
# Without this dead call, "language: c" runs its own WAF-unaware script
41-
- python --version
48+
- .ci/bin/check_exec --version -- $(find $CONDA_PREFIX/bin -name '*.e')

0 commit comments

Comments
 (0)