2020-05-14 20:50:22 +03:00
|
|
|
#!/usr/bin/env bash
|
2018-12-13 03:59:00 +03:00
|
|
|
|
2020-11-17 00:49:31 +03:00
|
|
|
set -e
|
|
|
|
|
2018-12-13 03:59:00 +03:00
|
|
|
BIN=bin
|
|
|
|
|
2020-09-17 20:38:43 +03:00
|
|
|
QUICKTESTS="tests/issues tests/modsys tests/mono-binds tests/parser tests/regression tests/renamer"
|
|
|
|
|
2020-05-14 20:50:22 +03:00
|
|
|
function setup_external_tools() {
|
|
|
|
[[ -x "$BIN/test-runner" || -x "$BIN/test-runner.exe" ]] && return
|
|
|
|
cabal v2-install --install-method=copy --installdir="$BIN" test-lib
|
2018-12-13 03:59:00 +03:00
|
|
|
}
|
|
|
|
|
2020-05-14 20:50:22 +03:00
|
|
|
function show_usage() {
|
|
|
|
cat << EOM
|
2020-10-02 01:32:45 +03:00
|
|
|
Usage: $0 COMMAND COMMAND_OPTIONS
|
2018-12-13 03:59:00 +03:00
|
|
|
Available commands:
|
2020-05-14 20:50:22 +03:00
|
|
|
run Run Cryptol
|
|
|
|
build Build Cryptol
|
|
|
|
haddock Generate Haddock documentation
|
2020-09-23 23:48:31 +03:00
|
|
|
test Run some tests (may take a while)
|
|
|
|
quick-test Like "test" but run fewer tests by default
|
2021-03-02 00:19:00 +03:00
|
|
|
rpc-test Run RPC server tests
|
2021-05-30 17:55:01 +03:00
|
|
|
rpc-docs Check that the RPC documentation is up-to-date
|
2020-05-14 20:50:22 +03:00
|
|
|
exe-path Print the location of the local executable
|
2018-12-13 03:59:00 +03:00
|
|
|
EOM
|
|
|
|
}
|
|
|
|
|
2020-05-14 20:50:22 +03:00
|
|
|
if [ "$#" == "0" ]; then
|
2018-12-13 03:59:00 +03:00
|
|
|
show_usage
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
COMMAND=$1
|
|
|
|
shift
|
|
|
|
|
|
|
|
case $COMMAND in
|
2020-05-14 20:50:22 +03:00
|
|
|
run) cabal v2-exec cryptol -- $* ;;
|
2019-01-03 22:10:29 +03:00
|
|
|
|
2018-12-13 03:59:00 +03:00
|
|
|
build)
|
|
|
|
echo Building Cryptol
|
2019-01-09 04:18:45 +03:00
|
|
|
|
|
|
|
# XXX: This is a workaround the fact that currently Cabal
|
|
|
|
# will not rebuild this file, even though it has TH code, that
|
|
|
|
# depends on the environment. For now, we temporarily modify the
|
|
|
|
# file, then build, then revert it back after build.
|
|
|
|
|
2020-05-14 20:50:22 +03:00
|
|
|
dirty_string="-- Last build $(date)"
|
|
|
|
echo "$dirty_string" >> src/GitRev.hs
|
2019-01-09 04:18:45 +03:00
|
|
|
|
2020-07-21 19:34:26 +03:00
|
|
|
if [[ -n "$RELEASE" ]]; then
|
|
|
|
sed -i.bak -e 's/^commitShortHash = .*$/commitShortHash = "UNKNOWN"/' \
|
|
|
|
-e 's/^commitHash = .*$/commitHash = "UNKNOWN"/' \
|
|
|
|
-e 's/^commitBranch = .*$/commitBranch = "UNKNOWN"/' \
|
|
|
|
-e 's/^commitDirty = .*$/commitDirty = False/' \
|
|
|
|
-e '/import qualified GitRev/d' \
|
|
|
|
src/Cryptol/Version.hs
|
|
|
|
rm -f src/Cryptol/Version.hs.bak
|
|
|
|
fi
|
|
|
|
|
|
|
|
cabal v2-build "$@" exe:cryptol
|
|
|
|
|
|
|
|
sed -i.bak "/^-- Last build/d" src/GitRev.hs
|
2020-07-14 20:58:38 +03:00
|
|
|
rm -f src/GitRev.hs.bak
|
2019-01-09 04:14:53 +03:00
|
|
|
;;
|
2018-12-13 03:59:00 +03:00
|
|
|
|
2020-05-14 20:50:22 +03:00
|
|
|
haddock) echo Building Haddock documentation && cabal v2-haddock ;;
|
2018-12-13 03:59:00 +03:00
|
|
|
|
2020-09-17 20:38:43 +03:00
|
|
|
quick-test)
|
|
|
|
echo Running quick tests
|
|
|
|
setup_external_tools
|
|
|
|
$BIN/test-runner --ext=.icry \
|
|
|
|
--exe=cabal \
|
|
|
|
-F v2-run -F -v0 -F exe:cryptol -F -- -F -b \
|
|
|
|
$QUICKTESTS
|
|
|
|
;;
|
|
|
|
|
2018-12-13 03:59:00 +03:00
|
|
|
test)
|
|
|
|
echo Running tests
|
|
|
|
setup_external_tools
|
2020-05-14 20:50:22 +03:00
|
|
|
if [ "$#" == "0" ]; then TESTS=tests; else TESTS=$*; fi
|
2018-12-13 03:59:00 +03:00
|
|
|
$BIN/test-runner --ext=.icry \
|
2020-05-14 20:50:22 +03:00
|
|
|
--exe=cabal \
|
|
|
|
-F v2-run -F -v0 -F exe:cryptol -F -- -F -b \
|
|
|
|
$TESTS
|
2018-12-13 03:59:00 +03:00
|
|
|
;;
|
|
|
|
|
2021-03-02 00:19:00 +03:00
|
|
|
rpc-test)
|
|
|
|
echo Running RPC server tests
|
|
|
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
2021-03-02 01:29:57 +03:00
|
|
|
$DIR/cryptol-remote-api/run_rpc_tests.sh
|
2021-03-02 00:19:00 +03:00
|
|
|
;;
|
|
|
|
|
2021-05-30 17:55:01 +03:00
|
|
|
rpc-docs)
|
|
|
|
echo "Checking cryptol-remote-api docs (Cryptol.rst) are up-to-date with server"
|
|
|
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
|
|
|
$DIR/cryptol-remote-api/check_docs.sh
|
|
|
|
;;
|
|
|
|
|
2021-03-02 00:19:00 +03:00
|
|
|
|
2020-05-14 20:50:22 +03:00
|
|
|
help) show_usage && exit 0 ;;
|
2018-12-13 03:59:00 +03:00
|
|
|
|
2020-05-14 20:50:22 +03:00
|
|
|
exe-path) cabal v2-exec which cryptol ;;
|
2018-12-13 03:59:00 +03:00
|
|
|
|
2020-05-14 20:50:22 +03:00
|
|
|
*) echo "Unrecognized command: $COMMAND" && show_usage && exit 1 ;;
|
2018-12-13 03:59:00 +03:00
|
|
|
esac
|