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

121 lines, 51 significant
1#!/usr/bin/env bash
2#
3# Usage:
4# yaks/TEST.sh <function name>
5
6: ${LIB_OSH=stdlib/osh}
7source $LIB_OSH/bash-strict.sh
8source $LIB_OSH/task-five.sh
9
10REPO_ROOT=$(cd "$(dirname $0)/.."; pwd)
11
12source build/dev-shell.sh # python3 in PATH
13source test/common.sh # run-test-funcs
14
15unit() {
16 run-one-test 'yaks/yaks_runtime_test' '' asan
17 run-one-test 'frontend/arg_types_test' '' ubsan
18}
19
20build() {
21 build/py.sh gen-asdl-py 'yaks/yaks.asdl'
22}
23
24check() {
25 build
26
27 # pyext/fastfunc is a dependency of ASDL
28 # Source is Python 2
29
30 # These flags are in devtools/types.sh
31 #local mypy_flags='--strict --no-strict-optional'
32
33 # 514 errors! Not sure why we need the extra flag.
34 #local mypy_flags='--strict'
35 local mypy_flags='--strict --follow-imports=silent'
36
37 MYPYPATH='.:pyext' python3 -m \
38 mypy $mypy_flags --py2 yaks/yaks_main.py
39}
40
41yaks() {
42 PYTHONPATH='.:vendor' yaks/yaks_main.py "$@"
43}
44
45BAD=(
46 # should be a module
47 '(print "hi")'
48 '+'
49
50 # Unexpected EOF
51 '(print'
52
53 # Unexpected trailing input
54 '(print)oops'
55
56 # This one works
57 #'(module foo)'
58)
59
60
61# the transformer raises AssertionError
62
63test-syntax-errors() {
64 for b in "${BAD[@]}"; do
65 local src=_tmp/bad.yaks
66
67 echo "$b" >$src
68
69 echo "$b"
70 yaks cpp $src || true
71 echo
72
73 done
74}
75
76test-hello() {
77 yaks cpp yaks/examples/hello.yaks
78
79 # TODO: fibonacci program, etc. building up to yaks in yaks itself.
80
81 # type check only
82 # yaks/yaks.py check testdata/hello.yaks
83}
84
85test-hello-cpp() {
86 # Translate and compile the yaks translator
87 #local bin=_bin/cxx-asan/yaks/yaks_main.mycpp
88 #ninja $bin
89
90 # Generate C++ from an example
91 #$bin cpp yaks/examples/hello.yaks
92
93 # Translate and compile the yaks translator
94 # Then use it to generate C++ from an example
95 # Then wrap and compile that
96 local hello=_bin/cxx-asan/yaks/examples/hello.yaks
97 ninja $hello
98
99 set -o xtrace
100 set +o errexit
101 $hello
102 local status=$?
103 set -o errexit
104
105 echo status=$status
106}
107
108soil-run() {
109 ### Used by soil/worker.sh. Prints to stdout.
110
111 # Hm I guess we need the Python 2 wedge here. Right now deps/Dockerfile.pea
112 # has a Python 3 wedge and MyPy, which we still need.
113 #echo 'Disabled until container image has python2-dev to build pyext/fastfunc'
114 #return
115
116 run-test-funcs
117
118 check
119}
120
121task-five "$@"