1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
#!/bin/sh
# autopkgtest check: build and run pymol scripts from directory and subdirectories.
# ignores errors appearing inside PYMOL command line but looks for tracebacks or
# exceptions being raised. pymol provides no indication of successful exit when
# run in batch mode.
# Author: Tatiana Malygina <merlettaia@gmail.com>
set -e
testsdir="$(cd "$1" && pwd)"
skipped_pattern="$2" # this is optional
echo "Search pymol scripts in $testsdir..."
pkg=pymol
if [ "$ADTTMP" = "" ] ; then
ADTTMP=$(mktemp -d /tmp/${pkg}-test.XXXXXX)
trap "rm -rf $ADTTMP" 0 INT QUIT ABRT PIPE TERM
fi
cd $ADTTMP
error_lines="Traceback
raise
error"
for dir in $(find $testsdir -type d); do
echo "Processing new directory $dir"
# 1. select .py and .pml and run with pymol in temporary dir
for file in $(find $dir/* -name '*.py' -or -name '*.pml'); do
if [ -n "$skipped_pattern" ]; then
if [ -n "$(echo $file | egrep $skipped_pattern)" ]; then
echo "Skip $file"
# skip file if it matches provided pattern
continue
fi
fi
command=$(pymol -c $file)
echo "Run 'pymol -c $file'..."
error_lines_present=`echo "$command" | grep -F -i "$error_lines"` || true
if [ -n "$error_lines_present" ]; then
echo -n "\033[35m"
pymol -c $file
echo -n "\033[0m"
echo '\t\033[31;1mnot ok - error-related patterns were found in pymol output\033[0m'
[ -n "$error_lines_present" ]
fi
done
# 2. delete all files and symlinks in current directory after folder processing, processing next
for file in $(find -P . -type f); do
rm $file
done
done
|