| 1 | #!/usr/bin/env bash
|
| 2 | #
|
| 3 | # Usage:
|
| 4 | # yaks/TEST.sh <function name>
|
| 5 |
|
| 6 | set -o nounset
|
| 7 | set -o pipefail
|
| 8 | set -o errexit
|
| 9 |
|
| 10 | source build/dev-shell.sh # python3 in PATH
|
| 11 | source devtools/run-task.sh
|
| 12 | source test/common.sh # run-test-funcs
|
| 13 |
|
| 14 | build() {
|
| 15 | build/py.sh gen-asdl-py 'yaks/yaks.asdl'
|
| 16 | }
|
| 17 |
|
| 18 | check() {
|
| 19 | build
|
| 20 |
|
| 21 | # pyext/fastfunc is a dependency of ASDL
|
| 22 | # Source is Python 2
|
| 23 |
|
| 24 | # These flags are in devtools/types.sh
|
| 25 | #local mypy_flags='--strict --no-strict-optional'
|
| 26 |
|
| 27 | # 514 errors! Not sure why we need the extra flag.
|
| 28 | #local mypy_flags='--strict'
|
| 29 | local mypy_flags='--strict --follow-imports=silent'
|
| 30 |
|
| 31 | MYPYPATH='.:pyext' python3 -m \
|
| 32 | mypy $mypy_flags --py2 yaks/yaks_main.py
|
| 33 | }
|
| 34 |
|
| 35 | yaks() {
|
| 36 | PYTHONPATH='.:vendor' yaks/yaks_main.py "$@"
|
| 37 | }
|
| 38 |
|
| 39 | test-hello() {
|
| 40 | yaks cpp yaks/examples/hello.yaks
|
| 41 |
|
| 42 | # TODO: fibonacci program, etc. building up to yaks in yaks itself.
|
| 43 |
|
| 44 | # type check only
|
| 45 | # yaks/yaks.py check testdata/hello.yaks
|
| 46 | }
|
| 47 |
|
| 48 | test-hello-cpp() {
|
| 49 | # Translate and compile the yaks translator
|
| 50 | #local bin=_bin/cxx-asan/yaks/yaks_main.mycpp
|
| 51 | #ninja $bin
|
| 52 |
|
| 53 | # Generate C++ from an example
|
| 54 | #$bin cpp yaks/examples/hello.yaks
|
| 55 |
|
| 56 | # Translate and compile the yaks translator
|
| 57 | # Then use it to generate C++ from an example
|
| 58 | # Then wrap and compile that
|
| 59 | local hello=_bin/cxx-asan/yaks/examples/hello.yaks
|
| 60 | ninja $hello
|
| 61 |
|
| 62 | set -o xtrace
|
| 63 | set +o errexit
|
| 64 | $hello
|
| 65 | local status=$?
|
| 66 | set -o errexit
|
| 67 |
|
| 68 | echo status=$status
|
| 69 | }
|
| 70 |
|
| 71 | soil-run() {
|
| 72 | ### Used by soil/worker.sh. Prints to stdout.
|
| 73 |
|
| 74 | # Hm I guess we need the Python 2 wedge here. Right now deps/Dockerfile.pea
|
| 75 | # has a Python 3 wedge and MyPy, which we still need.
|
| 76 | #echo 'Disabled until container image has python2-dev to build pyext/fastfunc'
|
| 77 | #return
|
| 78 |
|
| 79 | run-test-funcs
|
| 80 |
|
| 81 | check
|
| 82 | }
|
| 83 |
|
| 84 | run-task "$@"
|