#!/bin/bash # # Usage: # ./opy.sh set -o nounset set -o pipefail set -o errexit source test/common.sh # Can't be readonly because we override it below? Gah. #readonly OPYC=${OPYC:-bin/opyc} setglobal OPYC = $(OPYC:-bin/opyc) const TMP_DIR = '_tmp/opy-test' mkdir -p $TMP_DIR proc usage { set +o errexit bin/opy_.py test $Status -eq 2 || fail bin/opy_.py --version test $Status -eq 0 || fail #bin/opy #test $? -eq 2 || fail bin/opyc test $Status -eq 2 || fail bin/opyc invalid test $Status -eq 2 || fail # TODO: --help, --version everywhere. #bin/opy_.py --help #test $? -eq 0 || fail #bin/opy --help #test $? -eq 0 || fail #bin/opy --version #test $? -eq 0 || fail bin/opyc --help test $Status -eq 0 || fail #bin/opyc --version #test $? -eq 0 || fail } proc parse { cat >$TMP_DIR/hello.py << """ print(1+2) """ $OPYC parse $TMP_DIR/hello.py } proc compile { cat >$TMP_DIR/loop.py << """ for i in xrange(4): print(i*i) """ $OPYC compile $TMP_DIR/loop.py $TMP_DIR/loop.opyc # We can run it with CPython now, but later we won't able to. python $TMP_DIR/loop.opyc > out.txt diff out.txt - << """ || fail 0 1 4 9 """ fail 0 1 4 9 EOF } const -a PASSING = '( 'usage parse compile ) proc all-passing { run-all $(PASSING[@]) } # Use the release binary proc run-for-release { env OPYC=_bin/opyc $0 run-all $(PASSING[@]) } @Argv