Permalink
Browse files

Test cleanup, including consolidating parse error tests.

- Polish of test/smoke.sh
  - Revealed a bug in oheap; now fixed
- Extract test/parse-errors.sh from test/smoke.sh
  - Move data files to test/parse-errors/
- Plan new release directory structure to publish more tests
  • Loading branch information...
Andy Chu
Andy Chu committed Aug 20, 2018
1 parent 3154117 commit 10077bab93d4a9067496b54324146d8e1414553b
View
@@ -174,8 +174,9 @@ def EncodeArray(obj_list, item_desc, enc, out):
else:
# A simple value is either an int, enum, or pointer. (Later: Iter<Str>
# might be possible for locality.)
assert isinstance(item_desc, asdl.Sum) or \
isinstance(item_desc, asdl.Product), item_desc
assert \
isinstance(item_desc, asdl.SumType) or \
isinstance(item_desc, asdl.CompoundType), item_desc
# This is like vector<T*>
# Later:
View
@@ -81,9 +81,11 @@ auto-machine1() {
# spec.wwz/
# machine-lisa/
# wild.wwz/
# unit/
# osh2oil/
# gold/
# unit.wwz/
# other.wwz/
# osh2oil.txt
# gold.txt
# parse-errors.txt
# tarball/ # log of building and running the tarball?
# asan/ # spec tests or other?
# # or it can be put under test/{spec,wild}
@@ -110,7 +112,7 @@ auto-machine1() {
_clean-tmp-dirs() {
rm -r -f \
_tmp/{spec,unit,gold,osh2oil,wild/www} \
_tmp/{spec,unit,gold,parse-errors,osh2oil,wild/www} \
_tmp/metrics \
_tmp/opy-test \
_tmp/{osh-parser,osh-runtime,vm-baseline,ovm-build,oheap} \
@@ -166,6 +168,7 @@ _test-release-build() {
test/osh2oil.sh run-for-release
test/gold.sh run-for-release
test/parse-errors.sh run-for-release
# Just test the release build (not under CPython or byterun. That comes later.)
OSH_LIST="$OSH_RELEASE_BINARY" test/spec.sh all
@@ -547,6 +550,8 @@ compress-txt() {
compress() {
local root=$PWD/_release/VERSION/
# TODO: Change this to test/other.wwz/{gold,osh2oil,...}.txt
# There is a single log.txt file in _tmp/{osh2oil,gold}
compress-txt osh2oil
compress-txt gold
View
@@ -0,0 +1,68 @@
#!/bin/bash
#
# Usage:
# ./parse-errors.sh <function name>
set -o nounset
set -o pipefail
set -o errexit
# Run with SH=bash too
SH=${SH:-bin/osh}
banner() {
echo
echo ===== CASE: "$@" =====
echo
}
_error-case() {
banner "$@"
echo
$SH -c "$@"
}
cases-in-strings() {
set +o errexit
_error-case 'echo < <<'
_error-case '${foo:}'
_error-case '$(( 1 + ))'
_error-case 'echo $( echo > >> )'
_error-case 'echo ${'
}
# Cases in their own file
cases-in-files() {
set +o errexit # Don't fail
for t in test/parse-errors/*.sh; do
banner $t
$SH $t
done
}
all() {
cases-in-strings
echo
echo ----------------------
echo
cases-in-files
# Always passes
return 0
}
# TODO:
run-for-release() {
local out=_tmp/parse-errors/log.txt
mkdir -p $(dirname $out)
echo '1'
all >$out 2>&1
echo "Wrote $out"
}
"$@"
File renamed without changes.
File renamed without changes.
View
@@ -11,7 +11,7 @@ set -o errexit
source test/common.sh
ast() {
ast-formats() {
bin/osh -n -c 'echo hi'
bin/osh -n --ast-format text -c 'echo hi'
bin/osh -n --ast-format abbrev-html -c 'echo hi'
@@ -27,14 +27,11 @@ ast() {
hexdump -C $ast_bin
}
# Read from a file.
osh-file() {
echo ===== Hello
cat >_tmp/hi.sh <<EOF
cat >_tmp/smoke-prog.sh <<EOF
echo hi
echo bye
func() {
echo "inside func"
@@ -47,7 +44,7 @@ func 1 2 3
echo \$(echo ComSub)
EOF
$OSH _tmp/hi.sh
$OSH _tmp/smoke-prog.sh
echo ===== EMPTY
touch _tmp/empty.sh
@@ -60,7 +57,7 @@ EOF
# Read from stdin.
osh-stdin() {
$OSH < _tmp/hi.sh
$OSH < _tmp/smoke-prog.sh
echo ===== EMPTY
$OSH < _tmp/empty.sh
@@ -89,13 +86,15 @@ func() {
}
EOF
# TODO: test while loop
}
osh-interactive() {
echo 'echo hi' | $OSH -i
echo 'exit' | $OSH -i
# Parse failure
echo ';' | $OSH -i
}
help() {
@@ -120,30 +119,14 @@ help() {
assert $? -eq 0
}
_error-case() {
echo
echo "$@"
echo
bin/osh -c "$@"
}
parse-errors() {
set +o errexit
_error-case 'echo < <<'
_error-case '${foo:}'
_error-case '$(( 1 + ))'
_error-case 'echo $( echo > >> )'
#_error-case 'echo ${'
}
exit-builtin-interactive() {
set +o errexit
echo 'echo one; exit 42; echo two' | bin/osh -i
assert $? -eq 42
}
readonly -a PASSING=(
ast
ast-formats
osh-file
osh-stdin
osh-interactive

0 comments on commit 10077ba

Please sign in to comment.