The R Project SVN R

Rev

Rev 7218 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7218 Rev 7357
Line 1... Line 1...
1
#!/bin/sh
1
#!/bin/sh
2
 
2
 
3
# ${R_HOME}/bin/check for checking installed add-on packages
3
# ${R_HOME}/bin/check for checking installed add-on packages
4
 
4
 
5
REVISION='$Revision: 1.10 $'
5
revision='$Revision: 1.11 $'
6
VERSION=`set - ${REVISION}; echo ${2}`
6
version=`set - ${revision}; echo ${2}`
-
 
7
version="R package checker ${version}
-
 
8
 
-
 
9
Copyright (C) 2000 R Development Core Team.
-
 
10
There is NO warranty.  You may redistribute this software under the
-
 
11
terms of the GNU General Public License.
-
 
12
For more information about these matters, see the files named COPYING."
-
 
13
 
7
USAGE_MSG="Usage: R CMD check [options] [-l lib] pkg_1 ... pkg_n"
14
usage="Usage: R CMD check [options] pkgs
-
 
15
 
-
 
16
Check installed R packages specified by pkgs.
-
 
17
Currently, the only check performed is whether the examples provided by
-
 
18
the packages' documentation can be run successfully.
-
 
19
Other means for regression testing will be added in the future.
-
 
20
 
-
 
21
If an element of pkgs is a relative or absolute path to the sources of a
-
 
22
package, it is attempted to re-build the examples from the Rd sources
-
 
23
(unless \`--no-rebuild' is given).
-
 
24
 
-
 
25
If necessary for passing the checks, use the \`--vsize' and \`--nsize'
-
 
26
options to increase R's memory (\`--vanilla' is used by default).
-
 
27
 
-
 
28
Options:
-
 
29
  -c, --clean
-
 
30
  -d, --debug		turn on shell debugging (set -x)
-
 
31
  -h, --help		print short help message and exit
-
 
32
  -l, --library=LIB	use packages in library tree LIB
-
 
33
  --vsize=N		set R's vector heap size to N bytes
-
 
34
  --nsize=N		set R's number of cons cells to N
-
 
35
  --no-rebuild		do not rebuild examples
-
 
36
  -v, --version		print version info and exit
-
 
37
 
-
 
38
Email bug reports to <r-bugs@lists.r-project.org>."
8
 
39
 
9
OPTS=
40
opts=
10
PKGS=
41
pkgs=
11
CLEAN=false
42
clean=false
12
DEBUG=false
43
debug=false
13
REBUILD=true
44
rebuild=true
14
START_DIR=`pwd`
-
 
15
lib=${R_HOME}/library
45
lib=${R_HOME}/library
16
 
46
 
17
while test -n "${1}"; do
47
while test -n "${1}"; do
18
  case ${1} in
48
  case ${1} in
19
    -h|--help|-\?)
49
    -h|--help)
20
      echo "${USAGE_MSG}"; exit 0 ;;
50
      echo "${usage}"; exit 0 ;;
21
    -V|--version)
51
    -v|--version)
22
      echo "${VERSION}"; exit 0 ;;
52
      echo "${version}"; exit 0 ;;
23
    -c|--clean)
53
    -c|--clean)
24
      CLEAN=true ;;
54
      clean=true ;;
25
    --debug)
55
    -d|--debug)
-
 
56
      debug=true
26
      DEBUG=true; OPTS="${OPTS} --debug" ;;
57
      opts="${opts} --debug"
-
 
58
      ;;
27
    --no-rebuild)
59
    --no-rebuild)
28
      REBUILD=false ;;
60
      rebuild=false ;;
29
    -l)
61
    -l)
30
      lib=${2}; shift;
62
      lib=${2}; shift ;;
-
 
63
    --library=*)
-
 
64
      lib=`echo "${1}" | sed -e 's/[^=]*=//'` ;;
-
 
65
    --nsize=*)
31
      R_LIBS="${lib}:${R_LIBS:-${RLIBS}}";
66
      R_opts="{R_opts} ${1}" ;;
32
      ;;
67
    --vsize=*)
-
 
68
      R_opts="{R_opts} ${1}" ;;
33
    *)
69
    *)
34
      PKGS="${PKGS} ${1}" ;;
70
      pkgs="${pkgs} ${1}" ;;
35
  esac
71
  esac
36
  shift
72
  shift
37
done
73
done
38
 
74
 
39
if ${DEBUG}; then set -x; fi
-
 
40
 
-
 
41
if test -z "${PKGS}"; then
75
if test -z "${pkgs}"; then
42
  echo "${USAGE_MSG}"
76
  echo "ERROR: no packages specified"
43
  exit 1
77
  exit 1
44
fi
78
fi
45
 
-
 
46
if test -d ${lib}; then
79
if test -d ${lib}; then
47
  lib=`cd ${lib}; pwd`
80
  lib=`cd ${lib}; pwd`
48
else
81
else
49
  echo "ERROR: library directory \`${lib}' does not exist"
82
  echo "ERROR: library directory \`${lib}' does not exist"
50
  exit 2
83
  exit 2
51
fi
84
fi
-
 
85
R_LIBS="${lib}:${R_LIBS:-${RLIBS}}"
52
 
86
 
53
for pkg in ${PKGS}; do
-
 
54
  cd ${START_DIR}
-
 
55
  USE_MAN=false
87
start_dir=`pwd`
56
 
88
 
-
 
89
## The work horse
-
 
90
checkpkg () {
-
 
91
  echo "Checking package \`${1}' ..."
-
 
92
  pkg=${1}
-
 
93
 
-
 
94
  cd ${start_dir}
-
 
95
  use_man=false
-
 
96
 
57
  if ${REBUILD}; then
97
  if ${rebuild}; then
58
    if test -d ${pkg}/man -a -w ${lib}/`basename ${pkg}`; then
98
    if test -d ${pkg}/man -a -w ${lib}/`basename ${pkg}`; then
59
      USE_MAN=true
99
      use_man=true
60
      cd ${pkg}
100
      cd ${pkg}
61
      pkg=`basename ${pkg}`
101
      pkg=`basename ${pkg}`
62
      rm -rf ${lib}/${pkg}/R-ex
102
      rm -rf ${lib}/${pkg}/R-ex
63
    fi
103
    fi
64
  fi
104
  fi
65
 
105
 
66
  echo "Checking package \`${pkg}' ..."
-
 
67
 
-
 
68
  if test \! -d ${lib}/${pkg}; then
106
  if test \! -d ${lib}/${pkg}; then
69
    echo "WARNING: package \`${pkg}' not installed ... skipping"
107
    echo "WARNING: package \`${pkg}' not installed ... skipping"
70
    break
108
    break
71
  fi
109
  fi
72
 
110
 
73
  if ${USE_MAN}; then
111
  if ${use_man}; then
74
    ${R_HOME}/bin/build-help ${OPTS} --example ../${pkg} ${lib}
112
    ${R_HOME}/bin/build-help ${OPTS} --example ../${pkg} ${lib}
75
    CHECK_DIR=check
113
    check_dir=check
76
  else
114
  else
77
    CHECK_DIR=check-${pkg}
115
    check_dir=check-${pkg}
78
  fi
116
  fi
79
 
117
 
80
  test -d ${CHECK_DIR} || mkdir ${CHECK_DIR}
118
  test -d ${check_dir} || mkdir ${check_dir}
81
  cd ${CHECK_DIR}
119
  cd ${check_dir}
82
 
120
 
83
  echo " Massaging examples into \`${pkg}-Ex.R' ..."
121
  echo " Massaging examples into \`${pkg}-Ex.R' ..."
84
  ${R_HOME}/bin/massage-Examples ${pkg} ${lib}/${pkg}/R-ex/*.R \
122
  ${R_HOME}/bin/massage-Examples ${pkg} ${lib}/${pkg}/R-ex/*.R \
85
    > ${pkg}-Ex.R
123
    > ${pkg}-Ex.R
86
  echo " Running examples in package \`${pkg}' ..."
124
  echo " Running examples in package \`${pkg}' ..."
Line 89... Line 127...
89
  if test ${?} -eq 0; then
127
  if test ${?} -eq 0; then
90
    echo " OK"
128
    echo " OK"
91
  else
129
  else
92
    echo " ERROR" && exit 1
130
    echo " ERROR" && exit 1
93
  fi
131
  fi
94
  if ${CLEAN}; then
132
  if ${clean}; then
95
    cd .. && rm -rf ${CHECK_DIR}
133
    cd .. && rm -rf ${check_dir}
96
  else
134
  else
97
    echo " Results of \`check' are available in directory ${CHECK_DIR}"
135
    echo " Results of \`check' are available in directory ${check_dir}"
98
  fi
136
  fi
99
 
137
}
-
 
138
  
-
 
139
## The main loop
-
 
140
if ${debug}; then set -x; fi
-
 
141
for p in ${pkgs}; do
-
 
142
  checkpkg ${p}
-
 
143
  echo
100
done
144
done
101
 
145
 
102
### Local Variables: ***
146
### Local Variables: ***
103
### mode: sh ***
147
### mode: sh ***
104
### sh-indentation: 2 ***
148
### sh-indentation: 2 ***