View
@@ -0,0 +1,76 @@
#!/bin/bash
#
# Usage:
# ./test.sh <function name>
set -o nounset
set -o pipefail
set -o errexit
osh-opy() {
_tmp/oil-opy/bin/osh "$@"
}
oil-opy() {
_tmp/oil-opy/bin/oil "$@"
}
osh-help() {
osh-opy --help
}
# TODO: Add compiled with "OPy".
# How will it know? You can have a special function bin/oil.py:
# def __GetCompilerName__():
# return "CPython"
#
# If the function name is opy stub, then Opy ret
#
# Or __COMPILER_NAME__ = "CPython"
# The OPy compiler can rewrite this to "OPy".
osh-version() {
osh-opy --version
}
# TODO:
# - Run with oil.ovm{,-dbg}
unit() {
local dir=${1:-_tmp/oil-opy}
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
echo $t
if test $vm = byterun; then
PYTHONPATH=. opy_ run $t
elif test $vm = cpython; then
PYTHONPATH=. python $t
else
die "Invalid VM $vm"
fi
done
popd
}
# NOTE: I checked with set -x that it's being run. It might be nicer to be
# sure with --verison.
export OSH_PYTHON=opy/_tmp/oil-opy/bin/osh
# NOTE: Failures in 'var-num' and 'special-vars' due to $0. That proves
# we're running the right binary!
spec() {
local action=${1:-smoke}
shift
pushd ..
# Could also export OSH_OVM
test/spec.sh $action "$@"
popd
}
"$@"
View
@@ -9,34 +9,27 @@ set -o nounset
set -o pipefail
set -o errexit
source build/common.sh # for OIL_SYMLINKS
# Python 3 stuff
replace-print() {
#grep 'print >>' oil/*.py
grep 'print ' {osh,core}/*.py
#sed -i --regexp-extended -e 's/print (.*)/print(\1)/' {osh,core}/*.py
}
readonly LINKS='oil oilc osh sh wok boil true false'
make-bin-links() {
# bin/ is for running with the Python interpreter. _bin/ is for running with
# OVM app bundles.
mkdir -p bin _bin
for link in $LINKS; do
for link in "${OIL_SYMLINKS[@]}"; do
ln -s -f --verbose oil.py bin/$link
done
for link in $LINKS; do
for link in "${OIL_SYMLINKS[@]}"; do
ln -s -f --verbose oil.ovm _bin/$link
done
}
# For OPy, called by opy/smoke.sh
make-pyc-links() {
for link in $LINKS; do
ln -s -f --verbose oil.pyc bin/$link
done
}
"$@"
View
@@ -13,15 +13,17 @@ readonly MKSH=$(which mksh)
readonly ZSH=$(which zsh)
readonly BUSYBOX_ASH=_tmp/shells/ash
if test -f _bin/osh; then
readonly OSH_PYTHON=${OSH_PYTHON:-bin/osh}
readonly OSH_OVM=${OSH_OVM:-_bin/osh}
if test -f $OSH_OVM; then
# TODO: Does it make sense to copy the binary to an unrelated to directory,
# like /tmp? /tmp/{oil.ovm,osh}.
readonly OSH_BIN=_bin/osh
# HACK that relies on word splitting. TODO: Use ${OSH[@]} everywhere
readonly OSH="bin/osh $OSH_BIN"
readonly OSH="$OSH_PYTHON $OSH_OVM"
else
readonly OSH="bin/osh"
readonly OSH="$OSH_PYTHON"
fi