mirror of
https://github.com/GaloisInc/cryptol.git
synced 2024-11-30 23:45:23 +03:00
A Bash script to automate common cabal (v2) tasks
This commit is contained in:
parent
d377f38c9d
commit
2bd9d3aecf
71
cry
Executable file
71
cry
Executable file
@ -0,0 +1,71 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
BIN=bin
|
||||
|
||||
function setup_external_tools {
|
||||
if [ ! -f "$BIN/test-runner" ]
|
||||
then
|
||||
mkdir -p "$BIN"
|
||||
cabal v2-install --symlink-bindir="$BIN" test-runner
|
||||
fi
|
||||
}
|
||||
|
||||
function show_usage {
|
||||
cat <<EOM
|
||||
Usage: $0 COMMAND COMANND_OPTIONS
|
||||
Available commands:
|
||||
build Build Cryptol
|
||||
haddock Generate Haddock documentation
|
||||
test Run some tests
|
||||
EOM
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if [ "$#" == "0" ]
|
||||
then
|
||||
show_usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
COMMAND=$1
|
||||
shift
|
||||
|
||||
case $COMMAND in
|
||||
build)
|
||||
echo Building Cryptol
|
||||
cabal v2-build exe:cryptol;;
|
||||
|
||||
haddock)
|
||||
echo Building Haddock documentation
|
||||
cabal v2-haddock;;
|
||||
|
||||
|
||||
test)
|
||||
echo Running tests
|
||||
setup_external_tools
|
||||
if [ "$#" == "0" ]
|
||||
then TESTS=tests
|
||||
else TESTS=$*
|
||||
fi
|
||||
$BIN/test-runner --ext=.icry \
|
||||
--exe=cabal \
|
||||
-F v2-run -F -v0 -F exe:cryptol -F -- -F -b \
|
||||
$TESTS
|
||||
;;
|
||||
|
||||
help)
|
||||
show_usage
|
||||
exit 0;;
|
||||
|
||||
*)
|
||||
echo Unrecognized command: $COMMAND
|
||||
show_usage
|
||||
exit 1;;
|
||||
|
||||
esac
|
||||
|
||||
|
||||
|
41
run-tests
41
run-tests
@ -1,41 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
TEST_DIR=tests
|
||||
ALL_TESTS=("modsys" "parser" "issues" "regression" "renamer" "mono-binds")
|
||||
|
||||
TESTS=()
|
||||
|
||||
if [ $# == 0 ]; then
|
||||
declare -a TESTS
|
||||
for i in ${!ALL_TESTS[*]}; do
|
||||
TESTS[i]="$TEST_DIR/${ALL_TESTS[i]}"
|
||||
done
|
||||
else
|
||||
TESTS=("$@")
|
||||
fi
|
||||
|
||||
CRY_VERSION=$(grep Version: cryptol.cabal | awk '{print $2}')
|
||||
|
||||
if [ ${CRY_VERSION}x == "x" ]; then
|
||||
echo Failed to guess version of Cryptol.
|
||||
exit 1
|
||||
fi
|
||||
|
||||
GHC_VERSION=$(ghc --numeric-version)
|
||||
|
||||
if [ ${GHC_VERSION}x == "x" ]; then
|
||||
echo Failed to guess version of GHC.
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo Testing Cryptol version ${CRY_VERSION}, built using GHC ${GHC_VERSION}.
|
||||
|
||||
|
||||
CRY=$(find dist-newstyle -name cryptol -type f \
|
||||
| grep $GHC_VERSION \
|
||||
| grep $CRY_VERSION)
|
||||
|
||||
|
||||
cabal new-run cryptol-test-runner -- --exe $CRY --ignore-expected ${TESTS[*]}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user