OILS / asdl / TEST.sh View on Github | oilshell.org

90 lines, 48 significant
1#!/usr/bin/env bash
2#
3# Tests for ASDL.
4#
5# Usage:
6# asdl/TEST.sh <function name>
7
8set -o nounset
9set -o pipefail
10set -o errexit
11
12REPO_ROOT=$(cd "$(dirname $0)/.."; pwd)
13
14source build/dev-shell.sh # python3 in $PATH
15source devtools/common.sh # banner
16source test/common.sh # run-one-test
17
18unit() {
19 ### Run unit tests
20
21 run-one-test 'asdl/gen_cpp_test' '' asan
22 echo
23
24 run-one-test 'asdl/gc_test' '' asan
25 echo
26
27 run-one-test 'asdl/gc_test' '' asan+gcalways
28 echo
29}
30
31#
32# Python codegen
33#
34
35readonly PY_PATH='.:vendor/' # note: could consolidate with other scripts
36
37asdl-check() {
38 # Unlike Python code, we use --strict mode
39 python3 -m mypy --py2 --strict --follow-imports=silent "$@"
40}
41
42# NOTE: We're testing ASDL code generation with --strict because we might want
43# Oils to pass under --strict someday.
44typed-demo-asdl() {
45 # We want to exclude ONLY pylib.collections_, but somehow --exclude
46 # '.*collections_\.py' does not do it. So --follow-imports=silent. Tried
47 # --verbose too
48 asdl-check \
49 _devbuild/gen/typed_demo_asdl.py asdl/examples/typed_demo.py
50
51 PYTHONPATH=$PY_PATH asdl/examples/typed_demo.py "$@"
52}
53
54check-arith() {
55 # NOTE: There are still some Any types here! We don't want them for
56 # translation.
57
58 asdl-check \
59 asdl/examples/typed_arith_parse.py \
60 asdl/examples/typed_arith_parse_test.py \
61 asdl/examples/tdop.py
62}
63
64typed-arith-asdl() {
65 check-arith
66
67 PYTHONPATH=$PY_PATH asdl/examples/typed_arith_parse_test.py
68
69 banner 'parse'
70 PYTHONPATH=$PY_PATH asdl/examples/typed_arith_parse.py parse '40+2'
71 echo
72
73 banner 'eval'
74 PYTHONPATH=$PY_PATH asdl/examples/typed_arith_parse.py eval '40+2+5'
75 echo
76}
77
78check-types() {
79 build/py.sh py-asdl-examples
80
81 asdl-check _devbuild/gen/shared_variant_asdl.py
82
83 banner 'typed-arith-asdl'
84 typed-arith-asdl
85
86 banner 'typed-demo-asdl'
87 typed-demo-asdl
88}
89
90"$@"