forked from rstudio/shinyapps-package-dependencies
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest
executable file
·55 lines (44 loc) · 1.32 KB
/
test
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
53
54
55
#!/bin/bash
black () { color_text 30; }
blue () { color_text 34; }
green () { color_text 32; }
cyan () { color_text 36; }
red () { color_text 31; }
purple () { color_text 35; }
brown () { color_text 33; }
light_gray () { color_text 37; }
color_text () {
while read data; do echo -e "\033[$1m$data"; done
echo -e -n "\033[0m" # clear the color
}
DIR=`dirname $0`
if [ $# -eq 0 ]; then
PACKAGES=$(ls -1 -d $DIR/packages/* | grep -v gsl | tr '\n' '\0' | xargs -0 -n 1 basename)
else
PACKAGES=$@
fi
for PACKAGE in $PACKAGES; do
PACKAGE_DIR=$DIR/packages/$PACKAGE
if [ -f $PACKAGE_DIR/install ]; then
echo " ***** PACKAGE $PACKAGE" | purple
echo " ***** INSTALLING..." | purple
bash $PACKAGE_DIR/install
echo " ***** TESTING..." | purple
if [ -f $PACKAGE_DIR/test.R ]; then
sudo R --verbose -f $PACKAGE_DIR/test.R
else
sudo R -e "install.packages('$PACKAGE', repos='http://cran.rstudio.com/'); library('$PACKAGE')"
fi
return_code=$?
if [[ $return_code != 0 ]] ; then
echo "$PACKAGE... FAILED" | red
exit $return_code
else
echo "$PACKAGE... SUCCESS" | green
fi
else
echo "Unable to find '$PACKAGE' in $DIR/packages, exiting..." | red
exit 1
fi
done
exit 0