OILS / ysh / run.sh View on Github | oils.pub

111 lines, 69 significant
1#!/usr/bin/env bash
2#
3# Usage:
4# ysh/run.sh <function name>
5
6set -o nounset
7set -o pipefail
8set -o errexit
9
10source test/common.sh
11
12YSH=${YSH:-'bin/ysh'}
13OSH_CPP=_bin/cxx-asan/osh
14# Assertion failed
15#OSH_CPP=_bin/cxx-dbg/osh
16
17# This doesn't distinguish if they should parse with osh or ysh though!
18
19parse-one() {
20 echo ---
21
22 local prog="$1"
23 local skip=''
24 case $prog in
25 */assign.osh) skip=T ;;
26 esac
27
28 if test -n "$skip"; then
29 echo "skipping $prog"
30 return
31 fi
32
33 set +o errexit
34 $OSH -n "$@"
35 if test $? -ne 0; then return 255; fi # make xargs quit
36}
37
38test-parse-osh() {
39 find ysh/testdata -name '*.sh' -o -name '*.osh' \
40 | xargs -n 1 -- $0 parse-one
41}
42
43test-run-osh() {
44 ### Run programs with OSH
45
46 for prog in ysh/testdata/*.{sh,osh}; do
47 echo $prog
48
49 local skip=''
50 case $prog in
51 */assign.osh) skip=T ;;
52 */no-dynamic-scope.osh) skip=T ;;
53 */inline-function-calls.sh) skip=T ;;
54 esac
55
56 if test -n "$skip"; then
57 echo "skipping $prog"
58 continue
59 fi
60
61 echo ---
62 $OSH $prog
63 done
64}
65
66test-run-ysh() {
67 ### Run programs with YSH
68
69 for prog in ysh/testdata/*.ysh; do
70 echo ---
71 $YSH $prog all
72 done
73}
74
75demo() {
76 ### Run some of them selectively
77
78 bin/osh ysh/testdata/array-rewrite-1.sh
79
80 bin/osh ysh/testdata/array-rewrite-2.sh
81 bin/osh ysh/testdata/array-splice-demo.osh
82
83 bin/osh ysh/testdata/hello.osh
84
85 bin/osh ysh/testdata/inline-function-calls.ysh all
86
87 bin/osh ysh/testdata/sigil-pairs.sh
88
89 set +o errexit
90 # Fails correctly
91 bin/osh ysh/testdata/no-dynamic-scope.osh
92
93 bin/osh ysh/testdata/assign.osh
94}
95
96soil-run() {
97 ### Used by soil/worker.sh. Prints to stdout.
98 run-test-funcs
99}
100
101soil-run-cpp() {
102 ninja $OSH_CPP
103 OSH=$OSH_CPP run-test-funcs
104}
105
106run-for-release() {
107 ### Used by devtools/release.sh. Writes a file.
108 run-other-suite-for-release ysh-large run-test-funcs
109}
110
111"$@"