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

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