OILS / test / ble.sh View on Github | oilshell.org

139 lines, 48 significant
1#!/usr/bin/env bash
2#
3# Run ble.sh tests.
4#
5# Usage:
6# test/ble.sh <function name>
7
8set -o nounset
9set -o pipefail
10set -o errexit
11
12source test/common.sh
13
14readonly BASE_DIR=_clone/ble.sh
15
16clone() {
17 local out=$BASE_DIR
18 mkdir -p $out
19 git clone --recursive --depth=50 --branch=osh \
20 https://github.com/akinomyoga/ble.sh $out
21 git clone --depth=50 \
22 https://github.com/akinomyoga/contra.git $out/ext/contra.src
23}
24
25build() {
26 # make ble.sh
27 cd $BASE_DIR
28 make
29
30 # make contra for test
31 cd ext/contra.src
32 make
33 cp src/contra ..
34}
35
36# https://superuser.com/questions/380772/removing-ansi-color-codes-from-text-stream
37filter-ansi() {
38 sed 's/\x1b\[[0-9;]*m//g'
39}
40
41run-tests-osh-bash() {
42 # Hm the tests detect ble.osh or ble.sh, this doesn't work
43 run-tests-osh bash
44}
45
46run-tests-osh-py() {
47 run-tests-osh ../../bin/osh
48}
49
50run-tests-osh-cpp() {
51 # Find osh binary created by devtools/release-native.sh test-tar
52 # test/wild-runner.sh uses it. We can't extract it over the repo.
53 export-osh-cpp _tmp/native-tar-test opt
54
55 run-tests-osh $OSH
56}
57
58run-tests-osh() {
59 ### Source the 35K line file, but only run selected tests
60
61 local osh=$1
62
63 pushd $BASE_DIR
64
65 # Fork of oshrc.test-util, to make it take less time
66 local myscript=myscript
67
68 cat >$myscript <<'EOF'
69#shopt -s eval_unsafe_arith
70HISTFILE=$HOME/.osh_history
71
72# Disabled for now, takes quite awhile
73# lib/test-canvas.sh \
74
75for script in \
76 out/ble.osh \
77 lib/test-main.sh \
78 lib/test-util.sh \
79 lib/test-decode.sh
80do
81 echo
82 echo "Running $script"
83 echo
84
85 time . $script
86
87 echo
88 echo "DONE Running $script"
89 echo
90done
91
92exit
93EOF
94
95 #wc -l oshrc.test-util
96 #wc -l out/ble.osh
97 #wc -l lib/test-util.sh
98
99 # Shorter tests
100 $osh --rcfile $myscript -i | filter-ansi
101
102 #../../bin/osh -i --rcfile oshrc.test-util | filter-ansi
103
104 # Longer tests
105 # TODO: Run these with osh-cpp
106 # ../../bin/osh out/ble.osh --test | filter-ansi
107
108 popd
109
110 echo DONE
111}
112
113# Seems to take about 12 seconds
114bash-suite() {
115 ### Run the 35K line file with --test
116
117 cd $BASE_DIR
118
119 set +o errexit
120 bash out/ble.sh --test | filter-ansi
121 echo 'Failure suppressed'
122
123 # Some failures, possibly due to old version of bash
124
125 # 98.1% [section] ble/util: 1205/1228 (23 fail, 0 crash, 6 skip)
126 # 100.0% [section] ble/canvas/trace (relative:confine:measure-bbox): 17/17 (0 fail, 0 crash, 0 skip)
127 # 100.0% [section] ble/canvas/trace (cfuncs): 18/18 (0 fail, 0 crash, 0 skip)
128 # 100.0% [section] ble/canvas/trace (justify): 30/30 (0 fail, 0 crash, 0 skip)
129 # 100.0% [section] ble/canvas/trace-text: 11/11 (0 fail, 0 crash, 0 skip)
130 # 100.0% [section] ble/textmap#update: 5/5 (0 fail, 0 crash, 0 skip)
131 # 100.0% [section] ble/unicode/GraphemeCluster/c2break: 77/77 (0 fail, 0 crash, 0 skip)
132 # 100.0% [section] ble/unicode/GraphemeCluster/c2break (GraphemeBreakTest.txt): 3251/3251 (0 fail, 0 crash, 0 skip)
133 # 100.0% [section] ble/decode: 33/33 (0 fail, 0 crash, 0 skip)
134 # 100.0% [section] ble/edit: 2/2 (0 fail, 0 crash, 0 skip)
135 # 100.0% [section] ble/syntax: 22/22 (0 fail, 0 crash, 0 skip)
136 # 100.0% [section] ble/complete: 7/7 (0 fail, 0 crash, 0 skip)
137}
138
139"$@"