View
@@ -62,11 +62,18 @@ speed.do_sum(n)
EOF
}
opyc-run() {
../bin/opyc run "$@"
}
opyc-compile() {
../bin/opyc compile "$@"
}
opy-speed-test() {
write-speed
_compile-one _tmp/speed.py _tmp/speed.pyc
_compile-one _tmp/speed_main.py _tmp/speed_main.pyc
opyc-compile _tmp/speed.py _tmp/speed.pyc
opyc-compile _tmp/speed_main.py _tmp/speed_main.pyc
cp _tmp/speed.pyc _tmp/speed.opyc
@@ -80,26 +87,21 @@ opy-speed-test() {
# 205 ms. So it's 30x slower. Makes sense.
echo OPY
time opy_ run _tmp/speed.opyc $n
time opyc-run _tmp/speed.opyc $n
#
# byterun Import bug regression test!
#
# 7 ms
echo PYTHON
time python _tmp/speed_main.pyc $n
# 205 ms. So it's 30x slower. Makes sense.
echo OPY
time opy_ run _tmp/speed_main.pyc $n
}
byterun-speed-test() {
write-speed
echo OLD BYTERUN
time _byterun $PWD/_tmp/speed_main.py 10000
time _byterun $PWD/_tmp/speed.py 10000
time opyc-run _tmp/speed_main.pyc $n
}
_byterun() {
# Wow this is SO confusing.
# Not executable on master branch
@@ -110,11 +112,19 @@ _byterun() {
#PYTHONPATH=~/git/other/byterun
# WHY is this the only way to make it work?
pushd ~/git/other/byterun
pushd ~/git/languages/byterun
python -m byterun.__main__ "$@"
popd
}
byterun-speed-test() {
write-speed
echo OLD BYTERUN
time _byterun $PWD/_tmp/speed_main.py 10000
time _byterun $PWD/_tmp/speed.py 10000
}
#
# Byterun smoke tests
#
@@ -124,24 +134,27 @@ _byterun() {
opy-parse-on-byterun() {
local arg=$PWD/testdata/hello_py2.py
pushd _tmp/opy-opy
opyg run opy_main.pyc -g $GRAMMAR parse $arg
opyc-run opy_main.pyc parse $arg
popd
}
osh-parse-on-byterun() {
cmd=(osh --ast-output - --no-exec -c 'echo "hello world"')
cmd=(osh -n -c 'echo "hello world"')
../bin/oil.py "${cmd[@]}" # Run with CPython
../bin/oil.py "${cmd[@]}"
echo ---
opyg run _tmp/osh-opy/bin/oil.pyc "${cmd[@]}"
# Run with byterun
opyc-run -- _tmp/oil-opy/bin/oil.pyc "${cmd[@]}"
}
opy-hello2() {
opyg run testdata/hello_py2.py
opyc-run testdata/hello_py2.py
}
opy-hello3() {
opyg run testdata/hello_py3.py
opyc-run testdata/hello_py3.py
}
#
View
@@ -7,6 +7,10 @@ set -o nounset
set -o pipefail
set -o errexit
readonly THIS_DIR=$(cd $(dirname $0) && pwd)
readonly OPYC=$THIS_DIR/../bin/opyc
osh-opy() {
_tmp/oil-opy/bin/osh "$@"
}
@@ -35,27 +39,105 @@ osh-version() {
# TODO:
# - Run with oil.ovm{,-dbg}
# 3/2018 byterun results:
#
# Ran 28 tests, 4 failures
# asdl/arith_parse_test.pyc core/glob_test.pyc core/lexer_gen_test.pyc osh/lex_test.pyc
#
oil-unit() {
local dir=${1:-_tmp/oil-opy}
local vm=${2:-cpython} # byterun or cpython
pushd $dir
mkdir -p _tmp
#$OPYC run core/cmd_exec_test.pyc
local n=0
local -a failures=()
#for t in {build,test,native,asdl,core,osh,test,tools}/*_test.py; do
for t in {asdl,core,osh}/*_test.pyc; do
echo $t
if test $vm = byterun; then
PYTHONPATH=. opy_ run $t
set +o errexit
set +o nounset # for empty array!
# Note: adding PYTHONPATH screws things up, I guess because it's the HOST
# interpreter pythonpath.
$OPYC run $t
status=$?
if test $status -ne 0; then
failures=("${failures[@]}" $t)
fi
(( n++ ))
elif test $vm = cpython; then
PYTHONPATH=. python $t
#(( n++ ))
else
die "Invalid VM $vm"
fi
done
popd
if test $vm = byterun; then
echo "Ran $n tests, ${#failures[@]} failures"
echo "${failures[@]}"
fi
}
oil-unit-byterun() {
oil-unit '' byterun
}
readonly -a FAILED=(
#asdl/arith_parse_test.pyc # IndexError
# I believe this is due to:
# 'TODO: handle generator exception state' in pyvm2.py. Open bug in
# byterun. asdl/tdop.py uses a generator Tokenize() with StopIteration
# Any bytecode can raise an exception internally.
core/glob_test.pyc # unbound method append()
core/lexer_gen_test.pyc # ditto
osh/lex_test.pyc # ditto
)
oil-byterun-failed() {
#set +o errexit
for t in "${FAILED[@]}"; do
echo
echo ---
echo --- $t
echo ---
pushd _tmp/oil-opy
$OPYC run $t
popd
done
}
# TODO: byterun/run.sh has this too
byterun-unit() {
pushd byterun
for t in test_*.py; do
echo
echo "*** $t"
echo
PYTHONPATH=. ./$t
done
}
unit() {
PYTHONPATH=. "$@"
}