Permalink
Browse files

Successfully run Oil unit tests with bytecode compiled by OPy.

The bytecode is run by CPython.

Exposed a bug in OPy's parser, which I worked around for now.
  • Loading branch information...
Andy Chu
Andy Chu committed Feb 24, 2018
1 parent 14e088c commit 67a4e32d6e5fea10c54200c189126cbb1accd4ae
Showing with 34 additions and 14 deletions.
  1. +2 −0 build/quick_ref.py
  2. +8 −1 opy/README.md
  3. +7 −0 opy/run.sh
  4. +17 −13 opy/smoke.sh
View
@@ -323,6 +323,8 @@ def main(argv):
with open(py_out_path, 'w') as f:
f.write('TOPIC_LOOKUP = ')
f.write(d)
# BUG WORKAROUND: The OPy parser requires an EOL! See opy/run.sh parser-bug.
f.write('\n')
print('Wrote %s/ and %s' % (text_dir, py_out_path), file=sys.stderr)
View
@@ -10,9 +10,16 @@ Getting started / smoke test:
Compiling Oil:
./smoke.sh compile-osh-tree
./smoke.sh compile-osh-tree # makes _tmp/osh-opy and _tmp/osh-ccompile
./smoke.sh test-osh-tree # Run Oil unit tests
TODO:
Move important stuff to build.sh. smoke.sh doesn't make sense.
Notes
-----
OSH tests don't run under byterun. I probably don't care.
./smoke.sh test-osh-tree '' byterun
View
@@ -23,6 +23,13 @@ parse-test() {
_parse-one testdata/hello_py2.py
}
# It has problems without EOL!
parser-bug() {
local out=_tmp/opy_parser_bug.py
echo -n 'foo = {}' > $out
_parse-one $out
}
# This might not work
_stdlib-parse-one() {
PYTHONPATH=. ./opy_main.py 2to3.grammar stdlib-parse "$@"
View
@@ -75,21 +75,26 @@ compile-opy-tree() {
_fill-osh-tree() {
local dir=${1:-_tmp/osh-stdlib}
cp -v ../osh/osh.asdl $dir/osh
cp -v ../osh/{osh,types}.asdl $dir/osh
cp -v ../core/runtime.asdl $dir/core
cp -v ../asdl/arith.asdl $dir/asdl
ln -v -s -f $PWD/../core/libc.so $dir/core
ln -v -s -f $PWD/../{libc,fastlex}.so $dir
}
# TODO: This could be part of the Travis build. It will ensure no Python 2
# Compile with both compile() and OPy.
# TODO:
# - What about the standard library? The whole app bundle should be
# compiled with OPy.
# - This could be part of the Travis build. It will ensure no Python 2
# print statements sneak in.
compile-osh-tree() {
local src=$(cd .. && echo $PWD)
# NOTE: Exclude _devbuild/cpython-full, but include _devbuild/gen.
local files=( $(find $src \
-name _tmp -a -prune -o \
-name _chroot -a -prune -o \
-name _devbuild -a -prune -o \
-name cpython-full -a -prune -o \
-name _deps -a -prune -o \
-name Python-2.7.13 -a -prune -o \
-name opy -a -prune -o \
@@ -117,25 +122,24 @@ zip-oil-tree() {
popd
}
# TODO:
# - Run with oil.ovm{,-dbg}
test-osh-tree() {
local dir=${1:-_tmp/osh-opy}
local vm=${2:-byterun} # byterun or cpython
local vm=${2:-cpython} # byterun or cpython
pushd $dir
mkdir -p _tmp
#for t in {build,test,native,asdl,core,osh,test,tools}/*_test.py; do
for t in {asdl,core,osh}/*_test.pyc; do
if [[ $t == *arith_parse_test.pyc ]]; then
continue
fi
#if [[ $t == *libc_test.pyc ]]; then
# continue
#fi
echo $t
if test $vm = byterun; then
PYTHONPATH=. opy_ run $t
else
elif test $vm = cpython; then
PYTHONPATH=. python $t
else
die "Invalid VM $vm"
fi
done
popd

0 comments on commit 67a4e32

Please sign in to comment.