OILS / ysh / run.sh View on Github | oilshell.org

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