~ chicken-core (master) /scripts/smoke-test.sh


  1#! /bin/sh
  2
  3set -e
  4
  5ALL_GOOD="========== ALL GOOD! =========="
  6
  7usage() {
  8    cat <<EOF
  9Usage: $(basename "$0") [-h|-help|--help]
 10
 11This script runs basic tests on the chicken-core repository:
 12
 13* Creates a distribution tarball with the Scheme code compiled to C.
 14* Extracts, builds, installs and tests the code from the distribution
 15  tarball.
 16* Uses CHICKEN installed out of the distribution tarball to install
 17  salmonella, and uses it to test an egg with dependencies.
 18
 19If everything goes well, you should see
 20
 21$ALL_GOOD
 22
 23printed to stdout and the script will exit 0.
 24
 25The following environment variables are considered by this script:
 26
 27* CHICKEN: path to the chicken executable to be used to compile Scheme
 28  code to C.  By default, chicken will be used from \$PATH.
 29
 30* MAKE_JOBS: the maximum number of make jobs to use.  On systems where
 31  the nproc program is available, its output will be used by default,
 32  otherwise 1 will be used.
 33
 34* C_COMPILER: the C compiler to use.  The default is gcc on Linux and
 35  cc on BSDs.
 36
 37* EGGS: eggs to be used as input for salmonella (space-separated, in
 38  case of multiple eggs).  By default, the base64 egg will be used.
 39  Note that, unless you tweak setup.defaults to configure
 40  chicken-install to use egg sources from a local filesystem, testing
 41  the installation of eggs requires Internet access.  If you want to
 42  skip the egg installation test, set this variable to ":".
 43EOF
 44}
 45
 46[ "$1" = "-h" ] || [ "$1" = "-help" ] || [ "$1" = "--help" ] && {
 47    usage
 48    exit 0
 49}
 50
 51set -x
 52
 53chicken=${CHICKEN:-chicken}
 54c_compiler=${C_COMPILER:-gcc}
 55make="make"
 56
 57if command -v nproc >/dev/null; then
 58    make_jobs=${MAKE_JOBS:-$(nproc)}
 59else
 60    make_jobs=${MAKE_JOBS:-1}
 61fi
 62
 63case "$(uname)" in
 64    *BSD)
 65        c_compiler=${C_COMPILER:-cc}
 66        make=gmake
 67        ;;
 68esac
 69
 70# manual-labor is needed by make dist to generate the HTML files of
 71# the manual
 72command -v manual-labor >/dev/null || {
 73    set +x
 74    echo "[ERROR] manual-labor could not be found. \
 75Install it with chicken-install and/or make sure its location is in \$PATH." >&2
 76    exit 1
 77}
 78
 79# Using a directory in the current directory as /tmp might be mounted
 80# on a filesystem that disallows execution
 81tmpdir=$(mktemp -p "$PWD" -d smoke-test-XXXXXX)
 82
 83./configure --chicken "$chicken"
 84"$make" dist -j "$make_jobs"
 85
 86tarball_basename=chicken-$(cat buildversion)
 87tarball=${tarball_basename}.tar.gz
 88
 89mv "$tarball" "$tmpdir"
 90cd "$tmpdir"
 91tar xzf "$tarball"
 92cd "$tarball_basename"
 93./configure --prefix "$PWD/../chicken" --chicken "$chicken" --c-compiler "$c_compiler"
 94"$make" -j "$make_jobs"
 95"$make" install
 96"$make" check
 97
 98eggs=${EGGS:-base64}
 99# : is not a valid egg name
100if [ "$eggs" != ":" ]; then
101    ../chicken/bin/chicken-install -v salmonella
102    # shellcheck disable=SC2086
103    ../chicken/bin/salmonella $eggs
104fi
105
106set +x
107echo "$ALL_GOOD"
Trap