/
test.sh
executable file
·92 lines (73 loc) · 1.61 KB
/
test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/env bash
#
# Usage:
# ./test.sh <function name>
set -o nounset
set -o pipefail
set -o errexit
shopt -s all:strict 2>/dev/null || true # dogfood for OSH
make-zip() {
local out=_tmp/make-zip-test.zip
build/make_zip.py $out _build/runpy-deps-py.txt
unzip -l $out
}
hello-bundle() {
set +o errexit
_bin/hello.ovm
if test $? = 1; then
echo OK
else
echo 'FAIL: expected exit code 1'
exit 1
fi
}
oil-bundle() {
_bin/oil.ovm osh -c 'echo hi'
ln -s -f oil.ovm _bin/osh
_bin/osh -c 'echo hi from osh'
}
_tarball() {
local name=${1:-hello}
local version=${2:-0.0.0}
local install=${3:-}
local tmp=_tmp/${name}-tar-test
rm -r -f $tmp
mkdir -p $tmp
cd $tmp
tar --extract -z < ../../_release/$name-$version.tar.gz
cd $name-$version
./configure
# Build the fast one for a test.
# TODO: Maybe edit the Makefile to change the top target.
local bin=_bin/${name}.ovm # not dbg
time make $bin
$bin --version
if test -n "$install"; then
sudo ./install
fi
}
hello-tar() {
_tarball hello $(head -n 1 build/testdata/hello-version.txt)
}
oil-tar() {
local install=${1:-} # non-empty to install
_tarball oil $(head -n 1 oil-version.txt) "$install"
}
# Test the different entry points.
ovm-main-func() {
echo ---
echo 'Running nothing'
echo ---
local ovm=_build/hello/ovm-dbg
_OVM_RUN_SELF=0 $ovm || true
echo ---
echo 'Running bytecode.zip'
echo ---
_OVM_RUN_SELF=0 $ovm _build/hello/bytecode.zip || true
# Doesn't work because of stdlib deps?
echo ---
echo 'Running lib.pyc'
echo ---
_OVM_RUN_SELF=0 $ovm build/testdata/lib.pyc
}
"$@"